Makefile.in 8.4 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
35
SHAREDLIBV=libz.so.1.2.5.2
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

M
Mark Adler 已提交
114
libz.a: $(OBJS)
115
	$(AR) $(ARFLAGS) $@ $(OBJS)
M
Mark Adler 已提交
116
	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
M
Mark Adler 已提交
117

M
Mark Adler 已提交
118
match.o: match.S
M
Mark Adler 已提交
119
	$(CPP) match.S > _match.s
M
Mark Adler 已提交
120 121
	$(CC) -c _match.s
	mv _match.o match.o
M
Mark Adler 已提交
122 123
	rm -f _match.s

M
Mark Adler 已提交
124
match.lo: match.S
M
Mark Adler 已提交
125
	$(CPP) match.S > _match.s
M
Mark Adler 已提交
126 127
	$(CC) -c -fPIC _match.s
	mv _match.o match.lo
M
Mark Adler 已提交
128 129
	rm -f _match.s

130 131
example.o: examples/example.c zlib.h zconf.h
	$(CC) $(CFLAGS) -I. -c -o $@ examples/example.c
M
Mark Adler 已提交
132

133 134 135 136 137 138 139 140
minigzip.o: examples/minigzip.c zlib.h zconf.h
	$(CC) $(CFLAGS) -I. -c -o $@ examples/minigzip.c

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

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

M
Mark Adler 已提交
142
.SUFFIXES: .lo
M
Mark Adler 已提交
143

M
Mark Adler 已提交
144
.c.lo:
M
Mark Adler 已提交
145
	-@mkdir objs 2>/dev/null || test -d objs
M
Mark Adler 已提交
146 147
	$(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
	-@mv objs/$*.o $@
M
Mark Adler 已提交
148

M
Mark Adler 已提交
149
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
M
Mark Adler 已提交
150
	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
M
Mark Adler 已提交
151
	rm -f $(SHAREDLIB) $(SHAREDLIBM)
M
Mark Adler 已提交
152
	ln -s $@ $(SHAREDLIB)
M
Mark Adler 已提交
153
	ln -s $@ $(SHAREDLIBM)
M
Mark Adler 已提交
154
	-@rmdir objs
M
Mark Adler 已提交
155

M
Mark Adler 已提交
156
example$(EXE): example.o $(STATICLIB)
M
Mark Adler 已提交
157
	$(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
M
Mark Adler 已提交
158

M
Mark Adler 已提交
159
minigzip$(EXE): minigzip.o $(STATICLIB)
M
Mark Adler 已提交
160
	$(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
M
Mark Adler 已提交
161

M
Mark Adler 已提交
162 163
examplesh$(EXE): example.o $(SHAREDLIBV)
	$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
M
Mark Adler 已提交
164

M
Mark Adler 已提交
165 166
minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
	$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
M
Mark Adler 已提交
167

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

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

M
Mark Adler 已提交
174
install-libs: $(LIBS)
M
Mark Adler 已提交
175 176
	-@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 已提交
177
	-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
M
Mark Adler 已提交
178 179
	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
M
Mark Adler 已提交
180
	cp $(STATICLIB) $(DESTDIR)$(libdir)
M
Mark Adler 已提交
181 182 183 184 185 186 187 188
	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); \
189 190
	  ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
	  ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
M
Mark Adler 已提交
191
	  ($(LDCONFIG) || true)  >/dev/null 2>&1; \
M
Mark Adler 已提交
192
	fi
M
Mark Adler 已提交
193 194 195 196
	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 已提交
197
# The ranlib in install is needed on NeXTSTEP which checks file times
M
Mark Adler 已提交
198
# ldconfig is for Linux
M
Mark Adler 已提交
199

M
Mark Adler 已提交
200 201
install: install-libs
	-@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
M
Mark Adler 已提交
202 203
	cp zlib.h zconf.h $(DESTDIR)$(includedir)
	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
M
Mark Adler 已提交
204

M
Mark Adler 已提交
205
uninstall:
M
Mark Adler 已提交
206
	cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
M
Mark Adler 已提交
207
	cd $(DESTDIR)$(libdir); rm -f libz.a; \
M
Mark Adler 已提交
208
	if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
M
Mark Adler 已提交
209
	  rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
M
Mark Adler 已提交
210
	fi
M
Mark Adler 已提交
211 212
	cd $(DESTDIR)$(man3dir); rm -f zlib.3
	cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
M
Mark Adler 已提交
213

M
Mark Adler 已提交
214 215 216 217 218
docs: zlib.3.pdf

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

219 220 221 222 223
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 已提交
224 225 226 227

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

M
Mark Adler 已提交
228
mostlyclean: clean
M
Mark Adler 已提交
229
clean:
M
Mark Adler 已提交
230
	rm -f *.o *.lo *~ \
M
Mark Adler 已提交
231
	   example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
M
Mark Adler 已提交
232
	   example64$(EXE) minigzip64$(EXE) \
M
Mark Adler 已提交
233
	   libz.* foo.gz so_locations \
M
Mark Adler 已提交
234
	   _match.s maketree contrib/infback9/*.o
M
Mark Adler 已提交
235
	rm -rf objs
236
	rm -f *.gcda *.gcno *.gcov
M
Mark Adler 已提交
237

M
Mark Adler 已提交
238
maintainer-clean: distclean
239
distclean: clean zconf zconf.h.cmakein docs
M
Mark Adler 已提交
240
	rm -f Makefile zlib.pc
M
Mark Adler 已提交
241
	-@rm -f .DS_Store
M
Mark Adler 已提交
242
	-@printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile
M
Mark Adler 已提交
243
	-@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
M
Mark Adler 已提交
244
	-@touch -r Makefile.in Makefile
M
Mark Adler 已提交
245

M
Mark Adler 已提交
246
tags:
M
Mark Adler 已提交
247 248 249 250 251 252 253
	etags *.[ch]

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

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

M
Mark Adler 已提交
254
adler32.o zutil.o: zutil.h zlib.h zconf.h
M
Mark Adler 已提交
255 256 257 258 259 260 261 262
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 已提交
263

M
Mark Adler 已提交
264
adler32.lo zutil.lo: zutil.h zlib.h zconf.h
M
Mark Adler 已提交
265 266 267 268 269 270 271 272
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