kusano fc6ab3
# Makefile for zlib
kusano fc6ab3
# Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler
kusano fc6ab3
# For conditions of distribution and use, see copyright notice in zlib.h
kusano fc6ab3
kusano fc6ab3
# To compile and test, type:
kusano fc6ab3
#    ./configure; make test
kusano fc6ab3
# Normally configure builds both a static and a shared library.
kusano fc6ab3
# If you want to build just a static library, use: ./configure --static
kusano fc6ab3
kusano fc6ab3
# To use the asm code, type:
kusano fc6ab3
#    cp contrib/asm?86/match.S ./match.S
kusano fc6ab3
#    make LOC=-DASMV OBJA=match.o
kusano fc6ab3
kusano fc6ab3
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
kusano fc6ab3
#    make install
kusano fc6ab3
# To install in $HOME instead of /usr/local, use:
kusano fc6ab3
#    make install prefix=$HOME
kusano fc6ab3
kusano fc6ab3
CC=cc
kusano fc6ab3
kusano fc6ab3
CFLAGS=-O
kusano fc6ab3
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
kusano fc6ab3
#CFLAGS=-g -DDEBUG
kusano fc6ab3
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
kusano fc6ab3
#           -Wstrict-prototypes -Wmissing-prototypes
kusano fc6ab3
kusano fc6ab3
SFLAGS=-O
kusano fc6ab3
LDFLAGS=
kusano fc6ab3
TEST_LDFLAGS=-L. libz.a
kusano fc6ab3
LDSHARED=$(CC)
kusano fc6ab3
CPP=$(CC) -E
kusano fc6ab3
kusano fc6ab3
STATICLIB=libz.a
kusano fc6ab3
SHAREDLIB=libz.so
kusano fc6ab3
SHAREDLIBV=libz.so.1.2.8
kusano fc6ab3
SHAREDLIBM=libz.so.1
kusano fc6ab3
LIBS=$(STATICLIB) $(SHAREDLIBV)
kusano fc6ab3
kusano fc6ab3
AR=ar
kusano fc6ab3
ARFLAGS=rc
kusano fc6ab3
RANLIB=ranlib
kusano fc6ab3
LDCONFIG=ldconfig
kusano fc6ab3
LDSHAREDLIBC=-lc
kusano fc6ab3
TAR=tar
kusano fc6ab3
SHELL=/bin/sh
kusano fc6ab3
EXE=
kusano fc6ab3
kusano fc6ab3
prefix = /usr/local
kusano fc6ab3
exec_prefix = ${prefix}
kusano fc6ab3
libdir = ${exec_prefix}/lib
kusano fc6ab3
sharedlibdir = ${libdir}
kusano fc6ab3
includedir = ${prefix}/include
kusano fc6ab3
mandir = ${prefix}/share/man
kusano fc6ab3
man3dir = ${mandir}/man3
kusano fc6ab3
pkgconfigdir = ${libdir}/pkgconfig
kusano fc6ab3
kusano fc6ab3
OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
kusano fc6ab3
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
kusano fc6ab3
OBJC = $(OBJZ) $(OBJG)
kusano fc6ab3
kusano fc6ab3
PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
kusano fc6ab3
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
kusano fc6ab3
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
kusano fc6ab3
kusano fc6ab3
# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
kusano fc6ab3
OBJA =
kusano fc6ab3
PIC_OBJA =
kusano fc6ab3
kusano fc6ab3
OBJS = $(OBJC) $(OBJA)
kusano fc6ab3
kusano fc6ab3
PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
kusano fc6ab3
kusano fc6ab3
all: static shared
kusano fc6ab3
kusano fc6ab3
static: example$(EXE) minigzip$(EXE)
kusano fc6ab3
kusano fc6ab3
shared: examplesh$(EXE) minigzipsh$(EXE)
kusano fc6ab3
kusano fc6ab3
all64: example64$(EXE) minigzip64$(EXE)
kusano fc6ab3
kusano fc6ab3
check: test
kusano fc6ab3
kusano fc6ab3
test: all teststatic testshared
kusano fc6ab3
kusano fc6ab3
teststatic: static
kusano fc6ab3
	@TMPST=tmpst_$$; \
kusano fc6ab3
	if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \
kusano fc6ab3
	  echo '		*** zlib test OK ***'; \
kusano fc6ab3
	else \
kusano fc6ab3
	  echo '		*** zlib test FAILED ***'; false; \
kusano fc6ab3
	fi; \
kusano fc6ab3
	rm -f $$TMPST
kusano fc6ab3
kusano fc6ab3
testshared: shared
kusano fc6ab3
	@LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
kusano fc6ab3
	LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
kusano fc6ab3
	DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
kusano fc6ab3
	SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
kusano fc6ab3
	TMPSH=tmpsh_$$; \
kusano fc6ab3
	if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \
kusano fc6ab3
	  echo '		*** zlib shared test OK ***'; \
kusano fc6ab3
	else \
kusano fc6ab3
	  echo '		*** zlib shared test FAILED ***'; false; \
kusano fc6ab3
	fi; \
kusano fc6ab3
	rm -f $$TMPSH
