Makefile 4.7 KB
Newer Older
M
Mark Adler 已提交
1
# Makefile for zlib
M
Mark Adler 已提交
2
# Copyright (C) 1995-1998 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=-L. -lz
M
Mark Adler 已提交
24
LDSHARED=$(CC)
M
Mark Adler 已提交
25

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

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

M
Mark Adler 已提交
35
prefix=/usr/local
M
Mark Adler 已提交
36
exec_prefix = $(prefix)
M
Mark Adler 已提交
37

M
Mark Adler 已提交
38
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
M
Mark Adler 已提交
39
       zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
M
Mark Adler 已提交
40

M
Mark Adler 已提交
41
TEST_OBJS = example.o minigzip.o
M
Mark Adler 已提交
42

M
Mark Adler 已提交
43 44 45 46 47 48 49
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \
  algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
  nt/Makefile.nt nt/zlib.dnt  contrib/README.contrib contrib/*.txt \
  contrib/asm386/*.asm contrib/asm386/*.c \
  contrib/asm386/*.bat contrib/asm386/*.mak contrib/iostream/*.cpp \
  contrib/iostream/*.h  contrib/iostream2/*.h contrib/iostream2/*.cpp \
  contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32
M
Mark Adler 已提交
50

M
Mark Adler 已提交
51
all: example minigzip
M
Mark Adler 已提交
52 53

test: all
M
Mark Adler 已提交
54
	@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
M
Mark Adler 已提交
55 56 57 58 59 60 61
	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 已提交
62

M
Mark Adler 已提交
63
libz.a: $(OBJS)
M
Mark Adler 已提交
64
	$(AR) $@ $(OBJS)
M
Mark Adler 已提交
65
	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
M
Mark Adler 已提交
66

M
Mark Adler 已提交
67
$(SHAREDLIB).$(VER): $(OBJS)
M
Mark Adler 已提交
68
	$(LDSHARED) -o $@ $(OBJS)
M
Mark Adler 已提交
69 70 71
	rm -f $(SHAREDLIB) $(SHAREDLIB).1
	ln -s $@ $(SHAREDLIB)
	ln -s $@ $(SHAREDLIB).1
M
Mark Adler 已提交
72

M
Mark Adler 已提交
73
example: example.o $(LIBS)
M
Mark Adler 已提交
74 75
	$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)

M
Mark Adler 已提交
76
minigzip: minigzip.o $(LIBS)
M
Mark Adler 已提交
77 78
	$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)

M
Mark Adler 已提交
79 80 81 82 83 84 85 86
install: $(LIBS)
	-@if [ ! $(prefix)/include  ]; then mkdir $(prefix)/include; fi
	-@if [ ! $(exec_prefix)/lib ]; then mkdir $(exec_prefix)/lib; fi
	cp zlib.h zconf.h $(prefix)/include
	chmod 644 $(prefix)/include/zlib.h $(prefix)/include/zconf.h
	cp $(LIBS) $(exec_prefix)/lib
	cd $(exec_prefix)/lib; chmod 644 $(LIBS)
	-@(cd $(exec_prefix)/lib; $(RANLIB) libz.a || true) >/dev/null 2>&1
M
Mark Adler 已提交
87 88 89 90 91
	cd $(exec_prefix)/lib; if test -f $(SHAREDLIB).$(VER); then \
	  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 已提交
92 93
	fi
# The ranlib in install is needed on NeXTSTEP which checks file times
M
Mark Adler 已提交
94
# ldconfig is for Linux
M
Mark Adler 已提交
95 96

uninstall:
M
Mark Adler 已提交
97 98 99 100 101 102 103 104 105
	cd $(prefix)/include; \
	v=$(VER); \
	if test -f zlib.h; then \
	  v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \
          rm -f zlib.h zconf.h; \
	fi; \
	cd $(exec_prefix)/lib; rm -f libz.a; \
	if test -f $(SHAREDLIB).$$v; then \
	  rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \
M
Mark Adler 已提交
106 107
	fi

M
Mark Adler 已提交
108
clean:
M
Mark Adler 已提交
109
	rm -f *.o *~ example minigzip libz.a libz.so* foo.gz
M
Mark Adler 已提交
110

M
Mark Adler 已提交
111 112
distclean:	clean

M
Mark Adler 已提交
113
zip:
M
Mark Adler 已提交
114
	mv Makefile Makefile~; cp -p Makefile.in Makefile
M
Mark Adler 已提交
115 116
	v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
	zip -ul9 zlib$$v $(DISTFILES)
M
Mark Adler 已提交
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
	mv Makefile~ Makefile

dist:
	mv Makefile Makefile~; cp -p Makefile.in Makefile
	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 已提交
132
	etags *.[ch]
M
Mark Adler 已提交
133

M
Mark Adler 已提交
134 135 136
depend:
	makedepend -- $(CFLAGS) -- *.[ch]

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

M
Mark Adler 已提交
139
adler32.o: zlib.h zconf.h
M
Mark Adler 已提交
140
compress.o: zlib.h zconf.h
M
Mark Adler 已提交
141
crc32.o: zlib.h zconf.h
M
Mark Adler 已提交
142 143 144
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 已提交
145 146 147 148 149
infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h
infcodes.o: zutil.h zlib.h zconf.h
infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h
inffast.o: infblock.h infcodes.h infutil.h inffast.h
M
Mark Adler 已提交
150 151
inflate.o: zutil.h zlib.h zconf.h infblock.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
M
Mark Adler 已提交
152 153
infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
minigzip.o:  zlib.h zconf.h 
M
Mark Adler 已提交
154
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
M
Mark Adler 已提交
155
uncompr.o: zlib.h zconf.h
M
Mark Adler 已提交
156
zutil.o: zutil.h zlib.h zconf.h