cannam@128
|
1 # Makefile for zlib
|
cannam@128
|
2 # Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler
|
cannam@128
|
3 # For conditions of distribution and use, see copyright notice in zlib.h
|
cannam@128
|
4
|
cannam@128
|
5 # To compile and test, type:
|
cannam@128
|
6 # ./configure; make test
|
cannam@128
|
7 # Normally configure builds both a static and a shared library.
|
cannam@128
|
8 # If you want to build just a static library, use: ./configure --static
|
cannam@128
|
9
|
cannam@128
|
10 # To use the asm code, type:
|
cannam@128
|
11 # cp contrib/asm?86/match.S ./match.S
|
cannam@128
|
12 # make LOC=-DASMV OBJA=match.o
|
cannam@128
|
13
|
cannam@128
|
14 # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
|
cannam@128
|
15 # make install
|
cannam@128
|
16 # To install in $HOME instead of /usr/local, use:
|
cannam@128
|
17 # make install prefix=$HOME
|
cannam@128
|
18
|
cannam@128
|
19 CC=cc
|
cannam@128
|
20
|
cannam@128
|
21 CFLAGS=-O
|
cannam@128
|
22 #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
cannam@128
|
23 #CFLAGS=-g -DDEBUG
|
cannam@128
|
24 #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
cannam@128
|
25 # -Wstrict-prototypes -Wmissing-prototypes
|
cannam@128
|
26
|
cannam@128
|
27 SFLAGS=-O
|
cannam@128
|
28 LDFLAGS=
|
cannam@128
|
29 TEST_LDFLAGS=-L. libz.a
|
cannam@128
|
30 LDSHARED=$(CC)
|
cannam@128
|
31 CPP=$(CC) -E
|
cannam@128
|
32
|
cannam@128
|
33 STATICLIB=libz.a
|
cannam@128
|
34 SHAREDLIB=libz.so
|
cannam@128
|
35 SHAREDLIBV=libz.so.1.2.8
|
cannam@128
|
36 SHAREDLIBM=libz.so.1
|
cannam@128
|
37 LIBS=$(STATICLIB) $(SHAREDLIBV)
|
cannam@128
|
38
|
cannam@128
|
39 AR=ar
|
cannam@128
|
40 ARFLAGS=rc
|
cannam@128
|
41 RANLIB=ranlib
|
cannam@128
|
42 LDCONFIG=ldconfig
|
cannam@128
|
43 LDSHAREDLIBC=-lc
|
cannam@128
|
44 TAR=tar
|
cannam@128
|
45 SHELL=/bin/sh
|
cannam@128
|
46 EXE=
|
cannam@128
|
47
|
cannam@128
|
48 prefix = /usr/local
|
cannam@128
|
49 exec_prefix = ${prefix}
|
cannam@128
|
50 libdir = ${exec_prefix}/lib
|
cannam@128
|
51 sharedlibdir = ${libdir}
|
cannam@128
|
52 includedir = ${prefix}/include
|
cannam@128
|
53 mandir = ${prefix}/share/man
|
cannam@128
|
54 man3dir = ${mandir}/man3
|
cannam@128
|
55 pkgconfigdir = ${libdir}/pkgconfig
|
cannam@128
|
56
|
cannam@128
|
57 OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
|
cannam@128
|
58 OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
|
cannam@128
|
59 OBJC = $(OBJZ) $(OBJG)
|
cannam@128
|
60
|
cannam@128
|
61 PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
|
cannam@128
|
62 PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
|
cannam@128
|
63 PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
|
cannam@128
|
64
|
cannam@128
|
65 # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
|
cannam@128
|
66 OBJA =
|
cannam@128
|
67 PIC_OBJA =
|
cannam@128
|
68
|
cannam@128
|
69 OBJS = $(OBJC) $(OBJA)
|
cannam@128
|
70
|
cannam@128
|
71 PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
|
cannam@128
|
72
|
cannam@128
|
73 all: static shared
|
cannam@128
|
74
|
cannam@128
|
75 static: example$(EXE) minigzip$(EXE)
|
cannam@128
|
76
|
cannam@128
|
77 shared: examplesh$(EXE) minigzipsh$(EXE)
|
cannam@128
|
78
|
cannam@128
|
79 all64: example64$(EXE) minigzip64$(EXE)
|
cannam@128
|
80
|
cannam@128
|
81 check: test
|
cannam@128
|
82
|
cannam@128
|
83 test: all teststatic testshared
|
cannam@128
|
84
|
cannam@128
|
85 teststatic: static
|
cannam@128
|
86 @TMPST=tmpst_$$; \
|
cannam@128
|
87 if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \
|
cannam@128
|
88 echo ' *** zlib test OK ***'; \
|
cannam@128
|
89 else \
|
cannam@128
|
90 echo ' *** zlib test FAILED ***'; false; \
|
cannam@128
|
91 fi; \
|
cannam@128
|
92 rm -f $$TMPST
|
cannam@128
|
93
|
cannam@128
|
94 testshared: shared
|
cannam@128
|
95 @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
|
cannam@128
|
96 LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
|
cannam@128
|
97 DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
|
cannam@128
|
98 SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
|
cannam@128
|
99 TMPSH=tmpsh_$$; \
|
cannam@128
|
100 if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \
|
cannam@128
|
101 echo ' *** zlib shared test OK ***'; \
|
cannam@128
|
102 else \
|
cannam@128
|
103 echo ' *** zlib shared test FAILED ***'; false; \
|
cannam@128
|
104 fi; \
|
cannam@128
|
105 rm -f $$TMPSH
|
cannam@128
|
106
|
cannam@128
|
107 test64: all64
|
cannam@128
|
108 @TMP64=tmp64_$$; \
|
cannam@128
|
109 if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \
|
cannam@128
|
110 echo ' *** zlib 64-bit test OK ***'; \
|
cannam@128
|
111 else \
|
cannam@128
|
112 echo ' *** zlib 64-bit test FAILED ***'; false; \
|
cannam@128
|
113 fi; \
|
cannam@128
|
114 rm -f $$TMP64
|
cannam@128
|
115
|
cannam@128
|
116 infcover.o: test/infcover.c zlib.h zconf.h
|
cannam@128
|
117 $(CC) $(CFLAGS) -I. -c -o $@ test/infcover.c
|
cannam@128
|
118
|
cannam@128
|
119 infcover: infcover.o libz.a
|
cannam@128
|
120 $(CC) $(CFLAGS) -o $@ infcover.o libz.a
|
cannam@128
|
121
|
cannam@128
|
122 cover: infcover
|
cannam@128
|
123 rm -f *.gcda
|
cannam@128
|
124 ./infcover
|
cannam@128
|
125 gcov inf*.c
|
cannam@128
|
126
|
cannam@128
|
127 libz.a: $(OBJS)
|
cannam@128
|
128 $(AR) $(ARFLAGS) $@ $(OBJS)
|
cannam@128
|
129 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
cannam@128
|
130
|
cannam@128
|
131 match.o: match.S
|
cannam@128
|
132 $(CPP) match.S > _match.s
|
cannam@128
|
133 $(CC) -c _match.s
|
cannam@128
|
134 mv _match.o match.o
|
cannam@128
|
135 rm -f _match.s
|
cannam@128
|
136
|
cannam@128
|
137 match.lo: match.S
|
cannam@128
|
138 $(CPP) match.S > _match.s
|
cannam@128
|
139 $(CC) -c -fPIC _match.s
|
cannam@128
|
140 mv _match.o match.lo
|
cannam@128
|
141 rm -f _match.s
|
cannam@128
|
142
|
cannam@128
|
143 example.o: test/example.c zlib.h zconf.h
|
cannam@128
|
144 $(CC) $(CFLAGS) -I. -c -o $@ test/example.c
|
cannam@128
|
145
|
cannam@128
|
146 minigzip.o: test/minigzip.c zlib.h zconf.h
|
cannam@128
|
147 $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
|
cannam@128
|
148
|
cannam@128
|
149 example64.o: test/example.c zlib.h zconf.h
|
cannam@128
|
150 $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c
|
cannam@128
|
151
|
cannam@128
|
152 minigzip64.o: test/minigzip.c zlib.h zconf.h
|
cannam@128
|
153 $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c
|
cannam@128
|
154
|
cannam@128
|
155 .SUFFIXES: .lo
|
cannam@128
|
156
|
cannam@128
|
157 .c.lo:
|
cannam@128
|
158 -@mkdir objs 2>/dev/null || test -d objs
|
cannam@128
|
159 $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
|
cannam@128
|
160 -@mv objs/$*.o $@
|
cannam@128
|
161
|
cannam@128
|
162 placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
|
cannam@128
|
163 $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
|
cannam@128
|
164 rm -f $(SHAREDLIB) $(SHAREDLIBM)
|
cannam@128
|
165 ln -s $@ $(SHAREDLIB)
|
cannam@128
|
166 ln -s $@ $(SHAREDLIBM)
|
cannam@128
|
167 -@rmdir objs
|
cannam@128
|
168
|
cannam@128
|
169 example$(EXE): example.o $(STATICLIB)
|
cannam@128
|
170 $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
|
cannam@128
|
171
|
cannam@128
|
172 minigzip$(EXE): minigzip.o $(STATICLIB)
|
cannam@128
|
173 $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
|
cannam@128
|
174
|
cannam@128
|
175 examplesh$(EXE): example.o $(SHAREDLIBV)
|
cannam@128
|
176 $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
|
cannam@128
|
177
|
cannam@128
|
178 minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
|
cannam@128
|
179 $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
|
cannam@128
|
180
|
cannam@128
|
181 example64$(EXE): example64.o $(STATICLIB)
|
cannam@128
|
182 $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
|
cannam@128
|
183
|
cannam@128
|
184 minigzip64$(EXE): minigzip64.o $(STATICLIB)
|
cannam@128
|
185 $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
|
cannam@128
|
186
|
cannam@128
|
187 install-libs: $(LIBS)
|
cannam@128
|
188 -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
|
cannam@128
|
189 -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
|
cannam@128
|
190 -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
|
cannam@128
|
191 -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
|
cannam@128
|
192 -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
|
cannam@128
|
193 cp $(STATICLIB) $(DESTDIR)$(libdir)
|
cannam@128
|
194 chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
|
cannam@128
|
195 -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
|
cannam@128
|
196 -@if test -n "$(SHAREDLIBV)"; then \
|
cannam@128
|
197 cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
|
cannam@128
|
198 echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
|
cannam@128
|
199 chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
|
cannam@128
|
200 echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
|
cannam@128
|
201 rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
|
cannam@128
|
202 ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
|
cannam@128
|
203 ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
|
cannam@128
|
204 ($(LDCONFIG) || true) >/dev/null 2>&1; \
|
cannam@128
|
205 fi
|
cannam@128
|
206 cp zlib.3 $(DESTDIR)$(man3dir)
|
cannam@128
|
207 chmod 644 $(DESTDIR)$(man3dir)/zlib.3
|
cannam@128
|
208 cp zlib.pc $(DESTDIR)$(pkgconfigdir)
|
cannam@128
|
209 chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
|
cannam@128
|
210 # The ranlib in install is needed on NeXTSTEP which checks file times
|
cannam@128
|
211 # ldconfig is for Linux
|
cannam@128
|
212
|
cannam@128
|
213 install: install-libs
|
cannam@128
|
214 -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
|
cannam@128
|
215 cp zlib.h zconf.h $(DESTDIR)$(includedir)
|
cannam@128
|
216 chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
|
cannam@128
|
217
|
cannam@128
|
218 uninstall:
|
cannam@128
|
219 cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h
|
cannam@128
|
220 cd $(DESTDIR)$(libdir) && rm -f libz.a; \
|
cannam@128
|
221 if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
|
cannam@128
|
222 rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
|
cannam@128
|
223 fi
|
cannam@128
|
224 cd $(DESTDIR)$(man3dir) && rm -f zlib.3
|
cannam@128
|
225 cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc
|
cannam@128
|
226
|
cannam@128
|
227 docs: zlib.3.pdf
|
cannam@128
|
228
|
cannam@128
|
229 zlib.3.pdf: zlib.3
|
cannam@128
|
230 groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
|
cannam@128
|
231
|
cannam@128
|
232 zconf.h.cmakein: zconf.h.in
|
cannam@128
|
233 -@ TEMPFILE=zconfh_$$; \
|
cannam@128
|
234 echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
|
cannam@128
|
235 sed -f $$TEMPFILE zconf.h.in > zconf.h.cmakein &&\
|
cannam@128
|
236 touch -r zconf.h.in zconf.h.cmakein &&\
|
cannam@128
|
237 rm $$TEMPFILE
|
cannam@128
|
238
|
cannam@128
|
239 zconf: zconf.h.in
|
cannam@128
|
240 cp -p zconf.h.in zconf.h
|
cannam@128
|
241
|
cannam@128
|
242 mostlyclean: clean
|
cannam@128
|
243 clean:
|
cannam@128
|
244 rm -f *.o *.lo *~ \
|
cannam@128
|
245 example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
|
cannam@128
|
246 example64$(EXE) minigzip64$(EXE) \
|
cannam@128
|
247 infcover \
|
cannam@128
|
248 libz.* foo.gz so_locations \
|
cannam@128
|
249 _match.s maketree contrib/infback9/*.o
|
cannam@128
|
250 rm -rf objs
|
cannam@128
|
251 rm -f *.gcda *.gcno *.gcov
|
cannam@128
|
252 rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
|
cannam@128
|
253
|
cannam@128
|
254 maintainer-clean: distclean
|
cannam@128
|
255 distclean: clean zconf zconf.h.cmakein docs
|
cannam@128
|
256 rm -f Makefile zlib.pc configure.log
|
cannam@128
|
257 -@rm -f .DS_Store
|
cannam@128
|
258 -@printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile
|
cannam@128
|
259 -@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
|
cannam@128
|
260 -@touch -r Makefile.in Makefile
|
cannam@128
|
261
|
cannam@128
|
262 tags:
|
cannam@128
|
263 etags *.[ch]
|
cannam@128
|
264
|
cannam@128
|
265 depend:
|
cannam@128
|
266 makedepend -- $(CFLAGS) -- *.[ch]
|
cannam@128
|
267
|
cannam@128
|
268 # DO NOT DELETE THIS LINE -- make depend depends on it.
|
cannam@128
|
269
|
cannam@128
|
270 adler32.o zutil.o: zutil.h zlib.h zconf.h
|
cannam@128
|
271 gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
|
cannam@128
|
272 compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
|
cannam@128
|
273 crc32.o: zutil.h zlib.h zconf.h crc32.h
|
cannam@128
|
274 deflate.o: deflate.h zutil.h zlib.h zconf.h
|
cannam@128
|
275 infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
|
cannam@128
|
276 inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
cannam@128
|
277 inftrees.o: zutil.h zlib.h zconf.h inftrees.h
|
cannam@128
|
278 trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
|
cannam@128
|
279
|
cannam@128
|
280 adler32.lo zutil.lo: zutil.h zlib.h zconf.h
|
cannam@128
|
281 gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
|
cannam@128
|
282 compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
|
cannam@128
|
283 crc32.lo: zutil.h zlib.h zconf.h crc32.h
|
cannam@128
|
284 deflate.lo: deflate.h zutil.h zlib.h zconf.h
|
cannam@128
|
285 infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
|
cannam@128
|
286 inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
cannam@128
|
287 inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
|
cannam@128
|
288 trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h
|