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
29 TEST_LDFLAGS=-L. libz.a
35 SHAREDLIBV=libz.so.1.2.5
37 LIBS=$(STATICLIB) $(SHAREDLIBV)
48 exec_prefix = ${prefix}
49 libdir = ${exec_prefix}/lib
50 sharedlibdir = ${libdir}
51 includedir = ${prefix}/include
52 mandir = ${prefix}/share/man
53 man3dir = ${mandir}/man3
54 pkgconfigdir = ${libdir}/pkgconfig
56 OBJC = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
57 gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
59 PIC_OBJC = adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo \
60 gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo
62 # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
66 OBJS = $(OBJC) $(OBJA)
68 PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
72 static: example$(EXE) minigzip$(EXE)
74 shared: examplesh$(EXE) minigzipsh$(EXE)
76 all64: example64$(EXE) minigzip64$(EXE)
80 test: all teststatic testshared
83 @if echo hello world | ./minigzip | ./minigzip -d && ./example; then \
84 echo ' *** zlib test OK ***'; \
86 echo ' *** zlib test FAILED ***'; false; \
91 @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
92 LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
93 DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
94 SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
95 if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh; then \
96 echo ' *** zlib shared test OK ***'; \
98 echo ' *** zlib shared test FAILED ***'; false; \
103 @if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64; then \
104 echo ' *** zlib 64-bit test OK ***'; \
106 echo ' *** zlib 64-bit test FAILED ***'; false; \
112 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
115 $(CPP) match.S > _match.s
121 $(CPP) match.S > _match.s
122 $(CC) -c -fPIC _match.s
126 example64.o: example.c zlib.h zconf.h
127 $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ example.c
129 minigzip64.o: minigzip.c zlib.h zconf.h
130 $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ minigzip.c
135 -@mkdir objs 2>/dev/null || test -d objs
136 $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
139 $(SHAREDLIBV): $(PIC_OBJS)
140 $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
141 rm -f $(SHAREDLIB) $(SHAREDLIBM)
142 ln -s $@ $(SHAREDLIB)
143 ln -s $@ $(SHAREDLIBM)
146 example$(EXE): example.o $(STATICLIB)
147 $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
149 minigzip$(EXE): minigzip.o $(STATICLIB)
150 $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
152 examplesh$(EXE): example.o $(SHAREDLIBV)
153 $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
155 minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
156 $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
158 example64$(EXE): example64.o $(STATICLIB)
159 $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
161 minigzip64$(EXE): minigzip64.o $(STATICLIB)
162 $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
164 install-libs: $(LIBS)
165 -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
166 -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
167 -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
168 -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
169 -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
170 cp $(STATICLIB) $(DESTDIR)$(libdir)
171 cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)
172 cd $(DESTDIR)$(libdir); chmod u=rw,go=r $(STATICLIB)
173 -@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
174 -@cd $(DESTDIR)$(sharedlibdir); if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
175 chmod 755 $(SHAREDLIBV); \
176 rm -f $(SHAREDLIB) $(SHAREDLIBM); \
177 ln -s $(SHAREDLIBV) $(SHAREDLIB); \
178 ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
179 ($(LDCONFIG) || true) >/dev/null 2>&1; \
181 cp zlib.3 $(DESTDIR)$(man3dir)
182 chmod 644 $(DESTDIR)$(man3dir)/zlib.3
183 cp zlib.pc $(DESTDIR)$(pkgconfigdir)
184 chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
185 # The ranlib in install is needed on NeXTSTEP which checks file times
186 # ldconfig is for Linux
188 install: install-libs
189 -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
190 cp zlib.h zconf.h $(DESTDIR)$(includedir)
191 chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
194 cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
195 cd $(DESTDIR)$(libdir); rm -f libz.a; \
196 if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
197 rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
199 cd $(DESTDIR)$(man3dir); rm -f zlib.3
200 cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
205 groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
207 zconf.h.in: zconf.h.cmakein
208 sed "/^#cmakedefine/D" < zconf.h.cmakein > zconf.h.in
209 touch -r zconf.h.cmakein zconf.h.in
212 cp -p zconf.h.in zconf.h
217 example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
218 example64$(EXE) minigzip64$(EXE) \
219 libz.* foo.gz so_locations \
220 _match.s maketree contrib/infback9/*.o
223 maintainer-clean: distclean
224 distclean: clean zconf docs
225 rm -f Makefile zlib.pc
227 -@printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile
228 -@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
229 -@touch -r Makefile.in Makefile
235 makedepend -- $(CFLAGS) -- *.[ch]
237 # DO NOT DELETE THIS LINE -- make depend depends on it.
239 adler32.o zutil.o: zutil.h zlib.h zconf.h
240 gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
241 compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
242 crc32.o: zutil.h zlib.h zconf.h crc32.h
243 deflate.o: deflate.h zutil.h zlib.h zconf.h
244 infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
245 inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
246 inftrees.o: zutil.h zlib.h zconf.h inftrees.h
247 trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
249 adler32.lo zutil.lo: zutil.h zlib.h zconf.h
250 gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
251 compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
252 crc32.lo: zutil.h zlib.h zconf.h crc32.h
253 deflate.lo: deflate.h zutil.h zlib.h zconf.h
254 infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
255 inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
256 inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
257 trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h