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.
7 # Copyright (C) 1995-2003 Jean-loup Gailly.
8 # For conditions of distribution and use, see copyright notice in zlib.h
10 # To compile, or to compile and test, type from the top level zlib directory:
12 # make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc
14 # To install libz.a, zconf.h and zlib.h in the system directories, type:
16 # make install -fwin32/Makefile.gcc
18 # BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set.
20 # To install the shared lib, append SHARED_MODE=1 to the make command :
22 # make install -fwin32/Makefile.gcc SHARED_MODE=1
25 # If the platform is *not* MinGW (e.g. it is Cygwin or UWIN),
26 # the DLL name should be changed from "zlib1.dll".
33 # Set to 1 if shared object needs to be installed
37 #LOC = -DZLIB_DEBUG -g
41 CFLAGS = $(LOC) -O3 -Wall
44 ASFLAGS = $(LOC) -Wall
53 RCFLAGS = --define GCC_WINDRES
55 STRIP = $(PREFIX)strip
58 # If GNU install is available, replace $(CP) with install.
63 exec_prefix = $(prefix)
65 OBJS = 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
69 all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe
71 test: example.exe minigzip.exe
73 echo hello world | ./minigzip | ./minigzip -d
75 testdll: example_d.exe minigzip_d.exe
77 echo hello world | ./minigzip_d | ./minigzip_d -d
80 $(CC) $(CFLAGS) -c -o $@ $<
83 $(AS) $(ASFLAGS) -c -o $@ $<
85 $(STATICLIB): $(OBJS) $(OBJA)
86 $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA)
88 $(IMPLIB): $(SHAREDLIB)
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
95 example.exe: example.o $(STATICLIB)
96 $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB)
99 minigzip.exe: minigzip.o $(STATICLIB)
100 $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB)
103 example_d.exe: example.o $(IMPLIB)
104 $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB)
107 minigzip_d.exe: minigzip.o $(IMPLIB)
108 $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB)
111 example.o: test/example.c zlib.h zconf.h
112 $(CC) $(CFLAGS) -I. -c -o $@ test/example.c
114 minigzip.o: test/minigzip.c zlib.h zconf.h
115 $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
117 zlibrc.o: win32/zlib1.rc
118 $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc
120 .PHONY: install uninstall clean
122 install: 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; \
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)'; \
134 -$(INSTALL) zlib.h '$(DESTDIR)$(INCLUDE_PATH)'
135 -$(INSTALL) zconf.h '$(DESTDIR)$(INCLUDE_PATH)'
136 -$(INSTALL) $(STATICLIB) '$(DESTDIR)$(LIBRARY_PATH)'
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
147 -if [ "$(SHARED_MODE)" = "1" ]; then \
148 $(RM) '$(DESTDIR)$(BINARY_PATH)'/$(SHAREDLIB); \
149 $(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(IMPLIB); \
151 -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zlib.h
152 -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zconf.h
153 -$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(STATICLIB)
163 adler32.o: zlib.h zconf.h
164 compress.o: zlib.h zconf.h
165 crc32.o: crc32.h zlib.h zconf.h
166 deflate.o: deflate.h zutil.h zlib.h zconf.h
167 gzclose.o: zlib.h zconf.h gzguts.h
168 gzlib.o: zlib.h zconf.h gzguts.h
169 gzread.o: zlib.h zconf.h gzguts.h
170 gzwrite.o: zlib.h zconf.h gzguts.h
171 inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
172 inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
173 infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
174 inftrees.o: zutil.h zlib.h zconf.h inftrees.h
175 trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
176 uncompr.o: zlib.h zconf.h
177 zutil.o: zutil.h zlib.h zconf.h