blob: c61aa3008d441fa55f755e7df600d640ef6135b6 [file] [log] [blame]
Martin v. Löwisd372aa82006-01-03 06:44:59 +00001# Makefile for zlib
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +02002# Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler
Martin v. Löwisd372aa82006-01-03 06:44:59 +00003# For conditions of distribution and use, see copyright notice in zlib.h
4
5# To compile and test, type:
6# ./configure; make test
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +02007# Normally configure builds both a static and a shared library.
8# If you want to build just a static library, use: ./configure --static
Martin v. Löwisd372aa82006-01-03 06:44:59 +00009
10# To use the asm code, type:
11# cp contrib/asm?86/match.S ./match.S
12# make LOC=-DASMV OBJA=match.o
13
14# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
15# make install
16# To install in $HOME instead of /usr/local, use:
17# make install prefix=$HOME
18
19CC=cc
20
21CFLAGS=-O
22#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
23#CFLAGS=-g -DDEBUG
24#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
25# -Wstrict-prototypes -Wmissing-prototypes
26
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020027SFLAGS=-O
28LDFLAGS=
29TEST_LDFLAGS=-L. libz.a
Martin v. Löwisd372aa82006-01-03 06:44:59 +000030LDSHARED=$(CC)
31CPP=$(CC) -E
32
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020033STATICLIB=libz.a
Martin v. Löwisd372aa82006-01-03 06:44:59 +000034SHAREDLIB=libz.so
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020035SHAREDLIBV=libz.so.1.2.8
Martin v. Löwisd372aa82006-01-03 06:44:59 +000036SHAREDLIBM=libz.so.1
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020037LIBS=$(STATICLIB) $(SHAREDLIBV)
Martin v. Löwisd372aa82006-01-03 06:44:59 +000038
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020039AR=ar
40ARFLAGS=rc
Martin v. Löwisd372aa82006-01-03 06:44:59 +000041RANLIB=ranlib
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020042LDCONFIG=ldconfig
43LDSHAREDLIBC=-lc
Martin v. Löwisd372aa82006-01-03 06:44:59 +000044TAR=tar
45SHELL=/bin/sh
46EXE=
47
48prefix = /usr/local
49exec_prefix = ${prefix}
50libdir = ${exec_prefix}/lib
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020051sharedlibdir = ${libdir}
Martin v. Löwisd372aa82006-01-03 06:44:59 +000052includedir = ${prefix}/include
53mandir = ${prefix}/share/man
54man3dir = ${mandir}/man3
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020055pkgconfigdir = ${libdir}/pkgconfig
Martin v. Löwisd372aa82006-01-03 06:44:59 +000056
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020057OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
58OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
59OBJC = $(OBJZ) $(OBJG)
Martin v. Löwisd372aa82006-01-03 06:44:59 +000060
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020061PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
62PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
63PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
64
65# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
Martin v. Löwisd372aa82006-01-03 06:44:59 +000066OBJA =
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020067PIC_OBJA =
Martin v. Löwisd372aa82006-01-03 06:44:59 +000068
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020069OBJS = $(OBJC) $(OBJA)
Martin v. Löwisd372aa82006-01-03 06:44:59 +000070
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020071PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
72
73all: static shared
74
75static: example$(EXE) minigzip$(EXE)
76
77shared: examplesh$(EXE) minigzipsh$(EXE)
78
79all64: example64$(EXE) minigzip64$(EXE)
Martin v. Löwisd372aa82006-01-03 06:44:59 +000080
81check: test
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020082
83test: all teststatic testshared
84
85teststatic: static
86 @TMPST=tmpst_$$; \
87 if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \
Martin v. Löwisd372aa82006-01-03 06:44:59 +000088 echo ' *** zlib test OK ***'; \
89 else \
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020090 echo ' *** zlib test FAILED ***'; false; \
91 fi; \
92 rm -f $$TMPST
Martin v. Löwisd372aa82006-01-03 06:44:59 +000093
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +020094testshared: shared
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 TMPSH=tmpsh_$$; \
100 if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \
101 echo ' *** zlib shared test OK ***'; \
102 else \
103 echo ' *** zlib shared test FAILED ***'; false; \
104 fi; \
105 rm -f $$TMPSH
106
107test64: all64
108 @TMP64=tmp64_$$; \
109 if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \
110 echo ' *** zlib 64-bit test OK ***'; \
111 else \
112 echo ' *** zlib 64-bit test FAILED ***'; false; \
113 fi; \
114 rm -f $$TMP64
115
116infcover.o: test/infcover.c zlib.h zconf.h
117 $(CC) $(CFLAGS) -I. -c -o $@ test/infcover.c
118
119infcover: infcover.o libz.a
120 $(CC) $(CFLAGS) -o $@ infcover.o libz.a
121
122cover: infcover
123 rm -f *.gcda
124 ./infcover
125 gcov inf*.c
126
127libz.a: $(OBJS)
128 $(AR) $(ARFLAGS) $@ $(OBJS)
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000129 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
130
131match.o: match.S
132 $(CPP) match.S > _match.s
133 $(CC) -c _match.s
134 mv _match.o match.o
135 rm -f _match.s
136
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200137match.lo: match.S
138 $(CPP) match.S > _match.s
139 $(CC) -c -fPIC _match.s
140 mv _match.o match.lo
141 rm -f _match.s
142
143example.o: test/example.c zlib.h zconf.h
144 $(CC) $(CFLAGS) -I. -c -o $@ test/example.c
145
146minigzip.o: test/minigzip.c zlib.h zconf.h
147 $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
148
149example64.o: test/example.c zlib.h zconf.h
150 $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c
151
152minigzip64.o: test/minigzip.c zlib.h zconf.h
153 $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c
154
155.SUFFIXES: .lo
156
157.c.lo:
158 -@mkdir objs 2>/dev/null || test -d objs
159 $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
160 -@mv objs/$*.o $@
161
162placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
163 $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000164 rm -f $(SHAREDLIB) $(SHAREDLIBM)
165 ln -s $@ $(SHAREDLIB)
166 ln -s $@ $(SHAREDLIBM)
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200167 -@rmdir objs
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000168
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200169example$(EXE): example.o $(STATICLIB)
170 $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000171
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200172minigzip$(EXE): minigzip.o $(STATICLIB)
173 $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000174
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200175examplesh$(EXE): example.o $(SHAREDLIBV)
176 $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
177
178minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
179 $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
180
181example64$(EXE): example64.o $(STATICLIB)
182 $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
183
184minigzip64$(EXE): minigzip64.o $(STATICLIB)
185 $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
186
187install-libs: $(LIBS)
188 -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
189 -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
190 -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
191 -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
192 -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
193 cp $(STATICLIB) $(DESTDIR)$(libdir)
194 chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
195 -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
196 -@if test -n "$(SHAREDLIBV)"; then \
197 cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
198 echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
199 chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
200 echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
201 rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
202 ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
203 ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
204 ($(LDCONFIG) || true) >/dev/null 2>&1; \
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000205 fi
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200206 cp zlib.3 $(DESTDIR)$(man3dir)
207 chmod 644 $(DESTDIR)$(man3dir)/zlib.3
208 cp zlib.pc $(DESTDIR)$(pkgconfigdir)
209 chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000210# The ranlib in install is needed on NeXTSTEP which checks file times
211# ldconfig is for Linux
212
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200213install: install-libs
214 -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
215 cp zlib.h zconf.h $(DESTDIR)$(includedir)
216 chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
217
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000218uninstall:
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200219 cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h
220 cd $(DESTDIR)$(libdir) && rm -f libz.a; \
221 if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000222 rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
223 fi
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200224 cd $(DESTDIR)$(man3dir) && rm -f zlib.3
225 cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc
226
227docs: zlib.3.pdf
228
229zlib.3.pdf: zlib.3
230 groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
231
232zconf.h.cmakein: zconf.h.in
233 -@ TEMPFILE=zconfh_$$; \
234 echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
235 sed -f $$TEMPFILE zconf.h.in > zconf.h.cmakein &&\
236 touch -r zconf.h.in zconf.h.cmakein &&\
237 rm $$TEMPFILE
238
239zconf: zconf.h.in
240 cp -p zconf.h.in zconf.h
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000241
242mostlyclean: clean
243clean:
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200244 rm -f *.o *.lo *~ \
245 example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
246 example64$(EXE) minigzip64$(EXE) \
247 infcover \
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000248 libz.* foo.gz so_locations \
249 _match.s maketree contrib/infback9/*.o
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200250 rm -rf objs
251 rm -f *.gcda *.gcno *.gcov
252 rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000253
254maintainer-clean: distclean
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200255distclean: clean zconf zconf.h.cmakein docs
256 rm -f Makefile zlib.pc configure.log
257 -@rm -f .DS_Store
258 -@printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile
259 -@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
260 -@touch -r Makefile.in Makefile
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000261
262tags:
263 etags *.[ch]
264
265depend:
266 makedepend -- $(CFLAGS) -- *.[ch]
267
268# DO NOT DELETE THIS LINE -- make depend depends on it.
269
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200270adler32.o zutil.o: zutil.h zlib.h zconf.h
271gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
272compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
273crc32.o: zutil.h zlib.h zconf.h crc32.h
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000274deflate.o: deflate.h zutil.h zlib.h zconf.h
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200275infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000276inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000277inftrees.o: zutil.h zlib.h zconf.h inftrees.h
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000278trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
doko@ubuntu.com77a64bf2014-09-11 08:32:46 +0200279
280adler32.lo zutil.lo: zutil.h zlib.h zconf.h
281gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
282compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
283crc32.lo: zutil.h zlib.h zconf.h crc32.h
284deflate.lo: deflate.h zutil.h zlib.h zconf.h
285infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
286inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
287inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
288trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h