1# Makefile for zlib, derived from Makefile.dj2. 2# Modified for mingw32 by C. Spieler, 6/16/98. 3# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. 4# Last updated: Mar 2012. 5# Tested under Cygwin and MinGW. 6 7# Copyright (C) 1995-2003 Jean-loup Gailly. 8# For conditions of distribution and use, see copyright notice in zlib.h 9 10# To compile, or to compile and test, type from the top level zlib directory: 11# 12# make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc 13# 14# To install libz.a, zconf.h and zlib.h in the system directories, type: 15# 16# make install -fwin32/Makefile.gcc 17# 18# BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set. 19# 20# To install the shared lib, append SHARED_MODE=1 to the make command : 21# 22# make install -fwin32/Makefile.gcc SHARED_MODE=1 23 24# Note: 25# If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), 26# the DLL name should be changed from "zlib1.dll". 27 28STATICLIB = libz.a 29SHAREDLIB = zlib1.dll 30IMPLIB = libz.dll.a 31 32# 33# Set to 1 if shared object needs to be installed 34# 35SHARED_MODE=0 36 37#LOC = -DZLIB_DEBUG -g 38 39PREFIX = 40CC = $(PREFIX)gcc 41CFLAGS = $(LOC) -O3 -Wall 42 43AS = $(CC) 44ASFLAGS = $(LOC) -Wall 45 46LD = $(CC) 47LDFLAGS = $(LOC) 48 49AR = $(PREFIX)ar 50ARFLAGS = rcs 51 52RC = $(PREFIX)windres 53RCFLAGS = --define GCC_WINDRES 54 55STRIP = $(PREFIX)strip 56 57CP = cp -fp 58# If GNU install is available, replace $(CP) with install. 59INSTALL = $(CP) 60RM = rm -f 61 62prefix ?= /usr/local 63exec_prefix = $(prefix) 64 65OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ 66 gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o 67OBJA = 68 69all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe 70 71test: example.exe minigzip.exe 72 ./example 73 echo hello world | ./minigzip | ./minigzip -d 74 75testdll: example_d.exe minigzip_d.exe 76 ./example_d 77 echo hello world | ./minigzip_d | ./minigzip_d -d 78 79.c.o: 80 $(CC) $(CFLAGS) -c -o $@ $< 81 82.S.o: 83 $(AS) $(ASFLAGS) -c -o $@ $< 84 85$(STATICLIB): $(OBJS) $(OBJA) 86 $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) 87 88$(IMPLIB): $(SHAREDLIB) 89 90$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o 91 $(CC) -shared -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \ 92 -o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o 93 $(STRIP) $@ 94 95example.exe: example.o $(STATICLIB) 96 $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) 97 $(STRIP) $@ 98 99minigzip.exe: minigzip.o $(STATICLIB) 100 $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) 101 $(STRIP) $@ 102 103example_d.exe: example.o $(IMPLIB) 104 $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) 105 $(STRIP) $@ 106 107minigzip_d.exe: minigzip.o $(IMPLIB) 108 $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) 109 $(STRIP) $@ 110 111example.o: test/example.c zlib.h zconf.h 112 $(CC) $(CFLAGS) -I. -c -o $@ test/example.c 113 114minigzip.o: test/minigzip.c zlib.h zconf.h 115 $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c 116 117zlibrc.o: win32/zlib1.rc 118 $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc 119 120.PHONY: install uninstall clean 121 122install: zlib.h zconf.h $(STATICLIB) $(IMPLIB) 123 @if test -z "$(DESTDIR)$(INCLUDE_PATH)" -o -z "$(DESTDIR)$(LIBRARY_PATH)" -o -z "$(DESTDIR)$(BINARY_PATH)"; then \ 124 echo INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH must be specified; \ 125 exit 1; \ 126 fi 127 -@mkdir -p '$(DESTDIR)$(INCLUDE_PATH)' 128 -@mkdir -p '$(DESTDIR)$(LIBRARY_PATH)' '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig 129 -if [ "$(SHARED_MODE)" = "1" ]; then \ 130 mkdir -p '$(DESTDIR)$(BINARY_PATH)'; \ 131 $(INSTALL) $(SHAREDLIB) '$(DESTDIR)$(BINARY_PATH)'; \ 132 $(INSTALL) $(IMPLIB) '$(DESTDIR)$(LIBRARY_PATH)'; \ 133 fi 134 -$(INSTALL) zlib.h '$(DESTDIR)$(INCLUDE_PATH)' 135 -$(INSTALL) zconf.h '$(DESTDIR)$(INCLUDE_PATH)' 136 -$(INSTALL) $(STATICLIB) '$(DESTDIR)$(LIBRARY_PATH)' 137 sed \ 138 -e 's|@prefix@|${prefix}|g' \ 139 -e 's|@exec_prefix@|${exec_prefix}|g' \ 140 -e 's|@libdir@|$(LIBRARY_PATH)|g' \ 141 -e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \ 142 -e 's|@includedir@|$(INCLUDE_PATH)|g' \ 143 -e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \ 144 zlib.pc.in > '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig/zlib.pc 145 146uninstall: 147 -if [ "$(SHARED_MODE)" = "1" ]; then \ 148 $(RM) '$(DESTDIR)$(BINARY_PATH)'/$(SHAREDLIB); \ 149 $(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(IMPLIB); \ 150 fi 151 -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zlib.h 152 -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zconf.h 153 -$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(STATICLIB) 154 155clean: 156 -$(RM) $(STATICLIB) 157 -$(RM) $(SHAREDLIB) 158 -$(RM) $(IMPLIB) 159 -$(RM) *.o 160 -$(RM) *.exe 161 -$(RM) foo.gz 162 163adler32.o: zlib.h zconf.h 164compress.o: zlib.h zconf.h 165crc32.o: crc32.h zlib.h zconf.h 166deflate.o: deflate.h zutil.h zlib.h zconf.h 167gzclose.o: zlib.h zconf.h gzguts.h 168gzlib.o: zlib.h zconf.h gzguts.h 169gzread.o: zlib.h zconf.h gzguts.h 170gzwrite.o: zlib.h zconf.h gzguts.h 171inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 172inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 173infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 174inftrees.o: zutil.h zlib.h zconf.h inftrees.h 175trees.o: deflate.h zutil.h zlib.h zconf.h trees.h 176uncompr.o: zlib.h zconf.h 177zutil.o: zutil.h zlib.h zconf.h 178