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

M
Mark Adler 已提交
5 6 7
# To compile and test, type:
#   ./configure; make test
# 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 10 11 12 13 14

# 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 已提交
15
CC=cc
M
Mark Adler 已提交
16

M
Mark Adler 已提交
17
CFLAGS=-O
M
Mark Adler 已提交
18
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
M
Mark Adler 已提交
19
#CFLAGS=-g -DDEBUG
M
Mark Adler 已提交
20 21 22
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
#           -Wstrict-prototypes -Wmissing-prototypes

M
Mark Adler 已提交
23
LDFLAGS=libz.a
M
Mark Adler 已提交
24
LDSHARED=$(CC)
M
Mark Adler 已提交
25
CPP=$(CC) -E
M
Mark Adler 已提交
26

M
Mark Adler 已提交
27
VER=1.2.0.2
M
Mark Adler 已提交
28
LIBS=libz.a
M
Mark Adler 已提交
29
SHAREDLIB=libz.so
M
Mark Adler 已提交
30 31

AR=ar rc
M
Mark Adler 已提交
32
RANLIB=ranlib
M
Mark Adler 已提交
33
TAR=tar
M
Mark Adler 已提交
34
SHELL=/bin/sh
M
Mark Adler 已提交
35

M
Mark Adler 已提交
36 37
prefix = /usr/local
exec_prefix = ${prefix}
M
Mark Adler 已提交
38 39
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
M
Mark Adler 已提交
40

M
Mark Adler 已提交
41
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
M
Mark Adler 已提交
42
       zutil.o inflate.o infback.o inftrees.o inffast.o
M
Mark Adler 已提交
43

M
Mark Adler 已提交
44 45 46
OBJA =
# to use the asm code: make OBJA=match.o

M
Mark Adler 已提交
47
TEST_OBJS = example.o minigzip.o
M
Mark Adler 已提交
48

M
Mark Adler 已提交
49
# Note: this hasn't been updated for zlib 1.2.0
M
Mark Adler 已提交
50
DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \
M
Mark Adler 已提交
51 52
  algorithm.txt zlib.3 zlib.html \
  msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
M
Mark Adler 已提交
53 54 55 56
  nt/Make*[a-z0-9] nt/zlib.dnt amiga/Make*.??? os2/M*.os2 os2/zlib.def \
  contrib/RE*.contrib contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \
  contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/asm[56]86/*.?86 \
  contrib/asm[56]86/*.S contrib/iostream/*.cpp \
M
Mark Adler 已提交
57
  contrib/iostream/*.h  contrib/iostream2/*.h contrib/iostream2/*.cpp \
M
Mark Adler 已提交
58
  contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \
M
Mark Adler 已提交
59 60
  contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? \
  contrib/delphi*/*.???
M
Mark Adler 已提交
61

M
Mark Adler 已提交
62
all: example minigzip
M
Mark Adler 已提交
63

M
Mark Adler 已提交
64
check: test
M
Mark Adler 已提交
65
test: all
M
Mark Adler 已提交
66
	@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
M
Mark Adler 已提交
67 68 69 70 71 72 73
	echo hello world | ./minigzip | ./minigzip -d || \
	  echo '		*** minigzip test FAILED ***' ; \
	if ./example; then \
	  echo '		*** zlib test OK ***'; \
	else \
	  echo '		*** zlib test FAILED ***'; \
	fi
M
Mark Adler 已提交
74

M
Mark Adler 已提交
75 76
libz.a: $(OBJS) $(OBJA)
	$(AR) $@ $(OBJS) $(OBJA)
M
Mark Adler 已提交
77
	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
M
Mark Adler 已提交
78

M
Mark Adler 已提交
79 80 81 82 83 84
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 已提交
85
$(SHAREDLIB).$(VER): $(OBJS)
M
Mark Adler 已提交
86
	$(LDSHARED) -o $@ $(OBJS)
M
Mark Adler 已提交
87 88 89
	rm -f $(SHAREDLIB) $(SHAREDLIB).1
	ln -s $@ $(SHAREDLIB)
	ln -s $@ $(SHAREDLIB).1
M
Mark Adler 已提交
90

M
Mark Adler 已提交
91
example: example.o $(LIBS)
M
Mark Adler 已提交
92 93
	$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)

M
Mark Adler 已提交
94
minigzip: minigzip.o $(LIBS)
M
Mark Adler 已提交
95 96
	$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)

