]> git.lizzy.rs Git - zlib.git/blob - Makefile.in
Update zconf.h.cmakein on make distclean.
[zlib.git] / Makefile.in
1 # Makefile for zlib
2 # Copyright (C) 1995-2011 Jean-loup Gailly.
3 # For conditions of distribution and use, see copyright notice in zlib.h
4
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
9
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
19 CC=cc
20
21 CFLAGS=-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
27 SFLAGS=-O
28 LDFLAGS=
29 TEST_LDFLAGS=-L. libz.a
30 LDSHARED=$(CC)
31 CPP=$(CC) -E
32
33 STATICLIB=libz.a
34 SHAREDLIB=libz.so
35 SHAREDLIBV=libz.so.1.2.5.2
36 SHAREDLIBM=libz.so.1
37 LIBS=$(STATICLIB) $(SHAREDLIBV)
38
39 AR=ar rc
40 RANLIB=ranlib
41 LDCONFIG=ldconfig
42 LDSHAREDLIBC=-lc
43 TAR=tar
44 SHELL=/bin/sh
45 EXE=
46
47 prefix = /usr/local
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
55 tempfile := $(shell mktemp -u __XXXXXX)
56
57 OBJC = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
58         gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
59
60 PIC_OBJC = adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo \
61         gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo
62
63 # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
64 OBJA =
65 PIC_OBJA =
66
67 OBJS = $(OBJC) $(OBJA)
68
69 PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
70
71 all: static shared
72
73 static: example$(EXE) minigzip$(EXE)
74
75 shared: examplesh$(EXE) minigzipsh$(EXE)
76
77 all64: example64$(EXE) minigzip64$(EXE)
78
79 check: test
80
81 test: all teststatic testshared
82
83 teststatic: static
84         @if echo hello world | ./minigzip | ./minigzip -d && ./example; then \
85           echo '                *** zlib test OK ***'; \
86         else \
87           echo '                *** zlib test FAILED ***'; false; \
88         fi
89         -@rm -f foo.gz
90
91 testshared: shared
92         @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
93         LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
94         DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
95         SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
96         if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh; then \
97           echo '                *** zlib shared test OK ***'; \
98         else \
99           echo '                *** zlib shared test FAILED ***'; false; \
100         fi
101         -@rm -f foo.gz
102
103 test64: all64
104         @if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64; then \
105           echo '                *** zlib 64-bit test OK ***'; \
106         else \
107           echo '                *** zlib 64-bit test FAILED ***'; false; \
108         fi
109         -@rm -f foo.gz
110
111 libz.a: $(OBJS)
112         $(AR) $@ $(OBJS)
113         -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
114
115 match.o: match.S
116         $(CPP) match.S > _match.s
117         $(CC) -c _match.s
118         mv _match.o match.o
119         rm -f _match.s
120
121 match.lo: match.S
122         $(CPP) match.S > _match.s
123         $(CC) -c -fPIC _match.s
124         mv _match.o match.lo
125         rm -f _match.s
126
127 example64.o: example.c zlib.h zconf.h
128         $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ example.c
129
130 minigzip64.o: minigzip.c zlib.h zconf.h
131         $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ minigzip.c
132
133 .SUFFIXES: .lo
134
135 .c.lo:
136         -@mkdir objs 2>/dev/null || test -d objs
137         $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
138         -@mv objs/$*.o $@
139
140 placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
141         $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
142         rm -f $(SHAREDLIB) $(SHAREDLIBM)
143         ln -s $@ $(SHAREDLIB)
144         ln -s $@ $(SHAREDLIBM)
145         -@rmdir objs
146
147 example$(EXE): example.o $(STATICLIB)
148         $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
149
150 minigzip$(EXE): minigzip.o $(STATICLIB)
151         $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
152
153 examplesh$(EXE): example.o $(SHAREDLIBV)
154         $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
155
156 minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
157         $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
158
159 example64$(EXE): example64.o $(STATICLIB)
160         $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
161
162 minigzip64$(EXE): minigzip64.o $(STATICLIB)
163         $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
164
165 install-libs: $(LIBS)
166         -@if [ ! -d $(DESTDIR)$(exec_prefix)  ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
167         -@if [ ! -d $(DESTDIR)$(libdir)       ]; then mkdir -p $(DESTDIR)$(libdir); fi
168         -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
169         -@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
170         -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
171         cp $(STATICLIB) $(DESTDIR)$(libdir)
172         chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
173         -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
174         -@if test -n "$(SHAREDLIBV)"; then \
175           cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
176           echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
177           chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
178           echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
179           rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
180           ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
181           ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
182           ($(LDCONFIG) || true)  >/dev/null 2>&1; \
183         fi
184         cp zlib.3 $(DESTDIR)$(man3dir)
185         chmod 644 $(DESTDIR)$(man3dir)/zlib.3
186         cp zlib.pc $(DESTDIR)$(pkgconfigdir)
187         chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
188 # The ranlib in install is needed on NeXTSTEP which checks file times
189 # ldconfig is for Linux
190
191 install: install-libs
192         -@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
193         cp zlib.h zconf.h $(DESTDIR)$(includedir)
194         chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
195
196 uninstall:
197         cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
198         cd $(DESTDIR)$(libdir); rm -f libz.a; \
199         if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
200           rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
201         fi
202         cd $(DESTDIR)$(man3dir); rm -f zlib.3
203         cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
204
205 docs: zlib.3.pdf
206
207 zlib.3.pdf: zlib.3
208         groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
209
210 zconf.h.cmakein: zconf.h.in
211         -@echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" > $(tempfile)
212         -@sed -f $(tempfile) zconf.h.in > zconf.h.cmakein
213         -@touch -r zconf.h.in zconf.h.cmakein
214         -@rm $(tempfile)
215
216 zconf: zconf.h.in
217         cp -p zconf.h.in zconf.h
218
219 mostlyclean: clean
220 clean:
221         rm -f *.o *.lo *~ \
222            example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
223            example64$(EXE) minigzip64$(EXE) \
224            libz.* foo.gz so_locations \
225            _match.s maketree contrib/infback9/*.o
226         rm -rf objs
227
228 maintainer-clean: distclean
229 distclean: clean zconf zconf.h.cmakein docs
230         rm -f Makefile zlib.pc
231         -@rm -f .DS_Store
232         -@printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile
233         -@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
234         -@touch -r Makefile.in Makefile
235
236 tags:
237         etags *.[ch]
238
239 depend:
240         makedepend -- $(CFLAGS) -- *.[ch]
241
242 # DO NOT DELETE THIS LINE -- make depend depends on it.
243
244 adler32.o zutil.o: zutil.h zlib.h zconf.h
245 gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
246 compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
247 crc32.o: zutil.h zlib.h zconf.h crc32.h
248 deflate.o: deflate.h zutil.h zlib.h zconf.h
249 infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
250 inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
251 inftrees.o: zutil.h zlib.h zconf.h inftrees.h
252 trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
253
254 adler32.lo zutil.lo: zutil.h zlib.h zconf.h
255 gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
256 compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
257 crc32.lo: zutil.h zlib.h zconf.h crc32.h
258 deflate.lo: deflate.h zutil.h zlib.h zconf.h
259 infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
260 inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
261 inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
262 trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h