kusano fc6ab3
kusano fc6ab3
test64: all64
kusano fc6ab3
	@TMP64=tmp64_$$; \
kusano fc6ab3
	if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \
kusano fc6ab3
	  echo '		*** zlib 64-bit test OK ***'; \
kusano fc6ab3
	else \
kusano fc6ab3
	  echo '		*** zlib 64-bit test FAILED ***'; false; \
kusano fc6ab3
	fi; \
kusano fc6ab3
	rm -f $$TMP64
kusano fc6ab3
kusano fc6ab3
infcover.o: test/infcover.c zlib.h zconf.h
kusano fc6ab3
	$(CC) $(CFLAGS) -I. -c -o $@ test/infcover.c
kusano fc6ab3
kusano fc6ab3
infcover: infcover.o libz.a
kusano fc6ab3
	$(CC) $(CFLAGS) -o $@ infcover.o libz.a
kusano fc6ab3
kusano fc6ab3
cover: infcover
kusano fc6ab3
	rm -f *.gcda
kusano fc6ab3
	./infcover
kusano fc6ab3
	gcov inf*.c
kusano fc6ab3
kusano fc6ab3
libz.a: $(OBJS)
kusano fc6ab3
	$(AR) $(ARFLAGS) $@ $(OBJS)
kusano fc6ab3
	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
kusano fc6ab3
kusano fc6ab3
match.o: match.S
kusano fc6ab3
	$(CPP) match.S > _match.s
kusano fc6ab3
	$(CC) -c _match.s
kusano fc6ab3
	mv _match.o match.o
kusano fc6ab3
	rm -f _match.s
kusano fc6ab3
kusano fc6ab3
match.lo: match.S
kusano fc6ab3
	$(CPP) match.S > _match.s
kusano fc6ab3
	$(CC) -c -fPIC _match.s
kusano fc6ab3
	mv _match.o match.lo
kusano fc6ab3
	rm -f _match.s
kusano fc6ab3
kusano fc6ab3
example.o: test/example.c zlib.h zconf.h
kusano fc6ab3
	$(CC) $(CFLAGS) -I. -c -o $@ test/example.c