M
Mark Adler 已提交
97
install: $(LIBS)
M
Mark Adler 已提交
98
	-@if [ ! -d $(exec_prefix) ]; then mkdir $(exec_prefix); fi
M
Mark Adler 已提交
99 100 101 102 103 104 105 106
	-@if [ ! -d $(includedir)  ]; then mkdir $(includedir); fi
	-@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi
	cp zlib.h zconf.h $(includedir)
	chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
	cp $(LIBS) $(libdir)
	cd $(libdir); chmod 755 $(LIBS)
	-@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
	cd $(libdir); if test -f $(SHAREDLIB).$(VER); then \
M
Mark Adler 已提交
107 108 109 110
	  rm -f $(SHAREDLIB) $(SHAREDLIB).1; \
	  ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \
	  ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \
	  (ldconfig || true)  >/dev/null 2>&1; \
M
Mark Adler 已提交
111 112
	fi
# The ranlib in install is needed on NeXTSTEP which checks file times
M
Mark Adler 已提交
113
# ldconfig is for Linux
M
Mark Adler 已提交
114 115

uninstall:
M
Mark Adler 已提交
116
	cd $(includedir); \
M
Mark Adler 已提交
117 118 119 120 121
	v=$(VER); \
	if test -f zlib.h; then \
	  v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \
          rm -f zlib.h zconf.h; \
	fi; \
M
Mark Adler 已提交
122
	cd $(libdir); rm -f libz.a; \
M
Mark Adler 已提交
123 124
	if test -f $(SHAREDLIB).$$v; then \
	  rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \
M
Mark Adler 已提交
125 126
	fi

M
Mark Adler 已提交
127
mostlyclean: clean
M
Mark Adler 已提交
128
clean:
M
Mark Adler 已提交
129 130
	rm -f *.o *~ example minigzip libz.a libz.so* foo.gz so_locations \
	   _match.s maketree
M
Mark Adler 已提交
131

M
Mark Adler 已提交
132
maintainer-clean: distclean
M
Mark Adler 已提交
133
distclean:	clean
M
Mark Adler 已提交
134 135
	cp -p Makefile.in Makefile
	cp -p zconf.in.h zconf.h
M
Mark Adler 已提交
136

M
Mark Adler 已提交
137
zip:
M
Mark Adler 已提交
138
	mv Makefile Makefile~; cp -p Makefile.in Makefile
M
Mark Adler 已提交
139
	rm -f test.c ztest*.c contrib/minizip/test.zip
M
Mark Adler 已提交
140 141
	v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
	zip -ul9 zlib$$v $(DISTFILES)
M
Mark Adler 已提交
142 143 144
	mv Makefile~ Makefile

dist:
M
Mark Adler 已提交
145
	echo Warning: this hasn't been updated for zlib 1.2.0 -- don't use
M
Mark Adler 已提交
146
	mv Makefile Makefile~; cp -p Makefile.in Makefile
M
Mark Adler 已提交
147
	rm -f test.c ztest*.c contrib/minizip/test.zip
M
Mark Adler 已提交
148 149 150 151 152 153 154 155 156 157 158
	d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
	rm -f $$d.tar.gz; \
	if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \
	files=""; \
	for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \
	cd ..; \
	GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \
	if test ! -d $$d; then rm -f $$d; fi
	mv Makefile~ Makefile

tags:	
M
Mark Adler 已提交
159
	etags *.[ch]
M
Mark Adler 已提交
160

M
Mark Adler 已提交
161 162 163
depend:
	makedepend -- $(CFLAGS) -- *.[ch]

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

M
Mark Adler 已提交
166
adler32.o: zlib.h zconf.h
M
Mark Adler 已提交
167
compress.o: zlib.h zconf.h
M
Mark Adler 已提交
168
crc32.o: crc32.h zlib.h zconf.h
M
Mark Adler 已提交
169 170 171
deflate.o: deflate.h zutil.h zlib.h zconf.h
example.o: zlib.h zconf.h
gzio.o: zutil.h zlib.h zconf.h
M
Mark Adler 已提交
172 173 174
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
M
Mark Adler 已提交
175
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
M
Mark Adler 已提交
176
minigzip.o:  zlib.h zconf.h 
M
Mark Adler 已提交
177
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
M
Mark Adler 已提交
178
uncompr.o: zlib.h zconf.h
M
Mark Adler 已提交
179
zutil.o: zutil.h zlib.h zconf.h