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

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

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

57 58 59
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 已提交
60

61 62 63
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 已提交
64

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

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

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

all: static shared
M
Mark Adler 已提交
74

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

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

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

check: test
M
Mark Adler 已提交
82

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

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

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

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

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

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

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

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

132 133 134 135 136 137 138 139
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 已提交
140

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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