kusano fc6ab3
kusano fc6ab3
minigzip.o: test/minigzip.c zlib.h zconf.h
kusano fc6ab3
	$(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
kusano fc6ab3
kusano fc6ab3
example64.o: test/example.c zlib.h zconf.h
kusano fc6ab3
	$(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/example.c
kusano fc6ab3
kusano fc6ab3
minigzip64.o: test/minigzip.c zlib.h zconf.h
kusano fc6ab3
	$(CC) $(CFLAGS) -I. -D_FILE_OFFSET_BITS=64 -c -o $@ test/minigzip.c
kusano fc6ab3
kusano fc6ab3
.SUFFIXES: .lo
kusano fc6ab3
kusano fc6ab3
.c.lo:
kusano fc6ab3
	-@mkdir objs 2>/dev/null || test -d objs
kusano fc6ab3
	$(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
kusano fc6ab3
	-@mv objs/$*.o $@
kusano fc6ab3
kusano fc6ab3
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
kusano fc6ab3
	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
kusano fc6ab3
	rm -f $(SHAREDLIB) $(SHAREDLIBM)
kusano fc6ab3
	ln -s $@ $(SHAREDLIB)
kusano fc6ab3
	ln -s $@ $(SHAREDLIBM)
kusano fc6ab3
	-@rmdir objs
kusano fc6ab3
kusano fc6ab3
example$(EXE): example.o $(STATICLIB)
kusano fc6ab3
	$(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
kusano fc6ab3
kusano fc6ab3
minigzip$(EXE): minigzip.o $(STATICLIB)
kusano fc6ab3
	$(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
kusano fc6ab3
kusano fc6ab3
examplesh$(EXE): example.o $(SHAREDLIBV)
kusano fc6ab3
	$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
kusano fc6ab3
kusano fc6ab3
minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
kusano fc6ab3
	$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
kusano fc6ab3
kusano fc6ab3
example64$(EXE): example64.o $(STATICLIB)
kusano fc6ab3
	$(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
kusano fc6ab3
kusano fc6ab3
minigzip64$(EXE): minigzip64.o $(STATICLIB)
kusano fc6ab3
	$(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
kusano fc6ab3
kusano fc6ab3
install-libs: $(LIBS)
kusano fc6ab3
	-@if [ ! -d $(DESTDIR)$(exec_prefix)  ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
kusano fc6ab3
	-@if [ ! -d $(DESTDIR)$(libdir)       ]; then mkdir -p $(DESTDIR)$(libdir); fi
kusano fc6ab3
	-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
kusano fc6ab3
	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
kusano fc6ab3
	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
kusano fc6ab3
	cp $(STATICLIB) $(DESTDIR)$(libdir)
kusano fc6ab3
	chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
kusano fc6ab3
	-@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
kusano fc6ab3
	-@if test -n "$(SHAREDLIBV)"; then \
kusano fc6ab3
	  cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
kusano fc6ab3
	  echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
kusano fc6ab3
	  chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
kusano fc6ab3
	  echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
kusano fc6ab3
	  rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
kusano fc6ab3
	  ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
kusano fc6ab3
	  ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
kusano fc6ab3
	  ($(LDCONFIG) || true)  >/dev/null 2>&1; \
kusano fc6ab3
	fi
kusano fc6ab3
	cp zlib.3 $(DESTDIR)$(man3dir)
kusano fc6ab3
	chmod 644 $(DESTDIR)$(man3dir)/zlib.3
kusano fc6ab3
	cp zlib.pc $(DESTDIR)$(pkgconfigdir)
kusano fc6ab3
	chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
kusano fc6ab3
# The ranlib in install is needed on NeXTSTEP which checks file times
kusano fc6ab3
# ldconfig is for Linux
kusano fc6ab3
kusano fc6ab3
install: install-libs
kusano fc6ab3
	-@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
kusano fc6ab3
	cp zlib.h zconf.h $(DESTDIR)$(includedir)
kusano fc6ab3
	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
kusano fc6ab3
kusano fc6ab3
uninstall:
kusano fc6ab3
	cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h
kusano fc6ab3
	cd $(DESTDIR)$(libdir) && rm -f libz.a; \
kusano fc6ab3
	if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
kusano fc6ab3
	  rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
kusano fc6ab3
	fi
kusano fc6ab3
	cd $(DESTDIR)$(man3dir) && rm -f zlib.3
kusano fc6ab3
	cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc
kusano fc6ab3
kusano fc6ab3
docs: zlib.3.pdf
kusano fc6ab3
kusano fc6ab3
zlib.3.pdf: zlib.3
kusano fc6ab3
	groff -mandoc -f H -T ps zlib.3 | ps2pdf - zlib.3.pdf
kusano fc6ab3
kusano fc6ab3
zconf.h.cmakein: zconf.h.in
kusano fc6ab3
	-@ TEMPFILE=zconfh_$$; \
kusano fc6ab3
	echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
kusano fc6ab3
	sed -f $$TEMPFILE zconf.h.in > zconf.h.cmakein &&\
kusano fc6ab3
	touch -r zconf.h.in zconf.h.cmakein &&\
kusano fc6ab3
	rm $$TEMPFILE
kusano fc6ab3
kusano fc6ab3
zconf: zconf.h.in
kusano fc6ab3
	cp -p zconf.h.in zconf.h
kusano fc6ab3
kusano fc6ab3
mostlyclean: clean
kusano fc6ab3
clean:
kusano fc6ab3
	rm -f *.o *.lo *~ \
kusano fc6ab3
	   example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
kusano fc6ab3
	   example64$(EXE) minigzip64$(EXE) \
kusano fc6ab3
	   infcover \
kusano fc6ab3
	   libz.* foo.gz so_locations \
kusano fc6ab3
	   _match.s maketree contrib/infback9/*.o
kusano fc6ab3
	rm -rf objs
kusano fc6ab3
	rm -f *.gcda *.gcno *.gcov
kusano fc6ab3
	rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
kusano fc6ab3
kusano fc6ab3
maintainer-clean: distclean
kusano fc6ab3
distclean: clean zconf zconf.h.cmakein docs
kusano fc6ab3
	rm -f Makefile zlib.pc configure.log
kusano fc6ab3
	-@rm -f .DS_Store
kusano fc6ab3
	-@printf 'all:\n\t-@echo "Please use ./configure first.  Thank you."\n' > Makefile
kusano fc6ab3
	-@printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile
kusano fc6ab3
	-@touch -r Makefile.in Makefile
kusano fc6ab3
kusano fc6ab3
tags:
kusano fc6ab3
	etags *.[ch]
kusano fc6ab3
kusano fc6ab3
depend:
kusano fc6ab3
	makedepend -- $(CFLAGS) -- *.[ch]
kusano fc6ab3
kusano fc6ab3
# DO NOT DELETE THIS LINE -- make depend depends on it.
kusano fc6ab3
kusano fc6ab3
adler32.o zutil.o: zutil.h zlib.h zconf.h
kusano fc6ab3
gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
kusano fc6ab3
compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
kusano fc6ab3
crc32.o: zutil.h zlib.h zconf.h crc32.h
kusano fc6ab3
deflate.o: deflate.h zutil.h zlib.h zconf.h
kusano fc6ab3
infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
kusano fc6ab3
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
kusano fc6ab3
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
kusano fc6ab3
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
kusano fc6ab3
kusano fc6ab3
adler32.lo zutil.lo: zutil.h zlib.h zconf.h
kusano fc6ab3
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h
kusano fc6ab3
compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h
kusano fc6ab3
crc32.lo: zutil.h zlib.h zconf.h crc32.h
kusano fc6ab3
deflate.lo: deflate.h zutil.h zlib.h zconf.h
kusano fc6ab3
infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
kusano fc6ab3
inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
kusano fc6ab3
inftrees.lo: zutil.h zlib.h zconf.h inftrees.h
kusano fc6ab3
trees.lo: deflate.h zutil.h zlib.h zconf.h trees.h