Makefile.in 7.5 KB
Newer Older
M
Mark Adler 已提交
1
# Makefile for zlib
M
Mark Adler 已提交
2
# Copyright (C) 1995-2010 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 28
SFLAGS=-O

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.4.3
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 50
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
M
Mark Adler 已提交
51 52
mandir = ${prefix}/share/man
man3dir = ${mandir}/man3
M
Mark Adler 已提交
53
pkgconfigdir = ${libdir}/pkgconfig
M
Mark Adler 已提交
54

M
Mark Adler 已提交
55
OBJC = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
M
Mark Adler 已提交
56
	gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
M
Mark Adler 已提交
57

M
Mark Adler 已提交
58
PIC_OBJC = adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo \
M
Mark Adler 已提交
59
	gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo
M
Mark Adler 已提交
60

M
Mark Adler 已提交
61 62 63
# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
OBJA =
PIC_OBJA =
M
Mark Adler 已提交
64

M
Mark Adler 已提交
65
OBJS = $(OBJC) $(OBJA)
M
Mark Adler 已提交
66

M
Mark Adler 已提交
67
PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
M
Mark Adler 已提交
68 69

all: static shared
M
Mark Adler 已提交
70

M
Mark Adler 已提交
71
static: example$(EXE) minigzip$(EXE)
M
Mark Adler 已提交
72

M
Mark Adler 已提交
73
shared: examplesh$(EXE) minigzipsh$(EXE)
M
Mark Adler 已提交
74

M
Mark Adler 已提交
75 76 77
all64: example64$(EXE) minigzip64$(EXE)

check: test
M
Mark Adler 已提交
78

M
Mark Adler 已提交
79
test: all teststatic testshared
M
Mark Adler 已提交
80

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

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

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

M
Mark Adler 已提交
109 110
libz.a: $(OBJS)
	$(AR) $@ $(OBJS)
M
Mark Adler 已提交
111
	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
M
Mark Adler 已提交
112

M
Mark Adler 已提交
113
match.o: match.S
M
Mark Adler 已提交
114
	$(CPP) match.S > _match.s
M
Mark Adler 已提交
115 116
	$(CC) -c _match.s
	mv _match.o match.o
M
Mark Adler 已提交
117 118
	rm -f _match.s

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

M
Mark Adler 已提交
125
example64.o: example.c zlib.h zconf.h
M
Mark Adler 已提交
126
	$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ example.c
M
Mark Adler 已提交
127

M
Mark Adler 已提交
128
minigzip64.o: minigzip.c zlib.h zconf.h
M
Mark Adler 已提交
129
	$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ minigzip.c
M
Mark Adler 已提交
130

M
Mark Adler 已提交
131
.SUFFIXES: .lo
M
Mark Adler 已提交
132

