File indexing completed on 2024-04-21 03:48:32

0001 # Makefile for zlib
0002 # Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler
0003 # For conditions of distribution and use, see copyright notice in zlib.h
0004 
0005 # To compile and test, type:
0006 #    ./configure; make test
0007 # Normally configure builds both a static and a shared library.
0008 # If you want to build just a static library, use: ./configure --static
0009 
0010 # To use the asm code, type:
0011 #    cp contrib/asm?86/match.S ./match.S
0012 #    make LOC=-DASMV OBJA=match.o
0013 
0014 # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
0015 #    make install
0016 # To install in $HOME instead of /usr/local, use:
0017 #    make install prefix=$HOME
0018 
0019 CC=cc
0020 
0021 CFLAGS=-O
0022 #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
0023 #CFLAGS=-g -DDEBUG
0024 #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
0025 #           -Wstrict-prototypes -Wmissing-prototypes
0026 
0027 SFLAGS=-O
0028 LDFLAGS=
0029 TEST_LDFLAGS=-L. libz.a
0030 LDSHARED=$(CC)
0031 CPP=$(CC) -E
0032 
0033 STATICLIB=libz.a
0034 SHAREDLIB=libz.so
0035 SHAREDLIBV=libz.so.1.2.8
0036 SHAREDLIBM=libz.so.1
0037 LIBS=$(STATICLIB) $(SHAREDLIBV)
0038 
0039 AR=ar
0040 ARFLAGS=rc
0041 RANLIB=ranlib
0042 LDCONFIG=ldconfig
0043 LDSHAREDLIBC=-lc
0044 TAR=tar
0045 SHELL=/bin/sh
0046 EXE=
0047 
0048 prefix = /usr/local
0049 exec_prefix = ${prefix}
0050 libdir = ${exec_prefix}/lib
0051 sharedlibdir = ${libdir}
0052 includedir = ${prefix}/include
0053 mandir = ${prefix}/share/man 
0054 man3dir = ${mandir}/man3
0055 pkgconfigdir = ${libdir}/pkgconfig
0056 
0057 OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
0058 OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
0059 OBJC = $(OBJZ) $(OBJG)
0060 
0061 PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
0062 PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
0063 PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
0064 
0065 # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
0066 OBJA =
0067 PIC_OBJA =
0068 
0069 OBJS = $(OBJC) $(OBJA)
0070 
0071 PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
0072 
0073 all: static shared
0074 
0075 static: example$(EXE) minigzip$(EXE)
0076 
0077 shared: examplesh$(EXE) minigzipsh$(EXE)
0078 
0079 all64: example64$(EXE) minigzip64$(EXE)
0080 
0081 check: test
0082 
0083 test: all teststatic testshared
0084 
0085 teststatic: static
0086         @TMPST=tmpst_$$; \
0087         if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \
0088           echo '                *** zlib test OK ***'; \
0089         else \
0090           echo '                *** zlib test FAILED ***'; false; \
0091         fi; \
0092         rm -f $$TMPST
0093 
0094 testshared: shared
0095         @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
0096         LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
0097         DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
0098         SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
0099         TMPSH=tmpsh_$$; \
0100         if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \
0101           echo '                *** zlib shared test OK ***'; \
0102         else \
0103           echo '                *** zlib shared test FAILED ***'; false; \
0104         fi; \
0105         rm -f $$TMPSH
0106 
0107 test64: all64
0108         @TMP64=tmp64_$$; \
0109         if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \
0110           echo '                *** zlib 64-bit test OK ***'; \
0111         else \
0112           echo '                *** zlib 64-bit test FAILED ***'; false; \
0113         fi; \
0114         rm -f $$TMP64
0115 
0116 infcover.o: test/infcover.c zlib.h zconf.h
0117         $(CC) $(CFLAGS) -I. -c -o $@ test/infcover.c
0118 
0119 infcover: infcover.o libz.a
0120         $(CC) $(CFLAGS) -o $@ infcover.o libz.a
0121 
0122 cover: infcover
0123         rm -f *.gcda
0124         ./infcover
0125         gcov inf*.c
0126 
0127 libz.a: $(OBJS)
0128         $(AR) $(ARFLAGS) $@ $(OBJS)
0129         -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
0130 
0131 match.o: match.S
0132         $(CPP) match.S > _match.s
0133         $(CC) -c _match.s
0134         mv _match.o match.o
0135         rm -f _match.s
0136 
0137 match.lo: match.S
0138         $(CPP) match.S > _match.s
0139         $(CC) -c -fPIC _match.s
0140         mv _match.o match.lo
0141         rm -f _match.s
0142 
0143 example.o: test/example.c zlib.h zconf.h
0144         $(CC) $(CFLAGS) -I. -c -o $@ test/example.c
0145 
0146 minigzip.o: test/minigzip.c zlib.h zconf.h
0147         $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
0148 
0149 example64.o: test/example.c zlib.h zconf.h
0150         $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c
0151 
0152 minigzip64.o: test/minigzip.c zlib.h zconf.h
0153         $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c
0154 
0155 .SUFFIXES: .lo
0156 
0157 .c.lo:
0158         -@mkdir objs 2>/dev/null || test -d objs
0159         $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
0160         -@mv objs/$*.o $@
0161 
0162 placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
0163         $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
0164         rm -f $(SHAREDLIB) $(SHAREDLIBM)
0165         ln -s $@ $(SHAREDLIB)
0166         ln -s $@ $(SHAREDLIBM)
0167         -@rmdir objs
0168 
0169 example$(EXE): example.o $(STATICLIB)
0170         $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
0171 
0172 minigzip$(EXE): minigzip.o $(STATICLIB)
0173         $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
0174 
0175 examplesh$(EXE): example.o $(SHAREDLIBV)
0176         $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
0177 
0178 minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
0179         $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
0180 
0181 example64$(EXE): example64.o $(STATICLIB)
0182         $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
0183 
0184 minigzip64$(EXE): minigzip64.o $(STATICLIB)
0185         $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
0186 
0187 install-libs: $(LIBS)
0188         -@if [ ! -d $(DESTDIR)$(exec_prefix)  ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
0189         -@if [ ! -d $(DESTDIR)$(libdir)       ]; then mkdir -p $(DESTDIR)$(libdir); fi
0190         -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
0191         -@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
0192         -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
0193         cp $(STATICLIB) $(DESTDIR)$(libdir)
0194         chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
0195         -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
0196         -@if test -n "$(SHAREDLIBV)"; then \
0197           cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
0198           echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
0199           chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
0200           echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
0201           rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
0202           ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
0203           ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
0204           ($(LDCONFIG) || true)  >/dev/null 2>&1; \
0205         fi
0206         cp zlib.3 $(DESTDIR)$(man3dir)
0207         chmod 644 $(DESTDIR)$(man3dir)/zlib.3
0208         cp zlib.pc $(DESTDIR)$(pkgconfigdir)
0209         chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
0210 # The ranlib in install is needed on NeXTSTEP which checks file times
0211 # ldconfig is for Linux
0212 
0213 install: install-libs
0214         -@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
0215         cp zlib.h zconf.h $(DESTDIR)$(includedir)
0216         chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
0217 
0218 uninstall:
0219         cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h
0220         cd $(DESTDIR)$(libdir) && rm -f libz.a; \
0221         if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
0222           rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
0223         fi
0224         cd $(DESTDIR)$(man3dir) && rm -f zlib.3
0225         cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc
0226 
0227 docs: zlib.3.pdf
0228 
0229 zlib.3.pdf: zlib.3
0230         groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
0231 
0232 zconf.h.cmakein: zconf.h.in
0233         -@ TEMPFILE=zconfh_$$; \
0234         echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
0235         sed -f $$TEMPFILE zconf.h.in > zconf.h.cmakein &&\
0236         touch -r zconf.h.in zconf.h.cmakein &&\
0237         rm $$TEMPFILE
0238 
0239 zconf: zconf.h.in
0240         cp -p zconf.h.in zconf.h
0241 
0242 mostlyclean: clean
0243 clean:
0244         rm -f *.o *.lo *~ \
0245            example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
0246            example64$(EXE) minigzip64$(EXE) \
0247            infcover \
0248            libz.* foo.gz so_locations \
0249            _match.s maketree contrib/infback9/*.o
0250         rm -rf objs
0251         rm -f *.gcda *.gcno *.gcov
0252         rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
0253 
0254 maintainer-clean: distclean
0255 distclean: clean zconf zconf.h.cmakein docs
0256         rm -f Makefile zlib.pc configure.log
0257         -@rm -f .DS_Store
0258         -@printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile
0259         -@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
0260         -@touch -r Makefile.in Makefile
0261 
0262 tags:
0263         etags *.[ch]
0264 
0265 depend:
0266         makedepend -- $(CFLAGS) -- *.[ch]
0267 
0268 # DO NOT DELETE THIS LINE -- make depend depends on it.
0269 
0270 adler32.o zutil.o: zutil.h zlib.h zconf.h
0271 gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
0272 compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
0273 crc32.o: zutil.h zlib.h zconf.h crc32.h
0274 deflate.o: deflate.h zutil.h zlib.h zconf.h
0275 infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
0276 inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
0277 inftrees.o: zutil.h zlib.h zconf.h inftrees.h
0278 trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
0279 
0280 adler32.lo zutil.lo: zutil.h zlib.h zconf.h
0281 gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
0282 compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
0283 crc32.lo: zutil.h zlib.h zconf.h crc32.h
0284 deflate.lo: deflate.h zutil.h zlib.h zconf.h
0285 infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
0286 inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
0287 inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
0288 trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h