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

M
Mark Adler 已提交
5
# To compile and test, type:
M
Mark Adler 已提交
6
#    ./configure; make test
M
Mark Adler 已提交
7
# The call of configure is optional if you don't have special requirements
M
Mark Adler 已提交
8
# If you wish to build zlib as a shared library, use: ./configure -s
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
# 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

M
Mark Adler 已提交
19
CC=cc
M
Mark Adler 已提交
20

M
Mark Adler 已提交
21
CFLAGS=-O
M
Mark Adler 已提交
22
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
M
Mark Adler 已提交
23
#CFLAGS=-g -DDEBUG
M
Mark Adler 已提交
24 25 26
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
#           -Wstrict-prototypes -Wmissing-prototypes

M
Mark Adler 已提交
27 28
SFLAGS=-O

M
Mark Adler 已提交
29
LDFLAGS=libz.a
M
Mark Adler 已提交
30
LDSHARED=$(CC)
M
Mark Adler 已提交
31
CPP=$(CC) -E
M
Mark Adler 已提交
32

M
Mark Adler 已提交
33
LIBS=libz.a
M
Mark Adler 已提交
34
SHAREDLIB=libz.so
M
Mark Adler 已提交
35
SHAREDLIBV=libz.so.1.2.3.3
M
Mark Adler 已提交
36
SHAREDLIBM=libz.so.1
M
Mark Adler 已提交
37

M
Mark Adler 已提交
38
AR=ar
M
Mark Adler 已提交
39
RANLIB=ranlib
M
Mark Adler 已提交
40
TAR=tar
M
Mark Adler 已提交
41
SHELL=/bin/sh
M
Mark Adler 已提交
42
EXE=
M
Mark Adler 已提交
43

M
Mark Adler 已提交
44 45
prefix = /usr/local
exec_prefix = ${prefix}
M
Mark Adler 已提交
46 47
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
M
Mark Adler 已提交
48 49
mandir = ${prefix}/share/man
man3dir = ${mandir}/man3
M
Mark Adler 已提交
50
pkgconfigdir = ${libdir}/pkgconfig
M
Mark Adler 已提交
51

M
Mark Adler 已提交
52
OBJC = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
M
Mark Adler 已提交
53
       zutil.o inflate.o infback.o inftrees.o inffast.o
M
Mark Adler 已提交
54

M
Mark Adler 已提交
55 56 57
OBJA =
# to use the asm code: make OBJA=match.o

M
Mark Adler 已提交
58 59 60 61
OBJS = $(OBJC) $(OBJA)

PIC_OBJS = $(OBJS:%.o=%.lo)

M
Mark Adler 已提交
62
TEST_OBJS = example.o minigzip.o
M
Mark Adler 已提交
63

M
Mark Adler 已提交
64
allstatic: example$(EXE) minigzip$(EXE)
M
Mark Adler 已提交
65

M
Mark Adler 已提交
66 67 68 69 70 71
allshared: examplesh$(EXE) minigzipsh$(EXE)

all: allstatic allshared

teststatic: allstatic
	@echo hello world | ./minigzip | ./minigzip -d || \
M
Mark Adler 已提交
72 73 74 75 76 77
	  echo '		*** minigzip test FAILED ***' ; \
	if ./example; then \
	  echo '		*** zlib test OK ***'; \
	else \
	  echo '		*** zlib test FAILED ***'; \
	fi
M
Mark Adler 已提交
78

M
Mark Adler 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
testshared: allshared
	@LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
	DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
	SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
	echo hello world | ./minigzipsh | ./minigzipsh -d || \
	  echo '		*** minigzip shared test FAILED ***' ; \
	if ./examplesh; then \
	  echo '		*** zlib shared test OK ***'; \
	else \
	  echo '		*** zlib shared test FAILED ***'; \
	fi

test: teststatic testshared

check: test

M
Mark Adler 已提交
95 96
libz.a: $(OBJS)
	$(AR) $@ $(OBJS)
M
Mark Adler 已提交
97
	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
M
Mark Adler 已提交
98

M
Mark Adler 已提交
99 100 101 102 103 104
match.o: match.S
	$(CPP) match.S > _match.s
	$(CC) -c _match.s
	mv _match.o match.o
	rm -f _match.s

M
Mark Adler 已提交
105 106 107 108 109 110 111 112 113 114 115
match.lo: match.S
	$(CPP) match.S > _match.s
	$(CC) -c -fPIC _match.s
	mv _match.o match.lo
	rm -f _match.s

%.lo: %.c
	$(CC) $(SFLAGS) -DPIC -c $< -o $@

$(SHAREDLIBV): $(PIC_OBJS)
	$(LDSHARED) -o $@ $(PIC_OBJS) -lc
M
Mark Adler 已提交
116
	rm -f $(SHAREDLIB) $(SHAREDLIBM)
M
Mark Adler 已提交
117
	ln -s $@ $(SHAREDLIB)
