kusano fc6ab3
# Makefile for zlib using Microsoft (Visual) C
kusano fc6ab3
# zlib is copyright (C) 1995-2006 Jean-loup Gailly and Mark Adler
kusano fc6ab3
#
kusano fc6ab3
# Usage:
kusano fc6ab3
#   nmake -f win32/Makefile.msc                          (standard build)
kusano fc6ab3
#   nmake -f win32/Makefile.msc LOC=-DFOO                (nonstandard build)
kusano fc6ab3
#   nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" \
kusano fc6ab3
#         OBJA="inffas32.obj match686.obj"               (use ASM code, x86)
kusano fc6ab3
#   nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." \
kusano fc6ab3
#         OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"  (use ASM code, x64)
kusano fc6ab3
kusano fc6ab3
# The toplevel directory of the source tree.
kusano fc6ab3
#
kusano fc6ab3
TOP = .
kusano fc6ab3
kusano fc6ab3
# optional build flags
kusano fc6ab3
LOC =
kusano fc6ab3
kusano fc6ab3
# variables
kusano fc6ab3
STATICLIB = zlib.lib
kusano fc6ab3
SHAREDLIB = zlib1.dll
kusano fc6ab3
IMPLIB    = zdll.lib
kusano fc6ab3
kusano fc6ab3
CC = cl
kusano fc6ab3
AS = ml
kusano fc6ab3
LD = link
kusano fc6ab3
AR = lib
kusano fc6ab3
RC = rc
kusano fc6ab3
CFLAGS  = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC)
kusano fc6ab3
WFLAGS  = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
kusano fc6ab3
ASFLAGS = -coff -Zi $(LOC)
kusano fc6ab3
LDFLAGS = -nologo -debug -incremental:no -opt:ref
kusano fc6ab3
ARFLAGS = -nologo
kusano fc6ab3
RCFLAGS = /dWIN32 /r
kusano fc6ab3
kusano fc6ab3
OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \
kusano fc6ab3
       gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj
kusano fc6ab3
OBJA =
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
# targets
kusano fc6ab3
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
kusano fc6ab3
     example.exe minigzip.exe example_d.exe minigzip_d.exe
kusano fc6ab3
kusano fc6ab3
$(STATICLIB): $(OBJS) $(OBJA)
kusano fc6ab3
	$(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA)
kusano fc6ab3
kusano fc6ab3
$(IMPLIB): $(SHAREDLIB)
kusano fc6ab3
kusano fc6ab3
$(SHAREDLIB): $(TOP)/win32/zlib.def $(OBJS) $(OBJA) zlib1.res
kusano fc6ab3
	$(LD) $(LDFLAGS) -def:$(TOP)/win32/zlib.def -dll -implib:$(IMPLIB) \
kusano fc6ab3
	  -out:$@ -base:0x5A4C0000 $(OBJS) $(OBJA) zlib1.res
kusano fc6ab3
	if exist $@.manifest \
kusano fc6ab3
	  mt -nologo -manifest $@.manifest -outputresource:$@;2
kusano fc6ab3
kusano fc6ab3
example.exe: example.obj $(STATICLIB)
kusano fc6ab3
	$(LD) $(LDFLAGS) example.obj $(STATICLIB)
kusano fc6ab3
	if exist $@.manifest \
kusano fc6ab3
	  mt -nologo -manifest $@.manifest -outputresource:$@;1
kusano fc6ab3
kusano fc6ab3
minigzip.exe: minigzip.obj $(STATICLIB)
kusano fc6ab3
	$(LD) $(LDFLAGS) minigzip.obj $(STATICLIB)
kusano fc6ab3
	if exist $@.manifest \
kusano fc6ab3
	  mt -nologo -manifest $@.manifest -outputresource:$@;1
kusano fc6ab3
kusano fc6ab3
example_d.exe: example.obj $(IMPLIB)
kusano fc6ab3
	$(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB)
kusano fc6ab3
	if exist $@.manifest \
kusano fc6ab3
	  mt -nologo -manifest $@.manifest -outputresource:$@;1
kusano fc6ab3
kusano fc6ab3
minigzip_d.exe: minigzip.obj $(IMPLIB)
kusano fc6ab3
	$(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB)
kusano fc6ab3
	if exist $@.manifest \
