Makefile.gcc 3.4 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 28 29 30 31
# 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
IMPLIB    = libzdll.a

#LOC = -DASMV
#LOC = -DDEBUG -g
M
Mark Adler 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44

CC = gcc
CFLAGS = $(LOC) -O3 -Wall

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

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

AR = ar
ARFLAGS = rcs

M
Mark Adler 已提交
45
RC = windres
M
Mark Adler 已提交
46
RCFLAGS = --define GCC_WINDRES
M
Mark Adler 已提交
47

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

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

OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \
       inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
OBJA =

M
Mark Adler 已提交
60
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example minigzip example_d minigzip_d
M
Mark Adler 已提交
61

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

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

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

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

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

$(IMPLIB): $(SHAREDLIB)

$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
	dllwrap --driver-name $(CC) --def win32/zlib.def \
	  --implib $(IMPLIB) -o $@ $(OBJS) $(OBJA) zlibrc.o
	strip $@

example: example.o $(STATICLIB)
	$(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB)
M
Mark Adler 已提交
88

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

M
Mark Adler 已提交
92 93
example_d: example.o $(IMPLIB)
	$(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB)
M
Mark Adler 已提交
94

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

M
Mark Adler 已提交
98 99
zlibrc.o: win32/zlib1.rc
	$(RC) $(RCFLAGS) -o $@ win32/zlib1.rc
M
Mark Adler 已提交
100

M
Mark Adler 已提交
101

M
Mark Adler 已提交
102
# INCLUDE_PATH and LIBRARY_PATH must be set.
M
Mark Adler 已提交
103

M
Mark Adler 已提交
104
.PHONY: install uninstall clean
M
Mark Adler 已提交
105 106 107 108

install: zlib.h zconf.h $(LIB)
	-@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH)
	-@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH)
M
Mark Adler 已提交
109 110 111 112
	-$(INSTALL) zlib.h $(INCLUDE_PATH)
	-$(INSTALL) zconf.h $(INCLUDE_PATH)
	-$(INSTALL) $(STATICLIB) $(LIBRARY_PATH)
	-$(INSTALL) $(IMPLIB) $(LIBRARY_PATH)
M
Mark Adler 已提交
113 114

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

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

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
gzio.o: zutil.h zlib.h zconf.h
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 已提交
138
minigzip.o: zlib.h zconf.h
M
Mark Adler 已提交
139 140
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
uncompr.o: zlib.h zconf.h
M
Mark Adler 已提交
141
zutil.o: zutil.h zlib.h zconf.h