1# Makefile for zlib using Microsoft (Visual) C
2# zlib is copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
3#
4# Usage:
5#   nmake -f win32/Makefile.msc                          (standard build)
6#   nmake -f win32/Makefile.msc LOC=-DFOO                (nonstandard build)
7#   nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" \
8#         OBJA="inffas32.obj match686.obj"               (use ASM code, x86)
9#   nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." \
10#         OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"  (use ASM code, x64)
11
12# The toplevel directory of the source tree.
13#
14TOP = .
15
16# optional build flags
17LOC =
18
19# variables
20STATICLIB = zlib.lib
21SHAREDLIB = zlib1.dll
22IMPLIB    = zdll.lib
23
24CC = cl
25AS = ml
26LD = link
27AR = lib
28RC = rc
29CFLAGS  = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC)
30WFLAGS  = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
31ASFLAGS = -coff -Zi $(LOC)
32LDFLAGS = -nologo -debug -incremental:no -opt:ref
33ARFLAGS = -nologo
34RCFLAGS = /dWIN32 /r
35
36OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \
37       gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj
38OBJA =
39
40
41# targets
42all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
43     example.exe minigzip.exe example_d.exe minigzip_d.exe
44
45$(STATICLIB): $(OBJS) $(OBJA)
46	$(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA)
47
48$(IMPLIB): $(SHAREDLIB)
49
50$(SHAREDLIB): $(TOP)/win32/zlib.def $(OBJS) $(OBJA) zlib1.res
51	$(LD) $(LDFLAGS) -def:$(TOP)/win32/zlib.def -dll -implib:$(IMPLIB) \
52	  -out:$@ -base:0x5A4C0000 $(OBJS) $(OBJA) zlib1.res
53	if exist $@.manifest \
54	  mt -nologo -manifest $@.manifest -outputresource:$@;2
55
56example.exe: example.obj $(STATICLIB)
57	$(LD) $(LDFLAGS) example.obj $(STATICLIB)
58	if exist $@.manifest \
59	  mt -nologo -manifest $@.manifest -outputresource:$@;1
60
61minigzip.exe: minigzip.obj $(STATICLIB)
62	$(LD) $(LDFLAGS) minigzip.obj $(STATICLIB)
63	if exist $@.manifest \
64	  mt -nologo -manifest $@.manifest -outputresource:$@;1
65
66example_d.exe: example.obj $(IMPLIB)
67	$(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB)
68	if exist $@.manifest \
69	  mt -nologo -manifest $@.manifest -outputresource:$@;1
70
71minigzip_d.exe: minigzip.obj $(IMPLIB)
72	$(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB)
73	if exist $@.manifest \
74	  mt -nologo -manifest $@.manifest -outputresource:$@;1
75
76{$(TOP)}.c.obj:
77	$(CC) -c $(WFLAGS) $(CFLAGS) $<
78
79{$(TOP)/test}.c.obj:
80	$(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $<
81
82{$(TOP)/contrib/masmx64}.c.obj:
83	$(CC) -c $(WFLAGS) $(CFLAGS) $<
84
85{$(TOP)/contrib/masmx64}.asm.obj:
86	$(AS) -c $(ASFLAGS) $<
87
88{$(TOP)/contrib/masmx86}.asm.obj:
89	$(AS) -c $(ASFLAGS) $<
90
91adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h
92
93compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h
94
95crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h
96
97deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h
98
99gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
100
101gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
102
103gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
104
105gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
106
107infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \
108             $(TOP)/inffast.h $(TOP)/inffixed.h
109
110inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \
111             $(TOP)/inffast.h
112
113inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \
114             $(TOP)/inffast.h $(TOP)/inffixed.h
115
116inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h
117
118trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h
119
120uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h
121
122zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h
123
124gvmat64.obj: $(TOP)/contrib\masmx64\gvmat64.asm
125
126inffasx64.obj: $(TOP)/contrib\masmx64\inffasx64.asm
127
128inffas8664.obj: $(TOP)/contrib\masmx64\inffas8664.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h \
129		$(TOP)/inftrees.h $(TOP)/inflate.h $(TOP)/inffast.h
130
131inffas32.obj: $(TOP)/contrib\masmx86\inffas32.asm
132
133match686.obj: $(TOP)/contrib\masmx86\match686.asm
134
135example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h
136
137minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h
138
139zlib1.res: $(TOP)/win32/zlib1.rc
140	$(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc
141
142# testing
143test: example.exe minigzip.exe
144	example
145	echo hello world | minigzip | minigzip -d
146
147testdll: example_d.exe minigzip_d.exe
148	example_d
149	echo hello world | minigzip_d | minigzip_d -d
150
151
152# cleanup
153clean:
154	-del $(STATICLIB)
155	-del $(SHAREDLIB)
156	-del $(IMPLIB)
157	-del *.obj
158	-del *.res
159	-del *.exp
160	-del *.exe
161	-del *.pdb
162	-del *.manifest
163	-del foo.gz
164