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 use the asm code, type:
15 # cp contrib/asm?86/match.S ./match.S
16 # make LOC=-DASMV OBJA=match.o -fwin32/Makefile.gcc
18 # To install libz.a, zconf.h and zlib.h in the system directories, type:
20 # make install -fwin32/Makefile.gcc
22 # BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set.
24 # To install the shared lib, append SHARED_MODE=1 to the make command :
26 # make install -fwin32/Makefile.gcc SHARED_MODE=1
29 # If the platform is *not* MinGW (e.g. it is Cygwin or UWIN),
30 # the DLL name should be changed from "zlib1.dll".
37 # Set to 1 if shared object needs to be installed
46 CFLAGS = $(LOC) -O3 -Wall
49 ASFLAGS = $(LOC) -Wall
58 RCFLAGS = --define GCC_WINDRES
60 STRIP = $(PREFIX)strip
63 # If GNU install is available, replace $(CP) with install.
68 exec_prefix = $(prefix)
70 OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
71 gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
74 all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe
76 test: example.exe minigzip.exe
78 echo hello world | ./minigzip | ./minigzip -d
80 testdll: example_d.exe minigzip_d.exe
82 echo hello world | ./minigzip_d | ./minigzip_d -d
85 $(CC) $(CFLAGS) -c -o $@ $<
88 $(AS) $(ASFLAGS) -c -o $@ $<
90 $(STATICLIB): $(OBJS) $(OBJA)
91 $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA)
93 $(IMPLIB): $(SHAREDLIB)
95 $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
96 $(CC) -shared -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \
97 -o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
100 example.exe: example.o $(STATICLIB)
101 $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB)
104 minigzip.exe: minigzip.o $(STATICLIB)
105 $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB)
108 example_d.exe: example.o $(IMPLIB)
109 $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB)
112 minigzip_d.exe: minigzip.o $(IMPLIB)
113 $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB)
116 example.o: test/example.c zlib.h zconf.h
117 $(CC) $(CFLAGS) -I. -c -o $@ test/example.c
119 minigzip.o: test/minigzip.c zlib.h zconf.h
120 $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
122 zlibrc.o: win32/zlib1.rc
123 $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc
125 .PHONY: install uninstall clean
127 install: zlib.h zconf.h $(STATICLIB) $(IMPLIB)
128 @if test -z "$(DESTDIR)$(INCLUDE_PATH)" -o -z "$(DESTDIR)$(LIBRARY_PATH)" -o -z "$(DESTDIR)$(BINARY_PATH)"; then \
129 echo INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH must be specified; \
132 -@mkdir -p '$(DESTDIR)$(INCLUDE_PATH)'
133 -@mkdir -p '$(DESTDIR)$(LIBRARY_PATH)' '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig
134 -if [ "$(SHARED_MODE)" = "1" ]; then \
135 mkdir -p '$(DESTDIR)$(BINARY_PATH)'; \
136 $(INSTALL) $(SHAREDLIB) '$(DESTDIR)$(BINARY_PATH)'; \
137 $(INSTALL) $(IMPLIB) '$(DESTDIR)$(LIBRARY_PATH)'; \
139 -$(INSTALL) zlib.h '$(DESTDIR)$(INCLUDE_PATH)'
140 -$(INSTALL) zconf.h '$(DESTDIR)$(INCLUDE_PATH)'
141 -$(INSTALL) $(STATICLIB) '$(DESTDIR)$(LIBRARY_PATH)'
143 -e 's|@prefix@|${prefix}|g' \
144 -e 's|@exec_prefix@|${exec_prefix}|g' \
145 -e 's|@libdir@|$(LIBRARY_PATH)|g' \
146 -e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \
147 -e 's|@includedir@|$(INCLUDE_PATH)|g' \
148 -e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \
149 zlib.pc.in > '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig/zlib.pc
152 -if [ "$(SHARED_MODE)" = "1" ]; then \
153 $(RM) '$(DESTDIR)$(BINARY_PATH)'/$(SHAREDLIB); \
154 $(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(IMPLIB); \
156 -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zlib.h
157 -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zconf.h
158 -$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(STATICLIB)
168 adler32.o: zlib.h zconf.h
169 compress.o: zlib.h zconf.h
170 crc32.o: crc32.h zlib.h zconf.h
171 deflate.o: deflate.h zutil.h zlib.h zconf.h
172 gzclose.o: zlib.h zconf.h gzguts.h
173 gzlib.o: zlib.h zconf.h gzguts.h
174 gzread.o: zlib.h zconf.h gzguts.h
175 gzwrite.o: zlib.h zconf.h gzguts.h
176 inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
177 inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
178 infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
179 inftrees.o: zutil.h zlib.h zconf.h inftrees.h
180 trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
181 uncompr.o: zlib.h zconf.h
182 zutil.o: zutil.h zlib.h zconf.h