Skip to content

Commit

Permalink
added conditional compiling for zlib
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhongli committed Feb 28, 2019
1 parent df4047b commit 97ece86
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

CC = g++ -Wall -ggdb
CC = g++ -pg
CC = g++

# without OpenMP

# default with OpenMP
# with OpenMP
# in command line:
# make openmp=yes
Expand All @@ -14,6 +12,21 @@ else
CCFLAGS = -fopenmp
endif

#LDFLAGS = -static -lz -o
#LDFLAGS = /usr/lib/x86_64-linux-gnu/libz.a -o

# default with zlib
# without zlib
# in command line:
# make zlib=no
ifeq ($(zlib),no)
CCFLAGS +=
LDFLAGS += -o
else
CCFLAGS += -DWITH_ZLIB
LDFLAGS += -lz -o
endif

# support debugging
# in command line:
# make debug=yes
Expand All @@ -28,9 +41,6 @@ ifdef MAX_SEQ
CCFLAGS += -DMAX_SEQ=$(MAX_SEQ)
endif

#LDFLAGS = -static -lz -o
LDFLAGS += -lz -o

PROGS = cd-hit cd-hit-est cd-hit-2d cd-hit-est-2d cd-hit-div cd-hit-454

# Propagate hardening flags
Expand Down
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ don't have zlib, please install it first.
How to compile
1. Compile with multi-threading support (default): make
2. Compile without multi-threading support (if you are on very old systems): make openmp=no

3. Compile without zlib (if you can not install zlib): make zlib=no

Having problems to compile
Please download the pre-compiled binary packages for Linux systems
Please contact the author


For cd-hit-auxtools
Expand Down
33 changes: 18 additions & 15 deletions cdhit-common.c++
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ void Sequence::PrintInfo( int id, FILE *fout, const Options & options, char *buf
// tot_length is the total bytes of sequence record
void SequenceDB::Readgz( const char *file, const Options & options )
{

#ifdef WITH_ZLIB
Sequence one;
Sequence des;
gzFile fin = gzopen(file, "r");
Expand Down Expand Up @@ -1766,16 +1766,12 @@ void SequenceDB::Readgz( const char *file, const Options & options )
one.tot_length += strlen(buffer); one += buffer;
}
}
#if 0
int i, n = 0;
for(i=0; i<sequences.size(); i++) n += sequences[i].bufsize + 4;
cout<<n<<"\t"<<sequences.capacity() * sizeof(Sequence)<<endl;
int i;
scanf( "%i", & i );
#endif
one.identifier = NULL;
delete[] buffer;
gzclose( fin );
#else
bomb_error("this program was not compiled with zlib");
#endif
}


Expand Down Expand Up @@ -1886,6 +1882,7 @@ void SequenceDB::Read( const char *file, const Options & options )
// PE reads liwz, disable swap option
void SequenceDB::Readgz( const char *file, const char *file2, const Options & options )
{
#ifdef WITH_ZLIB
Sequence one, two;
Sequence des;
gzFile fin = gzopen(file, "r");
Expand Down Expand Up @@ -2023,19 +2020,16 @@ void SequenceDB::Readgz( const char *file, const char *file2, const Options & op
two.tot_length+= strlen(buffer2); two+= buffer2;
}
}
#if 0
int i, n = 0;
for(i=0; i<sequences.size(); i++) n += sequences[i].bufsize + 4;
cout<<n<<"\t"<<sequences.capacity() * sizeof(Sequence)<<endl;
int i;
scanf( "%i", & i );
#endif
one.identifier = NULL;
two.identifier = NULL;
delete[] buffer;
gzclose( fin );
delete[] buffer2;
gzclose( fin2 );
#else
bomb_error("this program was not compiled with zlib");
#endif

}

// PE reads liwz, disable swap option
Expand Down Expand Up @@ -2353,6 +2347,7 @@ void SequenceDB::DivideSave( const char *db, const char *newdb, int n, const Opt
// input db is gzipped
void SequenceDB::WriteClustersgz( const char *db, const char *newdb, const Options & options )
{
#ifdef WITH_ZLIB
gzFile fin = gzopen(db, "r");
FILE *fout = fopen( newdb, "w+" );
int i, j, n = rep_seqs.size();
Expand Down Expand Up @@ -2381,6 +2376,10 @@ void SequenceDB::WriteClustersgz( const char *db, const char *newdb, const Optio
gzclose( fin );
fclose( fout );
delete []buf;
#else
bomb_error("this program was not compiled with zlib");
#endif

}

void SequenceDB::WriteClusters( const char *db, const char *newdb, const Options & options )
Expand Down Expand Up @@ -2426,6 +2425,7 @@ void SequenceDB::WriteClusters( const char *db, const char *newdb, const Options
// liwz PE output
void SequenceDB::WriteClustersgz( const char *db, const char *db_pe, const char *newdb, const char *newdb_pe, const Options & options )
{
#ifdef WITH_ZLIB
gzFile fin = gzopen(db, "r");
gzFile fin_pe = gzopen(db_pe, "r");
FILE *fout = fopen( newdb, "w+" );
Expand Down Expand Up @@ -2499,6 +2499,9 @@ void SequenceDB::WriteClustersgz( const char *db, const char *db_pe, const char
fclose( fout );
fclose( fout_pe );
delete []buf;
#else
bomb_error("this program was not compiled with zlib");
#endif
}


Expand Down
3 changes: 3 additions & 0 deletions cdhit-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
#include<ctype.h>
#include<stdint.h>
#include<time.h>

#ifdef WITH_ZLIB
#include<zlib.h>
#endif

#include<valarray>
#include<vector>
Expand Down

0 comments on commit 97ece86

Please sign in to comment.