Makefile.in 8.7 KB
Newer Older
M
Mark Adler 已提交
1
# Makefile for zlib
M
Mark Adler 已提交
2
# Copyright (C) 1995-2011 Jean-loup Gailly.
M
Mark Adler 已提交
3
# For conditions of distribution and use, see copyright notice in zlib.h
M
Mark Adler 已提交
4 5

# To compile and test, type:
M
Mark Adler 已提交
6
#    ./configure; make test
M
Mark Adler 已提交
7 8
# Normally configure builds both a static and a shared library.
# If you want to build just a static library, use: ./configure --static
M
Mark Adler 已提交
9

M
Mark Adler 已提交
10 11 12 13
# To use the asm code, type:
#    cp contrib/asm?86/match.S ./match.S
#    make LOC=-DASMV OBJA=match.o

M
Mark Adler 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
#    make install
# To install in $HOME instead of /usr/local, use:
#    make install prefix=$HOME

CC=cc

CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
#           -Wstrict-prototypes -Wmissing-prototypes

M
Mark Adler 已提交
27
SFLAGS=-O
M
Mark Adler 已提交
28
LDFLAGS=
M
Mark Adler 已提交
29
TEST_LDFLAGS=-L. libz.a
M
Mark Adler 已提交
30
LDSHARED=$(CC)
M
Mark Adler 已提交
31
CPP=$(CC) -E
M
Mark Adler 已提交
32

M
Mark Adler 已提交
33
STATICLIB=libz.a
M
Mark Adler 已提交
34
SHAREDLIB=libz.so
M
Mark Adler 已提交
35
SHAREDLIBV=libz.so.1.2.7
M
Mark Adler 已提交
36
SHAREDLIBM=libz.so.1
M
Mark Adler 已提交
37
LIBS=$(STATICLIB) $(SHAREDLIBV)
M
Mark Adler 已提交
38

39 40
AR=ar
ARFLAGS=rc
M
Mark Adler 已提交
41
RANLIB=ranlib
M
Mark Adler 已提交
42 43
LDCONFIG=ldconfig
LDSHAREDLIBC=-lc
M
Mark Adler 已提交
44
TAR=tar
M
Mark Adler 已提交
45
SHELL=/bin/sh
M
Mark Adler 已提交
46
EXE=
M
Mark Adler 已提交
47

M
Mark Adler 已提交
48 49
prefix = /usr/local
exec_prefix = ${prefix}
M
Mark Adler 已提交
50
libdir = ${exec_prefix}/lib
M
Mark Adler 已提交
51
sharedlibdir = ${libdir}
M
Mark Adler 已提交
52
includedir = ${prefix}/include
M
Mark Adler 已提交
53 54
mandir = ${prefix}/share/man
man3dir = ${mandir}/man3
M
Mark Adler 已提交
55
pkgconfigdir = ${libdir}/pkgconfig
56
tempfile := $(shell mktemp -u __XXXXXX)
M
Mark Adler 已提交
57

58 59 60
OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)
M
Mark Adler 已提交
61

62 63 64
PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
M
Mark Adler 已提交
65

M
Mark Adler 已提交
66 67 68
# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
OBJA =
PIC_OBJA =
M
Mark Adler 已提交
69

M
Mark Adler 已提交
70
OBJS = $(OBJC) $(OBJA)
M
Mark Adler 已提交
71

M
Mark Adler 已提交
72
PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
M
Mark Adler 已提交
73 74

all: static shared
M
Mark Adler 已提交
75

M
Mark Adler 已提交
76
static: example$(EXE) minigzip$(EXE)
M
Mark Adler 已提交
77

M
Mark Adler 已提交
78
shared: examplesh$(EXE) minigzipsh$(EXE)
M
Mark Adler 已提交
79

M
Mark Adler 已提交
80 81 82
all64: example64$(EXE) minigzip64$(EXE)

check: test
M
Mark Adler 已提交
83

M
Mark Adler 已提交
84
test: all teststatic testshared
M
Mark Adler 已提交
85

M
Mark Adler 已提交
86
teststatic: static
M
Mark Adler 已提交
87
	@if echo hello world | ./minigzip | ./minigzip -d && ./example; then \
M
Mark Adler 已提交
88 89
	  echo '		*** zlib test OK ***'; \
	else \
M
Mark Adler 已提交
90
	  echo '		*** zlib test FAILED ***'; false; \
M
Mark Adler 已提交
91
	fi
M
Mark Adler 已提交
92
	-@rm -f foo.gz
M
Mark Adler 已提交
93

M
Mark Adler 已提交
94
testshared: shared
M
Mark Adler 已提交
95
	@LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
M
Mark Adler 已提交
96
	LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
M
Mark Adler 已提交
97 98
	DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
	SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