M
Mark Adler 已提交
118
	ln -s $@ $(SHAREDLIBM)
M
Mark Adler 已提交
119

M
Mark Adler 已提交
120
example$(EXE): example.o $(LIBS)
M
Mark Adler 已提交
121 122
	$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)

M
Mark Adler 已提交
123
minigzip$(EXE): minigzip.o $(LIBS)
M
Mark Adler 已提交
124 125
	$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)

M
Mark Adler 已提交
126 127 128 129 130 131
examplesh$(EXE): example.o $(LIBS)
	$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIB)

minigzipsh$(EXE): minigzip.o $(LIBS)
	$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIB)

M
Mark Adler 已提交
132
install-libs: $(LIBS)
M
Mark Adler 已提交
133 134 135 136 137 138 139 140
	-@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)
	cd $(DESTDIR)$(libdir); chmod 755 $(LIBS)
	-@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
	cd $(DESTDIR)$(libdir); if test -f $(SHAREDLIBV); then \
M
Mark Adler 已提交
141 142 143
	  rm -f $(SHAREDLIB) $(SHAREDLIBM); \
	  ln -s $(SHAREDLIBV) $(SHAREDLIB); \
	  ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
M
Mark Adler 已提交
144
	  (ldconfig || true)  >/dev/null 2>&1; \
M
Mark Adler 已提交
145
	fi
M
Mark Adler 已提交
146 147 148 149
	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 已提交
150
# The ranlib in install is needed on NeXTSTEP which checks file times
M
Mark Adler 已提交
151
# ldconfig is for Linux
M
Mark Adler 已提交
152

M
Mark Adler 已提交
153 154 155 156 157
install: install-libs
	-@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
	cp zlib.h zconf.h zlibdefs.h $(DESTDIR)$(includedir)
	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h $(DESTDIR)$(includedir)/zlibdefs.h

M
Mark Adler 已提交
158
uninstall:
M
Mark Adler 已提交
159
	cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h zlibdefs.h
M
Mark Adler 已提交
160
	cd $(DESTDIR)$(libdir); rm -f libz.a; \
M
Mark Adler 已提交
161 162
	if test -f $(SHAREDLIBV); then \
	  rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
M
Mark Adler 已提交
163
	fi
M
Mark Adler 已提交
164 165
	cd $(DESTDIR)$(man3dir); rm -f zlib.3
	cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
M
Mark Adler 已提交
166

M
Mark Adler 已提交
167
mostlyclean: clean
M
Mark Adler 已提交
168
clean:
M
Mark Adler 已提交
169 170
	rm -f *.o *.lo *~ \
	   example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
M
Mark Adler 已提交
171
	   libz.* foo.gz so_locations \
M
Mark Adler 已提交
172
	   _match.s maketree contrib/infback9/*.o
M
Mark Adler 已提交
173

M
Mark Adler 已提交
174
maintainer-clean: distclean
M
Mark Adler 已提交
175
distclean: clean
M
Mark Adler 已提交
176
	cp -p Makefile.in Makefile
M
Mark Adler 已提交
177 178
	rm zlibdefs.h
	touch -r configure zlibdefs.h
M
Mark Adler 已提交
179
	rm -f zlib.pc .DS_Store
M
Mark Adler 已提交
180

M
Mark Adler 已提交
181
tags:
M
Mark Adler 已提交
182
	etags *.[ch]
M
Mark Adler 已提交
183

M
Mark Adler 已提交
184 185 186
depend:
	makedepend -- $(CFLAGS) -- *.[ch]

M
Mark Adler 已提交
187 188
# DO NOT DELETE THIS LINE -- make depend depends on it.

M
Mark Adler 已提交
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
adler32.o: zlib.h zconf.h zlibdefs.h
compress.o: zlib.h zconf.h zlibdefs.h
crc32.o: crc32.h zlib.h zconf.h zlibdefs.h
deflate.o: deflate.h zutil.h zlib.h zconf.h zlibdefs.h
example.o: zlib.h zconf.h zlibdefs.h
gzio.o: zutil.h zlib.h zconf.h zlibdefs.h
inffast.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h
inflate.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
infback.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
inftrees.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
minigzip.o: zlib.h zconf.h zlibdefs.h
trees.o: deflate.h zutil.h zlib.h zconf.h zlibdefs.h trees.h
uncompr.o: zlib.h zconf.h zlibdefs.h
zutil.o: zutil.h zlib.h zconf.h zlibdefs.h

adler32.lo: zlib.h zconf.h zlibdefs.h
compress.lo: zlib.h zconf.h zlibdefs.h
crc32.lo: crc32.h zlib.h zconf.h zlibdefs.h
deflate.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h
gzio.lo: zutil.h zlib.h zconf.h zlibdefs.h
inffast.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h
inflate.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
infback.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
inftrees.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
trees.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h trees.h
uncompr.lo: zlib.h zconf.h zlibdefs.h
zutil.lo: zutil.h zlib.h zconf.h zlibdefs.h