zlib/win32/Makefile.gcc

178 lines
4.9 KiB
Makefile
Raw Normal View History

2011-09-10 02:21:57 -04:00
# Makefile for zlib, derived from Makefile.dj2.
# Modified for mingw32 by C. Spieler, 6/16/98.
2011-09-10 02:22:37 -04:00
# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003.
# Last updated: Mar 2012.
2011-09-10 02:21:57 -04:00
# Tested under Cygwin and MinGW.
2011-09-10 02:22:37 -04:00
# Copyright (C) 1995-2003 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
2011-09-10 02:21:57 -04:00
# To compile, or to compile and test, type from the top level zlib directory:
2011-09-10 02:22:37 -04:00
#
# make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc
2011-09-10 02:22:37 -04:00
#
2011-09-10 02:21:57 -04:00
# To install libz.a, zconf.h and zlib.h in the system directories, type:
2011-09-10 02:22:37 -04:00
#
# make install -fwin32/Makefile.gcc
#
# BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set.
#
# To install the shared lib, append SHARED_MODE=1 to the make command :
#
# make install -fwin32/Makefile.gcc SHARED_MODE=1
2011-09-10 02:21:57 -04:00
2011-09-10 02:22:37 -04:00
# Note:
# If the platform is *not* MinGW (e.g. it is Cygwin or UWIN),
# the DLL name should be changed from "zlib1.dll".
STATICLIB = libz.a
SHAREDLIB = zlib1.dll
2011-09-11 14:04:49 -04:00
IMPLIB = libz.dll.a
2011-09-10 02:22:37 -04:00
2011-09-10 02:34:45 -04:00
#
# Set to 1 if shared object needs to be installed
#
SHARED_MODE=0
#LOC = -DZLIB_DEBUG -g
2011-09-10 02:21:57 -04:00
2011-09-10 02:34:22 -04:00
PREFIX =
CC = $(PREFIX)gcc
2011-09-10 02:21:57 -04:00
CFLAGS = $(LOC) -O3 -Wall
AS = $(CC)
ASFLAGS = $(LOC) -Wall
LD = $(CC)
2011-09-10 02:34:45 -04:00
LDFLAGS = $(LOC)
2011-09-10 02:21:57 -04:00
2011-09-10 02:34:22 -04:00
AR = $(PREFIX)ar
2011-09-10 02:21:57 -04:00
ARFLAGS = rcs
2011-09-10 02:34:22 -04:00
RC = $(PREFIX)windres
2011-09-10 02:22:37 -04:00
RCFLAGS = --define GCC_WINDRES
2011-09-10 02:22:10 -04:00
2011-09-10 02:34:22 -04:00
STRIP = $(PREFIX)strip
2011-09-10 02:26:49 -04:00
2011-09-10 02:21:57 -04:00
CP = cp -fp
# If GNU install is available, replace $(CP) with install.
INSTALL = $(CP)
RM = rm -f
2011-09-11 14:04:49 -04:00
prefix ?= /usr/local
2011-09-10 02:21:57 -04:00
exec_prefix = $(prefix)
2011-09-10 02:27:26 -04:00
OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
2011-09-10 02:26:49 -04:00
gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
2011-09-10 02:21:57 -04:00
OBJA =
2011-09-10 02:26:49 -04:00
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe
2011-09-10 02:21:57 -04:00
2011-09-10 02:26:49 -04:00
test: example.exe minigzip.exe
2011-09-10 02:21:57 -04:00
./example
2011-09-10 02:22:37 -04:00
echo hello world | ./minigzip | ./minigzip -d
2011-09-10 02:26:49 -04:00
testdll: example_d.exe minigzip_d.exe
2011-09-10 02:22:37 -04:00
./example_d
echo hello world | ./minigzip_d | ./minigzip_d -d
2011-09-10 02:21:57 -04:00
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
2011-09-10 02:21:57 -04:00
2011-09-10 02:22:37 -04:00
.S.o:
$(AS) $(ASFLAGS) -c -o $@ $<
$(STATICLIB): $(OBJS) $(OBJA)
$(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA)
$(IMPLIB): $(SHAREDLIB)
$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
2011-09-10 02:34:45 -04:00
$(CC) -shared -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \
2011-09-10 02:26:49 -04:00
-o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
$(STRIP) $@
2011-09-10 02:22:37 -04:00
2011-09-10 02:26:49 -04:00
example.exe: example.o $(STATICLIB)
2011-09-10 02:22:37 -04:00
$(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB)
2011-09-10 02:34:45 -04:00
$(STRIP) $@
2011-09-10 02:21:57 -04:00
2011-09-10 02:26:49 -04:00
minigzip.exe: minigzip.o $(STATICLIB)
2011-09-10 02:22:37 -04:00
$(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB)
2011-09-10 02:34:45 -04:00
$(STRIP) $@
2011-09-10 02:22:10 -04:00
2011-09-10 02:26:49 -04:00
example_d.exe: example.o $(IMPLIB)
2011-09-10 02:22:37 -04:00
$(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB)
2011-09-10 02:34:45 -04:00
$(STRIP) $@
2011-09-10 02:21:57 -04:00
2011-09-10 02:26:49 -04:00
minigzip_d.exe: minigzip.o $(IMPLIB)
2011-09-10 02:22:37 -04:00
$(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB)
2011-09-10 02:34:45 -04:00
$(STRIP) $@
2011-09-10 02:21:57 -04:00
example.o: test/example.c zlib.h zconf.h
$(CC) $(CFLAGS) -I. -c -o $@ test/example.c
minigzip.o: test/minigzip.c zlib.h zconf.h
$(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c
2011-09-10 02:22:37 -04:00
zlibrc.o: win32/zlib1.rc
$(RC) $(RCFLAGS) -o $@ win32/zlib1.rc
2011-09-10 02:22:10 -04:00
2011-09-10 02:22:37 -04:00
.PHONY: install uninstall clean
2011-09-10 02:21:57 -04:00
2011-09-10 02:34:45 -04:00
install: zlib.h zconf.h $(STATICLIB) $(IMPLIB)
@if test -z "$(DESTDIR)$(INCLUDE_PATH)" -o -z "$(DESTDIR)$(LIBRARY_PATH)" -o -z "$(DESTDIR)$(BINARY_PATH)"; then \
echo INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH must be specified; \
exit 1; \
fi
-@mkdir -p '$(DESTDIR)$(INCLUDE_PATH)'
-@mkdir -p '$(DESTDIR)$(LIBRARY_PATH)' '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig
2011-09-10 02:34:45 -04:00
-if [ "$(SHARED_MODE)" = "1" ]; then \
mkdir -p '$(DESTDIR)$(BINARY_PATH)'; \
$(INSTALL) $(SHAREDLIB) '$(DESTDIR)$(BINARY_PATH)'; \
$(INSTALL) $(IMPLIB) '$(DESTDIR)$(LIBRARY_PATH)'; \
2011-09-10 02:34:45 -04:00
fi
-$(INSTALL) zlib.h '$(DESTDIR)$(INCLUDE_PATH)'
-$(INSTALL) zconf.h '$(DESTDIR)$(INCLUDE_PATH)'
-$(INSTALL) $(STATICLIB) '$(DESTDIR)$(LIBRARY_PATH)'
2011-09-11 14:04:49 -04:00
sed \
-e 's|@prefix@|${prefix}|g' \
-e 's|@exec_prefix@|${exec_prefix}|g' \
-e 's|@libdir@|$(LIBRARY_PATH)|g' \
-e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \
-e 's|@includedir@|$(INCLUDE_PATH)|g' \
-e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \
zlib.pc.in > '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig/zlib.pc
2011-09-10 02:21:57 -04:00
uninstall:
2011-09-10 02:34:45 -04:00
-if [ "$(SHARED_MODE)" = "1" ]; then \
$(RM) '$(DESTDIR)$(BINARY_PATH)'/$(SHAREDLIB); \
$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(IMPLIB); \
2011-09-10 02:34:45 -04:00
fi
-$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zlib.h
-$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zconf.h
-$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(STATICLIB)
2011-09-10 02:21:57 -04:00
clean:
2011-09-10 02:22:37 -04:00
-$(RM) $(STATICLIB)
-$(RM) $(SHAREDLIB)
-$(RM) $(IMPLIB)
-$(RM) *.o
-$(RM) *.exe
-$(RM) foo.gz
2011-09-10 02:21:57 -04:00
adler32.o: zlib.h zconf.h
compress.o: zlib.h zconf.h
crc32.o: crc32.h zlib.h zconf.h
deflate.o: deflate.h zutil.h zlib.h zconf.h
2011-09-10 02:26:49 -04:00
gzclose.o: zlib.h zconf.h gzguts.h
gzlib.o: zlib.h zconf.h gzguts.h
gzread.o: zlib.h zconf.h gzguts.h
gzwrite.o: zlib.h zconf.h gzguts.h
2011-09-10 02:21:57 -04:00
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
uncompr.o: zlib.h zconf.h
2011-09-10 02:22:37 -04:00
zutil.o: zutil.h zlib.h zconf.h