2 # Copyright (C) 1995-2010 Jean-loup Gailly.
3 # For conditions of distribution and use, see copyright notice in zlib.h
5 # To compile and test, type:
6 # ./configure; make test
7 # Normally configure builds both a static and a shared library.
8 # If you want to build just a static library, use: ./configure --static
10 # To use the asm code, type:
11 # cp contrib/asm?86/match.S ./match.S
12 # make LOC=-DASMV OBJA=match.o
14 # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
16 # To install in $HOME instead of /usr/local, use:
17 # make install prefix=$HOME
22 #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
24 #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
25 # -Wstrict-prototypes -Wmissing-prototypes
35 SHAREDLIBV=libz.so.1.2.3.7
37 LIBS=$(STATICLIB) $(SHAREDLIB) $(SHAREDLIBV)
46 exec_prefix = ${prefix}
47 libdir = ${exec_prefix}/lib
48 includedir = ${prefix}/include
49 mandir = ${prefix}/share/man
50 man3dir = ${mandir}/man3
51 pkgconfigdir = ${libdir}/pkgconfig
53 OBJC = adler32.o compress.o crc32.o deflate.o gzclose.o gzio.o gzlib.o gzread.o \
54 gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
56 # to use the asm code: make OBJA=match.o
62 OBJS = $(addprefix $(objdir), $(OBJC) $(OBJA))
64 PIC_OBJS = $(addprefix $(picdir), $(OBJC) $(OBJA))
68 static: example$(EXE) minigzip$(EXE)
70 shared: examplesh$(EXE) minigzipsh$(EXE)
72 all64: example64$(EXE) minigzip64$(EXE)
76 test: all teststatic testshared
79 @echo hello world | ./minigzip | ./minigzip -d || \
80 echo ' *** minigzip test FAILED ***' ; \
82 echo ' *** zlib test OK ***'; \
84 echo ' *** zlib test FAILED ***'; \
89 @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
90 LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
91 DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
92 SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
93 echo hello world | ./minigzipsh | ./minigzipsh -d || \
94 echo ' *** minigzip shared test FAILED ***' ; \
95 if ./examplesh; then \
96 echo ' *** zlib shared test OK ***'; \
98 echo ' *** zlib shared test FAILED ***'; \
103 @echo hello world | ./minigzip64 | ./minigzip64 -d || \
104 echo ' *** minigzip 64-bit test FAILED ***' ; \
105 if ./example64; then \
106 echo ' *** zlib 64-bit test OK ***'; \
108 echo ' *** zlib 64-bit test FAILED ***'; \
114 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
116 objs/match.o: match.S
117 $(CPP) match.S > _match.s
118 $(CC) -c -o $@ _match.s
121 pics/match.o: match.S
122 $(CPP) match.S > _match.s
123 $(CC) -c -o $@ -fPIC _match.s
126 objs/example64.o: example.c zlib.h zconf.h
127 $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ example.c
129 objs/minigzip64.o: minigzip.c zlib.h zconf.h
130 $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ minigzip.c
133 $(CC) $(CFLAGS) -c -o $@ $<
136 $(CC) $(SFLAGS) -DPIC -c -o $@ $<
138 $(SHAREDLIBV): $(PIC_OBJS)
139 $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) -lc
140 rm -f $(SHAREDLIB) $(SHAREDLIBM)
141 ln -s $@ $(SHAREDLIB)
142 ln -s $@ $(SHAREDLIBM)
144 example$(EXE): objs/example.o $(STATICLIB)
145 $(CC) $(CFLAGS) -o $@ objs/example.o $(LDFLAGS)
147 minigzip$(EXE): objs/minigzip.o $(STATICLIB)
148 $(CC) $(CFLAGS) -o $@ objs/minigzip.o $(LDFLAGS)
150 examplesh$(EXE): objs/example.o $(SHAREDLIBV)
151 $(CC) $(CFLAGS) -o $@ objs/example.o -L. $(SHAREDLIBV)
153 minigzipsh$(EXE): objs/minigzip.o $(SHAREDLIBV)
154 $(CC) $(CFLAGS) -o $@ objs/minigzip.o -L. $(SHAREDLIBV)
156 example64$(EXE): objs/example64.o $(STATICLIB)
157 $(CC) $(CFLAGS) -o $@ objs/example64.o $(LDFLAGS)
159 minigzip64$(EXE): objs/minigzip64.o $(STATICLIB)
160 $(CC) $(CFLAGS) -o $@ objs/minigzip64.o $(LDFLAGS)
162 install-libs: $(LIBS)
163 -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
164 -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
165 -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
166 -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
167 cp $(LIBS) $(DESTDIR)$(libdir)
168 cd $(DESTDIR)$(libdir); chmod 755 $(SHAREDLIB) ; chmod u=rw,go=r $(STATICLIB)
169 -@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
170 cd $(DESTDIR)$(libdir); if test -f $(SHAREDLIBV); then \
171 rm -f $(SHAREDLIB) $(SHAREDLIBM); \
172 ln -s $(SHAREDLIBV) $(SHAREDLIB); \
173 ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
174 (ldconfig || true) >/dev/null 2>&1; \
176 cp zlib.3 $(DESTDIR)$(man3dir)
177 chmod 644 $(DESTDIR)$(man3dir)/zlib.3
178 cp zlib.pc $(DESTDIR)$(pkgconfigdir)
179 chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
180 # The ranlib in install is needed on NeXTSTEP which checks file times
181 # ldconfig is for Linux
183 install: install-libs
184 -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
185 cp zlib.h zconf.h $(DESTDIR)$(includedir)
186 chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
189 cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
190 cd $(DESTDIR)$(libdir); rm -f libz.a; \
191 if test -f $(SHAREDLIBV); then \
192 rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
194 cd $(DESTDIR)$(man3dir); rm -f zlib.3
195 cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
199 rm -f $(objdir)* $(picdir)* *~ \
200 example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
201 example64$(EXE) minigzip64$(EXE) \
202 libz.* foo.gz so_locations \
203 _match.s maketree contrib/infback9/*.o
205 maintainer-clean: distclean
207 cp -p zconf.in.h zconf.h
208 rm -f zlib.pc .DS_Store
209 -@printf 'all:\n\t-@echo "Use ./configure first. Thank you."\n' > Makefile
210 -@ touch -r Makefile.in Makefile objs pics
216 makedepend -- $(CFLAGS) -- *.[ch]
218 # DO NOT DELETE THIS LINE -- make depend depends on it.
220 adler32.o gzio.o zutil.o: zutil.h zlib.h zconf.h
221 gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
222 compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
223 crc32.o: zutil.h zlib.h zconf.h crc32.h
224 deflate.o: deflate.h zutil.h zlib.h zconf.h
225 infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
226 inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
227 inftrees.o: zutil.h zlib.h zconf.h inftrees.h
228 trees.o: deflate.h zutil.h zlib.h zconf.h trees.h