1 # Makefile for zlib using Microsoft (Visual) C
   2 # zlib is copyright (C) 1995-2006 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 #
  14 TOP = .
  15 
  16 # optional build flags
  17 LOC =
  18 
  19 # variables
  20 STATICLIB = zlib.lib
  21 SHAREDLIB = zlib1.dll
  22 IMPLIB    = zdll.lib
  23 
  24 CC = cl
  25 AS = ml
  26 LD = link
  27 AR = lib
  28 RC = rc
  29 CFLAGS  = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC)
  30 WFLAGS  = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
  31 ASFLAGS = -coff -Zi $(LOC)
  32 LDFLAGS = -nologo -debug -incremental:no -opt:ref
  33 ARFLAGS = -nologo
  34 RCFLAGS = /dWIN32 /r
  35 
  36 OBJS = 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
  38 OBJA =
  39 
  40 
  41 # targets
  42 all: $(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 
  56 example.exe: example.obj $(STATICLIB)
  57         $(LD) $(LDFLAGS) example.obj $(STATICLIB)
  58         if exist $@.manifest \
  59           mt -nologo -manifest $@.manifest -outputresource:$@;1
  60 
  61 minigzip.exe: minigzip.obj $(STATICLIB)
  62         $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB)
  63         if exist $@.manifest \
  64           mt -nologo -manifest $@.manifest -outputresource:$@;1
  65 
  66 example_d.exe: example.obj $(IMPLIB)
  67         $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB)
  68         if exist $@.manifest \
  69           mt -nologo -manifest $@.manifest -outputresource:$@;1
  70 
  71 minigzip_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 
  91 adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h
  92 
  93 compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h
  94 
  95 crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h
  96 
  97 deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h
  98 
  99 gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
 100 
 101 gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
 102 
 103 gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
 104 
 105 gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h
 106 
 107 infback.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 
 110 inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \
 111              $(TOP)/inffast.h
 112 
 113 inflate.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 
 116 inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h
 117 
 118 trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h
 119 
 120 uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h
 121 
 122 zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h
 123 
 124 gvmat64.obj: $(TOP)/contrib\masmx64\gvmat64.asm
 125 
 126 inffasx64.obj: $(TOP)/contrib\masmx64\inffasx64.asm
 127 
 128 inffas8664.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 
 131 inffas32.obj: $(TOP)/contrib\masmx86\inffas32.asm
 132 
 133 match686.obj: $(TOP)/contrib\masmx86\match686.asm
 134 
 135 example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h
 136 
 137 minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h
 138 
 139 zlib1.res: $(TOP)/win32/zlib1.rc
 140         $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc
 141 
 142 # testing
 143 test: example.exe minigzip.exe
 144         example
 145         echo hello world | minigzip | minigzip -d
 146 
 147 testdll: example_d.exe minigzip_d.exe
 148         example_d
 149         echo hello world | minigzip_d | minigzip_d -d
 150 
 151 
 152 # cleanup
 153 clean:
 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