Makefile.gcc 3.6 KB
Newer Older
M
Mark Adler 已提交
1 2
# Makefile for zlib, derived from Makefile.dj2.
# Modified for mingw32 by C. Spieler, 6/16/98.
M
Mark Adler 已提交
3 4
# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003.
# Last updated: 1-Aug-2003.
M
Mark Adler 已提交
5 6
# Tested under Cygwin and MinGW.

M
Mark Adler 已提交
7 8
# Copyright (C) 1995-2003 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
M
Mark Adler 已提交
9 10

# To compile, or to compile and test, type:
M
Mark Adler 已提交
11 12 13 14 15 16 17
#
#   make -fmakefile.gcc;  make test testdll -fmakefile.gcc
#
# To use the asm code, type:
#   cp contrib/asm?86/match.S ./match.S
#   make LOC=-DASMV OBJA=match.o -fmakefile.gcc
#
M
Mark Adler 已提交
18
# To install libz.a, zconf.h and zlib.h in the system directories, type:
M
Mark Adler 已提交
19 20
#
#   make install -fmakefile.gcc
M
Mark Adler 已提交
21

M
Mark Adler 已提交
22 23 24 25 26 27
# 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
M
Mark Adler 已提交
28
IMPLIB    = libzdll.a
M
Mark Adler 已提交
29 30 31

#LOC = -DASMV
#LOC = -DDEBUG -g
M
Mark Adler 已提交
32

M
Mark Adler 已提交
33 34
PREFIX =
CC = $(PREFIX)gcc
M
Mark Adler 已提交
35 36 37 38 39 40 41 42
CFLAGS = $(LOC) -O3 -Wall

AS = $(CC)
ASFLAGS = $(LOC) -Wall

LD = $(CC)
LDFLAGS = $(LOC) -s

M
Mark Adler 已提交
43
AR = $(PREFIX)ar
M
Mark Adler 已提交
44 45
ARFLAGS = rcs

M
Mark Adler 已提交
46
RC = $(PREFIX)windres
M
Mark Adler 已提交
47
RCFLAGS = --define GCC_WINDRES
M
Mark Adler 已提交
48

M
Mark Adler 已提交
49
STRIP = $(PREFIX)strip
M
Mark Adler 已提交
50

M
Mark Adler 已提交
51 52 53 54 55 56 57 58
CP = cp -fp
# If GNU install is available, replace $(CP) with install.
INSTALL = $(CP)
RM = rm -f

prefix = /usr/local
exec_prefix = $(prefix)

M
Mark Adler 已提交
59
OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
M
Mark Adler 已提交
60
       gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
M
Mark Adler 已提交
61 62
OBJA =

M
Mark Adler 已提交
63
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe
M
Mark Adler 已提交
64

M
Mark Adler 已提交
65
test: example.exe minigzip.exe
M
Mark Adler 已提交
66
	./example
M
Mark Adler 已提交
67 68
	echo hello world | ./minigzip | ./minigzip -d

M
Mark Adler 已提交
69
testdll: example_d.exe minigzip_d.exe
M
Mark Adler 已提交
70 71
	./example_d
	echo hello world | ./minigzip_d | ./minigzip_d -d
M
Mark Adler 已提交
72 73 74 75

.c.o:
	$(CC) $(CFLAGS) -c -o $@ $<

M
Mark Adler 已提交
76 77 78 79 80 81 82 83 84
.S.o:
	$(AS) $(ASFLAGS) -c -o $@ $<

$(STATICLIB): $(OBJS) $(OBJA)
	$(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA)

$(IMPLIB): $(SHAREDLIB)

$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
M
Mark Adler 已提交
85 86 87
	$(CC) -shared -Wl,--out-implib,$(IMPLIB) \
	-o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
	$(STRIP) $@
M
Mark Adler 已提交
88

M
Mark Adler 已提交
89
example.exe: example.o $(STATICLIB)
M
Mark Adler 已提交
90
	$(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB)
M
Mark Adler 已提交
91

M
Mark Adler 已提交
92
minigzip.exe: minigzip.o $(STATICLIB)
M
Mark Adler 已提交
93
	$(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB)
M
Mark Adler 已提交
94

M
Mark Adler 已提交
95
example_d.exe: example.o $(IMPLIB)
M
Mark Adler 已提交
96
	$(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB)
M
Mark Adler 已提交
97

M
Mark Adler 已提交
98
minigzip_d.exe: minigzip.o $(IMPLIB)
M
Mark Adler 已提交
99
	$(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB)
M
Mark Adler 已提交
100

M
Mark Adler 已提交
101 102
zlibrc.o: win32/zlib1.rc
	$(RC) $(RCFLAGS) -o $@ win32/zlib1.rc
M
Mark Adler 已提交
103

M
Mark Adler 已提交
104

M
Mark Adler 已提交
105
# INCLUDE_PATH and LIBRARY_PATH must be set.
M
Mark Adler 已提交
106

M
Mark Adler 已提交
107
.PHONY: install uninstall clean
M
Mark Adler 已提交
108 109

install: zlib.h zconf.h $(LIB)
M
Mark Adler 已提交
110 111
	-@mkdir -p $(INCLUDE_PATH)
	-@mkdir -p $(LIBRARY_PATH)
M
Mark Adler 已提交
112 113 114 115
	-$(INSTALL) zlib.h $(INCLUDE_PATH)
	-$(INSTALL) zconf.h $(INCLUDE_PATH)
	-$(INSTALL) $(STATICLIB) $(LIBRARY_PATH)
	-$(INSTALL) $(IMPLIB) $(LIBRARY_PATH)
M
Mark Adler 已提交
116 117

uninstall:
M
Mark Adler 已提交
118 119 120 121
	-$(RM) $(INCLUDE_PATH)/zlib.h
	-$(RM) $(INCLUDE_PATH)/zconf.h
	-$(RM) $(LIBRARY_PATH)/$(STATICLIB)
	-$(RM) $(LIBRARY_PATH)/$(IMPLIB)
M
Mark Adler 已提交
122 123

clean:
M
Mark Adler 已提交
124 125 126 127 128 129
	-$(RM) $(STATICLIB)
	-$(RM) $(SHAREDLIB)
	-$(RM) $(IMPLIB)
	-$(RM) *.o
	-$(RM) *.exe
	-$(RM) foo.gz
M
Mark Adler 已提交
130 131 132 133 134 135

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
example.o: zlib.h zconf.h
M
Mark Adler 已提交
136 137 138 139
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
M
Mark Adler 已提交
140 141 142 143
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
M
Mark Adler 已提交
144
minigzip.o: zlib.h zconf.h
M
Mark Adler 已提交
145 146
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
uncompr.o: zlib.h zconf.h
M
Mark Adler 已提交
147
zutil.o: zutil.h zlib.h zconf.h