1# Makefile for zlib 2# Copyright (C) 1995-2011 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# Normally configure builds both a static and a shared library. 8# If you want to build just a static library, use: ./configure --static 9 10# To use the asm code, type: 11# cp contrib/asm?86/match.S ./match.S 12# make LOC=-DASMV OBJA=match.o 13 14# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: 15# make install 16# To install in $HOME instead of /usr/local, use: 17# make install prefix=$HOME 18 19CC=gcc 20 21CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 22#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 23#CFLAGS=-g -DDEBUG 24#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ 25# -Wstrict-prototypes -Wmissing-prototypes 26 27SFLAGS=-O3 -fPIC -D_LARGEFILE64_SOURCE=1 28LDFLAGS= 29TEST_LDFLAGS=-L. libz.a 30LDSHARED=gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map 31CPP=gcc -E 32 33STATICLIB=libz.a 34SHAREDLIB=libz.so 35SHAREDLIBV=libz.so.1.2.6 36SHAREDLIBM=libz.so.1 37LIBS=$(STATICLIB) $(SHAREDLIBV) 38 39AR=ar 40ARFLAGS=rc 41RANLIB=ranlib 42LDCONFIG=ldconfig 43LDSHAREDLIBC=-lc 44TAR=tar 45SHELL=/bin/sh 46EXE= 47 48prefix =/usr/local 49exec_prefix =${prefix} 50libdir =${exec_prefix}/lib 51sharedlibdir =${libdir} 52includedir =${prefix}/include 53mandir =${prefix}/share/man 54man3dir = ${mandir}/man3 55pkgconfigdir = ${libdir}/pkgconfig 56tempfile := $(shell mktemp -u __XXXXXX) 57 58OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o 59OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o 60OBJC = $(OBJZ) $(OBJG) 61 62PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo 63PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo 64PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG) 65 66# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo 67OBJA = 68PIC_OBJA = 69 70OBJS = $(OBJC) $(OBJA) 71 72PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA) 73 74all: static shared all64 75 76static: example$(EXE) minigzip$(EXE) 77 78shared: examplesh$(EXE) minigzipsh$(EXE) 79 80all64: example64$(EXE) minigzip64$(EXE) 81 82check: test 83 84test: all teststatic testshared test64 85 86teststatic: static 87 @if echo hello world | ./minigzip | ./minigzip -d && ./example; then \ 88 echo ' *** zlib test OK ***'; \ 89 else \ 90 echo ' *** zlib test FAILED ***'; false; \ 91 fi 92 -@rm -f foo.gz 93 94testshared: shared 95 @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ 96 LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ 97 DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ 98 SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ 99 if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh; then \ 100 echo ' *** zlib shared test OK ***'; \ 101 else \ 102 echo ' *** zlib shared test FAILED ***'; false; \ 103 fi 104 -@rm -f foo.gz 105 106test64: all64 107 @if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64; then \ 108 echo ' *** zlib 64-bit test OK ***'; \ 109 else \ 110 echo ' *** zlib 64-bit test FAILED ***'; false; \ 111 fi 112 -@rm -f foo.gz 113 114infcover.o: test/infcover.c zlib.h zconf.h 115 $(CC) $(CFLAGS) -I. -c -o $@ test/infcover.c 116 117infcover: infcover.o libz.a 118 $(CC) $(CFLAGS) -o $@ infcover.o libz.a 119 120cover: infcover 121 rm -f *.gcda 122 ./infcover 123 gcov inf*.c 124 125libz.a: $(OBJS) 126 $(AR) $(ARFLAGS) $@ $(OBJS) 127 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 128 129match.o: match.S 130 $(CPP) match.S > _match.s 131 $(CC) -c _match.s 132 mv _match.o match.o 133 rm -f _match.s 134 135match.lo: match.S 136 $(CPP) match.S > _match.s 137 $(CC) -c -fPIC _match.s 138 mv _match.o match.lo 139 rm -f _match.s 140 141example.o: test/example.c zlib.h zconf.h 142 $(CC) $(CFLAGS) -I. -c -o $@ test/example.c 143 144minigzip.o: test/minigzip.c zlib.h zconf.h 145 $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c 146 147example64.o: test/example.c zlib.h zconf.h 148 $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c 149 150minigzip64.o: test/minigzip.c zlib.h zconf.h 151 $(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c 152 153.SUFFIXES: .lo 154 155.c.lo: 156 -@mkdir objs 2>/dev/null || test -d objs 157 $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $< 158 -@mv objs/$*.o $@ 159 160placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a 161 $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) 162 rm -f $(SHAREDLIB) $(SHAREDLIBM) 163 ln -s $@ $(SHAREDLIB) 164 ln -s $@ $(SHAREDLIBM) 165 -@rmdir objs 166 167example$(EXE): example.o $(STATICLIB) 168 $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) 169 170minigzip$(EXE): minigzip.o $(STATICLIB) 171 $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) 172 173examplesh$(EXE): example.o $(SHAREDLIBV) 174 $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV) 175 176minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) 177 $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV) 178 179example64$(EXE): example64.o $(STATICLIB) 180 $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) 181 182minigzip64$(EXE): minigzip64.o $(STATICLIB) 183 $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) 184 185install-libs: $(LIBS) 186 -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi 187 -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi 188 -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi 189 -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi 190 -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi 191 cp $(STATICLIB) $(DESTDIR)$(libdir) 192 chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB) 193 -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1 194 -@if test -n "$(SHAREDLIBV)"; then \ 195 cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \ 196 echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \ 197 chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ 198 echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \ 199 rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ 200 ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \ 201 ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ 202 ($(LDCONFIG) || true) >/dev/null 2>&1; \ 203 fi 204 cp zlib.3 $(DESTDIR)$(man3dir) 205 chmod 644 $(DESTDIR)$(man3dir)/zlib.3 206 cp zlib.pc $(DESTDIR)$(pkgconfigdir) 207 chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc 208# The ranlib in install is needed on NeXTSTEP which checks file times 209# ldconfig is for Linux 210 211install: install-libs 212 -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi 213 cp zlib.h zconf.h $(DESTDIR)$(includedir) 214 chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h 215 216uninstall: 217 cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h 218 cd $(DESTDIR)$(libdir); rm -f libz.a; \ 219 if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ 220 rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ 221 fi 222 cd $(DESTDIR)$(man3dir); rm -f zlib.3 223 cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc 224 225docs: zlib.3.pdf 226 227zlib.3.pdf: zlib.3 228 groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf 229 230zconf.h.cmakein: zconf.h.in 231 -@echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" > $(tempfile) 232 -@sed -f $(tempfile) zconf.h.in > zconf.h.cmakein 233 -@touch -r zconf.h.in zconf.h.cmakein 234 -@rm $(tempfile) 235 236zconf: zconf.h.in 237 cp -p zconf.h.in zconf.h 238 239mostlyclean: clean 240clean: 241 rm -f *.o *.lo *~ \ 242 example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ 243 example64$(EXE) minigzip64$(EXE) \ 244 infcover \ 245 libz.* foo.gz so_locations \ 246 _match.s maketree contrib/infback9/*.o 247 rm -rf objs 248 rm -f *.gcda *.gcno *.gcov 249 rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov 250 251maintainer-clean: distclean 252distclean: clean zconf zconf.h.cmakein docs 253 rm -f Makefile zlib.pc configure.log 254 -@rm -f .DS_Store 255 -@printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile 256 -@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile 257 -@touch -r Makefile.in Makefile 258 259tags: 260 etags *.[ch] 261 262depend: 263 makedepend -- $(CFLAGS) -- *.[ch] 264 265# DO NOT DELETE THIS LINE -- make depend depends on it. 266 267adler32.o zutil.o: zutil.h zlib.h zconf.h 268gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h 269compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h 270crc32.o: zutil.h zlib.h zconf.h crc32.h 271deflate.o: deflate.h zutil.h zlib.h zconf.h 272infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h 273inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 274inftrees.o: zutil.h zlib.h zconf.h inftrees.h 275trees.o: deflate.h zutil.h zlib.h zconf.h trees.h 276 277adler32.lo zutil.lo: zutil.h zlib.h zconf.h 278gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h 279compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h 280crc32.lo: zutil.h zlib.h zconf.h crc32.h 281deflate.lo: deflate.h zutil.h zlib.h zconf.h 282infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h 283inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 284inftrees.lo: zutil.h zlib.h zconf.h inftrees.h 285trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h 286