2 # Copyright (C) 1995-2011 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
29 TEST_LDFLAGS=-L. libz.a
35 SHAREDLIBV=libz.so.1.2.5.2
37 LIBS=$(STATICLIB) $(SHAREDLIBV)
49 exec_prefix = ${prefix}
50 libdir = ${exec_prefix}/lib
51 sharedlibdir = ${libdir}
52 includedir = ${prefix}/include
53 mandir = ${prefix}/share/man
54 man3dir = ${mandir}/man3
55 pkgconfigdir = ${libdir}/pkgconfig
56 tempfile := $(shell mktemp -u __XXXXXX)
58 OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
59 OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
60 OBJC = $(OBJZ) $(OBJG)
62 PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
63 PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
64 PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
66 # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
70 OBJS = $(OBJC) $(OBJA)
72 PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
76 static: example$(EXE) minigzip$(EXE)
78 shared: examplesh$(EXE) minigzipsh$(EXE)
80 all64: example64$(EXE) minigzip64$(EXE)
84 test: all teststatic testshared
87 @if echo hello world | ./minigzip | ./minigzip -d && ./example; then \
88 echo ' *** zlib test OK ***'; \
90 echo ' *** zlib test FAILED ***'; false; \
95 @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
96 LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
97 DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
98 SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
99 if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh; then \
100 echo ' *** zlib shared test OK ***'; \
102 echo ' *** zlib shared test FAILED ***'; false; \
107 @if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64; then \
108 echo ' *** zlib 64-bit test OK ***'; \
110 echo ' *** zlib 64-bit test FAILED ***'; false; \
115 $(AR) $(ARFLAGS) $@ $(OBJS)
116 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
119 $(CPP) match.S > _match.s
125 $(CPP) match.S > _match.s
126 $(CC) -c -fPIC _match.s
130 example.o: test/example.c zlib.h zconf.h
131 $(CC) $(CFLAGS) -I. -c -o $@ test/example.c
133 minigzip.o: test/minigzip.c zlib.h zconf.h
134 $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
136 example64.o: test/example.c zlib.h zconf.h
137 $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c
139 minigzip64.o: test/minigzip.c zlib.h zconf.h
140 $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c
145 -@mkdir objs 2>/dev/null || test -d objs
146 $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
149 placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
150 $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
151 rm -f $(SHAREDLIB) $(SHAREDLIBM)
152 ln -s $@ $(SHAREDLIB)
153 ln -s $@ $(SHAREDLIBM)
156 example$(EXE): example.o $(STATICLIB)
157 $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
159 minigzip$(EXE): minigzip.o $(STATICLIB)
160 $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
162 examplesh$(EXE): example.o $(SHAREDLIBV)
163 $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
165 minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
166 $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
168 example64$(EXE): example64.o $(STATICLIB)
169 $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
171 minigzip64$(EXE): minigzip64.o $(STATICLIB)
172 $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
174 install-libs: $(LIBS)
175 -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
176 -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
177 -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
178 -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
179 -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
180 cp $(STATICLIB) $(DESTDIR)$(libdir)
181 chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
182 -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
183 -@if test -n "$(SHAREDLIBV)"; then \
184 cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
185 echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
186 chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
187 echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
188 rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
189 ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
190 ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
191 ($(LDCONFIG) || true) >/dev/null 2>&1; \
193 cp zlib.3 $(DESTDIR)$(man3dir)
194 chmod 644 $(DESTDIR)$(man3dir)/zlib.3
195 cp zlib.pc $(DESTDIR)$(pkgconfigdir)
196 chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
197 # The ranlib in install is needed on NeXTSTEP which checks file times
198 # ldconfig is for Linux
200 install: install-libs
201 -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
202 cp zlib.h zconf.h $(DESTDIR)$(includedir)
203 chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
206 cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
207 cd $(DESTDIR)$(libdir); rm -f libz.a; \
208 if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
209 rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
211 cd $(DESTDIR)$(man3dir); rm -f zlib.3
212 cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
217 groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
219 zconf.h.cmakein: zconf.h.in
220 -@echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" > $(tempfile)
221 -@sed -f $(tempfile) zconf.h.in > zconf.h.cmakein
222 -@touch -r zconf.h.in zconf.h.cmakein
226 cp -p zconf.h.in zconf.h
231 example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
232 example64$(EXE) minigzip64$(EXE) \
233 libz.* foo.gz so_locations \
234 _match.s maketree contrib/infback9/*.o
236 rm -f *.gcda *.gcno *.gcov
238 maintainer-clean: distclean
239 distclean: clean zconf zconf.h.cmakein docs
240 rm -f Makefile zlib.pc
242 -@printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile
243 -@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
244 -@touch -r Makefile.in Makefile
250 makedepend -- $(CFLAGS) -- *.[ch]
252 # DO NOT DELETE THIS LINE -- make depend depends on it.
254 adler32.o zutil.o: zutil.h zlib.h zconf.h
255 gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
256 compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
257 crc32.o: zutil.h zlib.h zconf.h crc32.h
258 deflate.o: deflate.h zutil.h zlib.h zconf.h
259 infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
260 inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
261 inftrees.o: zutil.h zlib.h zconf.h inftrees.h
262 trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
264 adler32.lo zutil.lo: zutil.h zlib.h zconf.h
265 gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
266 compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
267 crc32.lo: zutil.h zlib.h zconf.h crc32.h
268 deflate.lo: deflate.h zutil.h zlib.h zconf.h
269 infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
270 inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
271 inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
272 trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h