Makefile 4.4 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 8 9 10 11 12 13
# To compile and test, type:
#   ./configure; make test
# The call of configure is optional if you don't have special requirements

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

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

M
Mark Adler 已提交
22
LDFLAGS=-L. -lz
M
Mark Adler 已提交
23
LDSHARED=$(CC)
M
Mark Adler 已提交
24

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

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

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

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

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

M
Mark Adler 已提交
42 43 44 45 46 47 48
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 已提交
49

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

test: all
M
Mark Adler 已提交
53 54 55
	@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
	./example ; \
	echo hello world | ./minigzip | ./minigzip -d
M
Mark Adler 已提交
56

M
Mark Adler 已提交
57
libz.a: $(OBJS)
M
Mark Adler 已提交
58
	$(AR) $@ $(OBJS)
M
Mark Adler 已提交
59
	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
M
Mark Adler 已提交
60

M
Mark Adler 已提交
61
$(SHAREDLIB).$(VER): $(OBJS)
M
Mark Adler 已提交
62
	$(LDSHARED) -o $@ $(OBJS)
M
Mark Adler 已提交
63 64 65
	rm -f $(SHAREDLIB) $(SHAREDLIB).1
	ln -s $@ $(SHAREDLIB)
	ln -s $@ $(SHAREDLIB).1
M
Mark Adler 已提交
66

M
Mark Adler 已提交
67
example: example.o $(LIBS)
M
Mark Adler 已提交
68 69
	$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)

M
Mark Adler 已提交
70
minigzip: minigzip.o $(LIBS)
M
Mark Adler 已提交
71 72
	$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)

M
Mark Adler 已提交
73 74 75 76 77 78 79 80
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 已提交
81 82 83 84 85
	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 已提交
86 87
	fi
# The ranlib in install is needed on NeXTSTEP which checks file times
M
Mark Adler 已提交
88
# ldconfig is for Linux
M
Mark Adler 已提交
89 90 91

uninstall:
	cd $(exec_prefix)/lib; rm -f $(LIBS); \
M
Mark Adler 已提交
92
	if test -f $(SHAREDLIB); then \
M
Mark Adler 已提交
93
	 v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p'<$(prefix)/include/zlib.h`;\
M
Mark Adler 已提交
94
	 rm -f $(SHAREDLIB).$$v $(SHAREDLIB); \
M
Mark Adler 已提交
95
	fi
M
Mark Adler 已提交
96
	cdz $(prefix)/include; rm -f zlib.h zconf.h
M
Mark Adler 已提交
97

M
Mark Adler 已提交
98
clean:
M
Mark Adler 已提交
99
	rm -f *.o *~ example minigzip libz.a libz.so* foo.gz
M
Mark Adler 已提交
100

M
Mark Adler 已提交
101 102
distclean:	clean

M
Mark Adler 已提交
103
zip:
M
Mark Adler 已提交
104
	mv Makefile Makefile~; cp -p Makefile.in Makefile
M
Mark Adler 已提交
105 106
	v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
	zip -ul9 zlib$$v $(DISTFILES)
M
Mark Adler 已提交
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
	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 已提交
122
	etags *.[ch]
M
Mark Adler 已提交
123

M
Mark Adler 已提交
124 125 126
depend:
	makedepend -- $(CFLAGS) -- *.[ch]

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

M
Mark Adler 已提交
129
adler32.o: zlib.h zconf.h
M
Mark Adler 已提交
130
compress.o: zlib.h zconf.h
M
Mark Adler 已提交
131
crc32.o: zlib.h zconf.h
M
Mark Adler 已提交
132 133 134
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 已提交
135 136 137 138 139
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 已提交
140 141
inflate.o: zutil.h zlib.h zconf.h infblock.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
M
Mark Adler 已提交
142 143 144
infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
minigzip.o:  zlib.h zconf.h 
trees.o: deflate.h zutil.h zlib.h zconf.h 
M
Mark Adler 已提交
145
uncompr.o: zlib.h zconf.h
M
Mark Adler 已提交
146
zutil.o: zutil.h zlib.h zconf.h