M
Mark Adler 已提交
99
	if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh; then \
M
Mark Adler 已提交
100 101
	  echo '		*** zlib shared test OK ***'; \
	else \
M
Mark Adler 已提交
102
	  echo '		*** zlib shared test FAILED ***'; false; \
M
Mark Adler 已提交
103
	fi
M
Mark Adler 已提交
104
	-@rm -f foo.gz
M
Mark Adler 已提交
105

M
Mark Adler 已提交
106
test64: all64
M
Mark Adler 已提交
107
	@if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64; then \
M
Mark Adler 已提交
108 109
	  echo '		*** zlib 64-bit test OK ***'; \
	else \
M
Mark Adler 已提交
110
	  echo '		*** zlib 64-bit test FAILED ***'; false; \
M
Mark Adler 已提交
111
	fi
M
Mark Adler 已提交
112
	-@rm -f foo.gz
M
Mark Adler 已提交
113

114 115 116 117 118 119 120 121 122 123 124
infcover.o: test/infcover.c zlib.h zconf.h
	$(CC) $(CFLAGS) -I. -c -o $@ test/infcover.c

infcover: infcover.o libz.a
	$(CC) $(CFLAGS) -o $@ infcover.o libz.a

cover: infcover
	rm -f *.gcda
	./infcover
	gcov inf*.c

M
Mark Adler 已提交
125
libz.a: $(OBJS)
126
	$(AR) $(ARFLAGS) $@ $(OBJS)
M
Mark Adler 已提交
127
	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
M
Mark Adler 已提交
128

M
Mark Adler 已提交
129
match.o: match.S
M
Mark Adler 已提交
130
	$(CPP) match.S > _match.s
M
Mark Adler 已提交
131 132
	$(CC) -c _match.s
	mv _match.o match.o
M
Mark Adler 已提交
133 134
	rm -f _match.s

M
Mark Adler 已提交
135
match.lo: match.S
M
Mark Adler 已提交
136
	$(CPP) match.S > _match.s
M
Mark Adler 已提交
137 138
	$(CC) -c -fPIC _match.s
	mv _match.o match.lo
M
Mark Adler 已提交
139 140
	rm -f _match.s

141 142
example.o: test/example.c zlib.h zconf.h
	$(CC) $(CFLAGS) -I. -c -o $@ test/example.c
M
Mark Adler 已提交
143