kusano fc6ab3
	  mt -nologo -manifest $@.manifest -outputresource:$@;1
kusano fc6ab3
kusano fc6ab3
{$(TOP)}.c.obj:
kusano fc6ab3
	$(CC) -c $(WFLAGS) $(CFLAGS) $<
kusano fc6ab3
kusano fc6ab3
{$(TOP)/test}.c.obj:
kusano fc6ab3
	$(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $<
kusano fc6ab3
kusano fc6ab3
{$(TOP)/contrib/masmx64}.c.obj:
kusano fc6ab3
	$(CC) -c $(WFLAGS) $(CFLAGS) $<
kusano fc6ab3
kusano fc6ab3
{$(TOP)/contrib/masmx64}.asm.obj:
kusano fc6ab3
	$(AS) -c $(ASFLAGS) $<
kusano fc6ab3
kusano fc6ab3
{$(TOP)/contrib/masmx86}.asm.obj:
kusano fc6ab3
	$(AS) -c $(ASFLAGS) $<
kusano fc6ab3
kusano fc6ab3
adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h
kusano fc6ab3
kusano fc6ab3
compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h
kusano fc6ab3
kusano fc6ab3
crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h
kusano fc6ab3
kusano fc6ab3
deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h
kusano fc6ab3
kusano fc6ab3
gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
kusano fc6ab3
kusano fc6ab3
gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
kusano fc6ab3
kusano fc6ab3
gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
kusano fc6ab3
kusano fc6ab3
gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
kusano fc6ab3
kusano fc6ab3
infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \
kusano fc6ab3
             $(TOP)/inffast.h $(TOP)/inffixed.h
kusano fc6ab3
kusano fc6ab3
inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \
kusano fc6ab3
             $(TOP)/inffast.h
kusano fc6ab3
kusano fc6ab3
inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \
kusano fc6ab3
             $(TOP)/inffast.h $(TOP)/inffixed.h
kusano fc6ab3
kusano fc6ab3
inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h
kusano fc6ab3
kusano fc6ab3
trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h
kusano fc6ab3
kusano fc6ab3
uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h
kusano fc6ab3
kusano fc6ab3
zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h
kusano fc6ab3
kusano fc6ab3
gvmat64.obj: $(TOP)/contrib\masmx64\gvmat64.asm
kusano fc6ab3
kusano fc6ab3
inffasx64.obj: $(TOP)/contrib\masmx64\inffasx64.asm
kusano fc6ab3
kusano fc6ab3
inffas8664.obj: $(TOP)/contrib\masmx64\inffas8664.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h \
kusano fc6ab3
		$(TOP)/inftrees.h $(TOP)/inflate.h $(TOP)/inffast.h
kusano fc6ab3
kusano fc6ab3
inffas32.obj: $(TOP)/contrib\masmx86\inffas32.asm
kusano fc6ab3
kusano fc6ab3
match686.obj: $(TOP)/contrib\masmx86\match686.asm
kusano fc6ab3
kusano fc6ab3
example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h
kusano fc6ab3
kusano fc6ab3
minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h
kusano fc6ab3
kusano fc6ab3
zlib1.res: $(TOP)/win32/zlib1.rc
kusano fc6ab3
	$(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc
kusano fc6ab3
kusano fc6ab3
# testing
kusano fc6ab3
test: example.exe minigzip.exe
kusano fc6ab3
	example
kusano fc6ab3
	echo hello world | minigzip | minigzip -d
kusano fc6ab3
kusano fc6ab3
testdll: example_d.exe minigzip_d.exe
kusano fc6ab3
	example_d
kusano fc6ab3
	echo hello world | minigzip_d | minigzip_d -d
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
# cleanup
kusano fc6ab3
clean:
kusano fc6ab3
	-del $(STATICLIB)
kusano fc6ab3
	-del $(SHAREDLIB)
kusano fc6ab3
	-del $(IMPLIB)
kusano fc6ab3
	-del *.obj
kusano fc6ab3
	-del *.res
kusano fc6ab3
	-del *.exp
kusano fc6ab3
	-del *.exe
kusano fc6ab3
	-del *.pdb
kusano fc6ab3
	-del *.manifest
kusano fc6ab3
	-del foo.gz