| 1 | # Makefile for zlib |
| 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. |
| 3 | # For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | |
| 5 | # To compile and test, type: |
| 6 | # ./configure; make test |
| 7 | # The call of configure is optional if you don't have special requirements |
| 8 | # If you wish to build zlib as a shared library, use: ./configure -s |
| 9 | |
| 10 | # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: |
| 11 | # make install |
| 12 | # To install in $HOME instead of /usr/local, use: |
| 13 | # make install prefix=$HOME |
| 14 | |
| 15 | CC=cc |
| 16 | |
| 17 | CFLAGS=-O |
| 18 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 |
| 19 | #CFLAGS=-g -DDEBUG |
| 20 | #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ |
| 21 | # -Wstrict-prototypes -Wmissing-prototypes |
| 22 | |
| 23 | LDFLAGS=-L. -lz |
| 24 | LDSHARED=$(CC) |
| 25 | |
| 26 | VER=1.1.2 |
| 27 | LIBS=libz.a |
| 28 | SHAREDLIB=libz.so |
| 29 | |
| 30 | AR=ar rc |
| 31 | RANLIB=ranlib |
| 32 | TAR=tar |
| 33 | SHELL=/bin/sh |
| 34 | |
| 35 | prefix = /usr/local |
| 36 | exec_prefix = ${prefix} |
| 37 | |
| 38 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
| 39 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o |
| 40 | |
| 41 | TEST_OBJS = example.o minigzip.o |
| 42 | |
| 43 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ |
| 44 | algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ |
| 45 | nt/Makefile.nt nt/zlib.dnt amiga/Make*.??? contrib/README.contrib \ |
| 46 | contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \ |
| 47 | contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ |
| 48 | contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ |
| 49 | contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \ |
| 50 | contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? |
| 51 | |
| 52 | |
| 53 | all: example minigzip |
| 54 | |
| 55 | test: all |
| 56 | @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ |
| 57 | echo hello world | ./minigzip | ./minigzip -d || \ |
| 58 | echo ' *** minigzip test FAILED ***' ; \ |
| 59 | if ./example; then \ |
| 60 | echo ' *** zlib test OK ***'; \ |
| 61 | else \ |
| 62 | echo ' *** zlib test FAILED ***'; \ |
| 63 | fi |
| 64 | |
| 65 | libz.a: $(OBJS) |
| 66 | $(AR) $@ $(OBJS) |
| 67 | -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 |
| 68 | |
| 69 | $(SHAREDLIB).$(VER): $(OBJS) |
| 70 | $(LDSHARED) -o $@ $(OBJS) |
| 71 | rm -f $(SHAREDLIB) $(SHAREDLIB).1 |
| 72 | ln -s $@ $(SHAREDLIB) |
| 73 | ln -s $@ $(SHAREDLIB).1 |
| 74 | |
| 75 | example: example.o $(LIBS) |
| 76 | $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) |
| 77 | |
| 78 | minigzip: minigzip.o $(LIBS) |
| 79 | $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) |
| 80 | |
| 81 | install: $(LIBS) |
| 82 | -@if [ ! -d $(prefix)/include ]; then mkdir $(prefix)/include; fi |
| 83 | -@if [ ! -d $(exec_prefix)/lib ]; then mkdir $(exec_prefix)/lib; fi |
| 84 | cp zlib.h zconf.h $(prefix)/include |
| 85 | chmod 644 $(prefix)/include/zlib.h $(prefix)/include/zconf.h |
| 86 | cp $(LIBS) $(exec_prefix)/lib |
| 87 | cd $(exec_prefix)/lib; chmod 755 $(LIBS) |
| 88 | -@(cd $(exec_prefix)/lib; $(RANLIB) libz.a || true) >/dev/null 2>&1 |
| 89 | cd $(exec_prefix)/lib; if test -f $(SHAREDLIB).$(VER); then \ |
| 90 | rm -f $(SHAREDLIB) $(SHAREDLIB).1; \ |
| 91 | ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \ |
| 92 | ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \ |
| 93 | (ldconfig || true) >/dev/null 2>&1; \ |
| 94 | fi |
| 95 | # The ranlib in install is needed on NeXTSTEP which checks file times |
| 96 | # ldconfig is for Linux |
| 97 | |
| 98 | uninstall: |
| 99 | cd $(prefix)/include; \ |
| 100 | v=$(VER); \ |
| 101 | if test -f zlib.h; then \ |
| 102 | v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \ |
| 103 | rm -f zlib.h zconf.h; \ |
| 104 | fi; \ |
| 105 | cd $(exec_prefix)/lib; rm -f libz.a; \ |
| 106 | if test -f $(SHAREDLIB).$$v; then \ |
| 107 | rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ |
| 108 | fi |
| 109 | |
| 110 | clean: |
| 111 | rm -f *.o *~ example minigzip libz.a libz.so* foo.gz |
| 112 | |
| 113 | distclean: clean |
| 114 | |
| 115 | zip: |
| 116 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
| 117 | rm -f test.c ztest*.c contrib/minizip/test.zip |
| 118 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
| 119 | zip -ul9 zlib$$v $(DISTFILES) |
| 120 | mv Makefile~ Makefile |
| 121 | |
| 122 | dist: |
| 123 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
| 124 | rm -f test.c ztest*.c contrib/minizip/test.zip |
| 125 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
| 126 | rm -f $$d.tar.gz; \ |
| 127 | if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ |
| 128 | files=""; \ |
| 129 | for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ |
| 130 | cd ..; \ |
| 131 | GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ |
| 132 | if test ! -d $$d; then rm -f $$d; fi |
| 133 | mv Makefile~ Makefile |
| 134 | |
| 135 | tags: |
| 136 | etags *.[ch] |
| 137 | |
| 138 | depend: |
| 139 | makedepend -- $(CFLAGS) -- *.[ch] |
| 140 | |
| 141 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
| 142 | |
| 143 | adler32.o: zlib.h zconf.h |
| 144 | compress.o: zlib.h zconf.h |
| 145 | crc32.o: zlib.h zconf.h |
| 146 | deflate.o: deflate.h zutil.h zlib.h zconf.h |
| 147 | example.o: zlib.h zconf.h |
| 148 | gzio.o: zutil.h zlib.h zconf.h |
| 149 | infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h |
| 150 | infcodes.o: zutil.h zlib.h zconf.h |
| 151 | infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h |
| 152 | inffast.o: zutil.h zlib.h zconf.h inftrees.h |
| 153 | inffast.o: infblock.h infcodes.h infutil.h inffast.h |
| 154 | inflate.o: zutil.h zlib.h zconf.h infblock.h |
| 155 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h |
| 156 | infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h |
| 157 | minigzip.o: zlib.h zconf.h |
| 158 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h |
| 159 | uncompr.o: zlib.h zconf.h |
| 160 | zutil.o: zutil.h zlib.h zconf.h |