144 145
minigzip.o: test/minigzip.c zlib.h zconf.h
	$(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
146

147 148
example64.o: test/example.c zlib.h zconf.h
	$(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c
149

150 151
minigzip64.o: test/minigzip.c zlib.h zconf.h
	$(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c
M
Mark Adler 已提交
152

M
Mark Adler 已提交
153
.SUFFIXES: .lo
M
Mark Adler 已提交
154

M
Mark Adler 已提交
155
.c.lo:
M
Mark Adler 已提交
156
	-@mkdir objs 2>/dev/null || test -d objs
M
Mark Adler 已提交
157 158
	$(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
	-@mv objs/$*.o $@
M
Mark Adler 已提交
159

M
Mark Adler 已提交
160
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
M
Mark Adler 已提交
161
	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
M
Mark Adler 已提交
162
	rm -f $(SHAREDLIB) $(SHAREDLIBM)
M
Mark Adler 已提交
163
	ln -s $@ $(SHAREDLIB)
M
Mark Adler 已提交
164
	ln -s $@ $(SHAREDLIBM)
M
Mark Adler 已提交
165
	-@rmdir objs
M
Mark Adler 已提交
166

M
Mark Adler 已提交
167
example$(EXE): example.o $(STATICLIB)
M
Mark Adler 已提交
168
	$(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
M
Mark Adler 已提交
169

M
Mark Adler 已提交
170
minigzip$(EXE): minigzip.o $(STATICLIB)
M
Mark Adler 已提交
171
	$(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
M
Mark Adler 已提交
172

M
Mark Adler 已提交
173 174
examplesh$(EXE): example.o $(SHAREDLIBV)
	$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
M
Mark Adler 已提交
175

M
Mark Adler 已提交
176 177
minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
	$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
M
Mark Adler 已提交
178

M
Mark Adler 已提交
179
example64$(EXE): example64.o $(STATICLIB)
M
Mark Adler 已提交
180
	$(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
M
Mark Adler 已提交
181

M
Mark Adler 已提交
182
minigzip64$(EXE): minigzip64.o $(STATICLIB)
M
Mark Adler 已提交
183
	$(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
M
Mark Adler 已提交
184

M
Mark Adler 已提交
185
install-libs: $(LIBS)
M
Mark Adler 已提交
186 187
	-@if [ ! -d $(DESTDIR)$(exec_prefix)  ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
	-@if [ ! -d $(DESTDIR)$(libdir)       ]; then mkdir -p $(DESTDIR)$(libdir); fi
M
Mark Adler 已提交
188
	-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
M
Mark Adler 已提交
189 190
	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
M
Mark Adler 已提交
191
	cp $(STATICLIB) $(DESTDIR)$(libdir)
M
Mark Adler 已提交
192 193 194 195 196 197 198 199
	chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
	-@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
	-@if test -n "$(SHAREDLIBV)"; then \
	  cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
	  echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
	  chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
	  echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
	  rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
200 201
	  ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
	  ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
M
Mark Adler 已提交
202
	  ($(LDCONFIG) || true)  >/dev/null 2>&1; \
M
Mark Adler 已提交
203
	fi
M
Mark Adler 已提交
204 205 206 207
	cp zlib.3 $(DESTDIR)$(man3dir)
	chmod 644 $(DESTDIR)$(man3dir)/zlib.3
	cp zlib.pc $(DESTDIR)$(pkgconfigdir)
	chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
M
Mark Adler 已提交
208
# The ranlib in install is needed on NeXTSTEP which checks file times
M
Mark Adler 已提交
209
# ldconfig is for Linux
M
Mark Adler 已提交
210

M
Mark Adler 已提交
211 212
install: install-libs
	-@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
M
Mark Adler 已提交
213 214
	cp zlib.h zconf.h $(DESTDIR)$(includedir)
	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
M
Mark Adler 已提交
215

M
Mark Adler 已提交
216
uninstall:
M
Mark Adler 已提交
217
	cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
M
Mark Adler 已提交
218
	cd $(DESTDIR)$(libdir); rm -f libz.a; \
M
Mark Adler 已提交
219
	if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
M
Mark Adler 已提交
220
	  rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
M
Mark Adler 已提交
221
	fi
M
Mark Adler 已提交
222 223
	cd $(DESTDIR)$(man3dir); rm -f zlib.3
	cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
M
Mark Adler 已提交
224

M
Mark Adler 已提交
225 226 227 228 229
docs: zlib.3.pdf

zlib.3.pdf: zlib.3
	groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf

230 231 232 233 234
zconf.h.cmakein: zconf.h.in
	-@echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" > $(tempfile)
	-@sed -f $(tempfile) zconf.h.in > zconf.h.cmakein
	-@touch -r zconf.h.in zconf.h.cmakein
	-@rm $(tempfile)
M
Mark Adler 已提交
235 236 237 238

zconf: zconf.h.in
	cp -p zconf.h.in zconf.h

M
Mark Adler 已提交
239
mostlyclean: clean
M
Mark Adler 已提交
240
clean:
M
Mark Adler 已提交
241
	rm -f *.o *.lo *~ \
M
Mark Adler 已提交
242
	   example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
M
Mark Adler 已提交
243
	   example64$(EXE) minigzip64$(EXE) \
244
	   infcover \
M
Mark Adler 已提交
245
	   libz.* foo.gz so_locations \
M
Mark Adler 已提交
246
	   _match.s maketree contrib/infback9/*.o
M
Mark Adler 已提交
247
	rm -rf objs
248
	rm -f *.gcda *.gcno *.gcov
249
	rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
M
Mark Adler 已提交
250

M
Mark Adler 已提交
251
maintainer-clean: distclean
252
distclean: clean zconf zconf.h.cmakein docs
253
	rm -f Makefile zlib.pc configure.log
M
Mark Adler 已提交
254
	-@rm -f .DS_Store
M
Mark Adler 已提交
255
	-@printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile
M
Mark Adler 已提交
256
	-@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
M
Mark Adler 已提交
257
	-@touch -r Makefile.in Makefile
M
Mark Adler 已提交
258

M
Mark Adler 已提交
259
tags:
M
Mark Adler 已提交
260 261 262 263 264 265 266
	etags *.[ch]

depend:
	makedepend -- $(CFLAGS) -- *.[ch]

# DO NOT DELETE THIS LINE -- make depend depends on it.

M
Mark Adler 已提交
267
adler32.o zutil.o: zutil.h zlib.h zconf.h
M
Mark Adler 已提交
268 269 270 271 272 273 274 275
gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
crc32.o: zutil.h zlib.h zconf.h crc32.h
deflate.o: deflate.h zutil.h zlib.h zconf.h
infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
M
Mark Adler 已提交
276

M
Mark Adler 已提交
277
adler32.lo zutil.lo: zutil.h zlib.h zconf.h
M
Mark Adler 已提交
278 279 280 281 282 283 284 285
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
crc32.lo: zutil.h zlib.h zconf.h crc32.h
deflate.lo: deflate.h zutil.h zlib.h zconf.h
infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h