M
Mark Adler 已提交
133 134 135 136
.c.lo:
	-@if [ ! -d objs ]; then mkdir objs; fi
	$(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
	-@mv objs/$*.o $@
M
Mark Adler 已提交
137 138

$(SHAREDLIBV): $(PIC_OBJS)
M
Mark Adler 已提交
139
	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
M
Mark Adler 已提交
140
	rm -f $(SHAREDLIB) $(SHAREDLIBM)
M
Mark Adler 已提交
141
	ln -s $@ $(SHAREDLIB)
M
Mark Adler 已提交
142
	ln -s $@ $(SHAREDLIBM)
M
Mark Adler 已提交
143
	-@rmdir objs
M
Mark Adler 已提交
144

M
Mark Adler 已提交
145
example$(EXE): example.o $(STATICLIB)
M
Mark Adler 已提交
146
	$(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
M
Mark Adler 已提交
147

M
Mark Adler 已提交
148
minigzip$(EXE): minigzip.o $(STATICLIB)
M
Mark Adler 已提交
149
	$(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
M
Mark Adler 已提交
150

M
Mark Adler 已提交
151 152
examplesh$(EXE): example.o $(SHAREDLIBV)
	$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
M
Mark Adler 已提交
153

M
Mark Adler 已提交
154 155
minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
	$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
M
Mark Adler 已提交
156

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

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

M
Mark Adler 已提交
163
install-libs: $(LIBS)
M
Mark Adler 已提交
164 165 166 167 168
	-@if [ ! -d $(DESTDIR)$(exec_prefix)  ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
	-@if [ ! -d $(DESTDIR)$(libdir)       ]; then mkdir -p $(DESTDIR)$(libdir); fi
	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
	cp $(LIBS) $(DESTDIR)$(libdir)
M
Mark Adler 已提交
169
	cd $(DESTDIR)$(libdir); chmod u=rw,go=r $(STATICLIB)
M
Mark Adler 已提交
170
	-@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
M
Mark Adler 已提交
171 172
	-@cd $(DESTDIR)$(libdir); if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
	  chmod 755 $(SHAREDLIBV); \
M
Mark Adler 已提交
173 174 175
	  rm -f $(SHAREDLIB) $(SHAREDLIBM); \
	  ln -s $(SHAREDLIBV) $(SHAREDLIB); \
	  ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
M
Mark Adler 已提交
176
	  ($(LDCONFIG) || true)  >/dev/null 2>&1; \
M
Mark Adler 已提交
177
	fi
M
Mark Adler 已提交
178 179 180 181
	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 已提交
182
# The ranlib in install is needed on NeXTSTEP which checks file times
M
Mark Adler 已提交
183
# ldconfig is for Linux
M
Mark Adler 已提交
184

M
Mark Adler 已提交
185 186
install: install-libs
	-@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
M
Mark Adler 已提交
187 188
	cp zlib.h zconf.h $(DESTDIR)$(includedir)
	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
M
Mark Adler 已提交
189

M
Mark Adler 已提交
190
uninstall:
M
Mark Adler 已提交
191
	cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
M
Mark Adler 已提交
192
	cd $(DESTDIR)$(libdir); rm -f libz.a; \
M
Mark Adler 已提交
193
	if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
M
Mark Adler 已提交
194
	  rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
M
Mark Adler 已提交
195
	fi
M
Mark Adler 已提交
196 197
	cd $(DESTDIR)$(man3dir); rm -f zlib.3
	cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
M
Mark Adler 已提交
198

M
Mark Adler 已提交
199 200 201 202 203 204 205 206 207 208 209 210
docs: zlib.3.pdf

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

zconf.h.in: zconf.h.cmakein
	sed "/^#cmakedefine/D" < zconf.h.cmakein > zconf.h.in
	touch -r zconf.h.cmakein zconf.h.in

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

M
Mark Adler 已提交
211
mostlyclean: clean
M
Mark Adler 已提交
212
clean:
M
Mark Adler 已提交
213
	rm -f *.o *.lo *~ \
M
Mark Adler 已提交
214
	   example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
M
Mark Adler 已提交
215
	   example64$(EXE) minigzip64$(EXE) \
M
Mark Adler 已提交
216
	   libz.* foo.gz so_locations \
M
Mark Adler 已提交
217
	   _match.s maketree contrib/infback9/*.o
M
Mark Adler 已提交
218
	rm -rf objs
M
Mark Adler 已提交
219

M
Mark Adler 已提交
220
maintainer-clean: distclean
M
Mark Adler 已提交
221 222
distclean: clean zconf docs
	rm -f Makefile zlib.pc
M
Mark Adler 已提交
223
	-@rm -f .DS_Store
M
Mark Adler 已提交
224
	-@printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile
M
Mark Adler 已提交
225
	-@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
M
Mark Adler 已提交
226
	-@touch -r Makefile.in Makefile
M
Mark Adler 已提交
227

M
Mark Adler 已提交
228
tags:
M
Mark Adler 已提交
229 230 231 232 233 234 235
	etags *.[ch]

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

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

M
Mark Adler 已提交
236
adler32.o zutil.o: zutil.h zlib.h zconf.h
M
Mark Adler 已提交
237 238 239 240 241 242 243 244
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 已提交
245

M
Mark Adler 已提交
246
adler32.lo zutil.lo: zutil.h zlib.h zconf.h
M
Mark Adler 已提交
247 248 249 250 251 252 253 254
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