| 1 | # Makefile for zlib | 
|---|
| 2 | # Microsoft C 5.1 or later | 
|---|
| 3 |  | 
|---|
| 4 | # To use, do "make makefile.msc" | 
|---|
| 5 | # To compile in small model, set below: MODEL=S | 
|---|
| 6 |  | 
|---|
| 7 | # If you wish to reduce the memory requirements (default 256K for big | 
|---|
| 8 | # objects plus a few K), you can add to the LOC macro below: | 
|---|
| 9 | #   -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 | 
|---|
| 10 | # See zconf.h for details about the memory requirements. | 
|---|
| 11 |  | 
|---|
| 12 | # ------------- Microsoft C 5.1 and later ------------- | 
|---|
| 13 |  | 
|---|
| 14 | #    Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) | 
|---|
| 15 | #    should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added | 
|---|
| 16 | #    to the declaration of LOC here: | 
|---|
| 17 | LOC = $(LOCAL_ZLIB) | 
|---|
| 18 |  | 
|---|
| 19 | # Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. | 
|---|
| 20 | CPU_TYP = 0 | 
|---|
| 21 |  | 
|---|
| 22 | # Memory model: one of S, M, C, L (small, medium, compact, large) | 
|---|
| 23 | MODEL=L | 
|---|
| 24 |  | 
|---|
| 25 | CC=cl | 
|---|
| 26 | CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) | 
|---|
| 27 | #-Ox generates bad code with MSC 5.1 | 
|---|
| 28 | LIB_CFLAGS=-Zl $(CFLAGS) | 
|---|
| 29 |  | 
|---|
| 30 | LD=link | 
|---|
| 31 | LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode | 
|---|
| 32 | # "/farcall/packcode" are only useful for `large code' memory models | 
|---|
| 33 | # but should be a "no-op" for small code models. | 
|---|
| 34 |  | 
|---|
| 35 | O=.obj | 
|---|
| 36 |  | 
|---|
| 37 | # variables | 
|---|
| 38 | OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ | 
|---|
| 39 | trees$(O) | 
|---|
| 40 | OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ | 
|---|
| 41 | trees$(O) | 
|---|
| 42 | OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ | 
|---|
| 43 | infutil$(O) inffast$(O) | 
|---|
| 44 | OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ | 
|---|
| 45 | infutil$(O)+inffast$(O) | 
|---|
| 46 |  | 
|---|
| 47 | ZLIB_H = zlib.h zconf.h | 
|---|
| 48 | ZUTIL_H = zutil.h $(ZLIB_H) | 
|---|
| 49 |  | 
|---|
| 50 | ZLIB_LIB = zlib_$(MODEL).lib | 
|---|
| 51 |  | 
|---|
| 52 | all:  $(ZLIB_LIB) example.exe minigzip.exe | 
|---|
| 53 |  | 
|---|
| 54 | # individual dependencies and action rules: | 
|---|
| 55 | adler32.obj: adler32.c $(ZLIB_H) | 
|---|
| 56 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 57 |  | 
|---|
| 58 | compress.obj: compress.c $(ZLIB_H) | 
|---|
| 59 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 60 |  | 
|---|
| 61 | crc32.obj: crc32.c $(ZLIB_H) | 
|---|
| 62 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 63 |  | 
|---|
| 64 | deflate.obj: deflate.c deflate.h $(ZUTIL_H) | 
|---|
| 65 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 66 |  | 
|---|
| 67 | gzio.obj: gzio.c $(ZUTIL_H) | 
|---|
| 68 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 69 |  | 
|---|
| 70 | infblock.obj: infblock.c $(ZUTIL_H) infblock.h inftrees.h infcodes.h infutil.h | 
|---|
| 71 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 72 |  | 
|---|
| 73 | infcodes.obj: infcodes.c $(ZUTIL_H) inftrees.h infutil.h infcodes.h inffast.h | 
|---|
| 74 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 75 |  | 
|---|
| 76 | inflate.obj: inflate.c $(ZUTIL_H) infblock.h | 
|---|
| 77 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 78 |  | 
|---|
| 79 | inftrees.obj: inftrees.c $(ZUTIL_H) inftrees.h | 
|---|
| 80 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 81 |  | 
|---|
| 82 | infutil.obj: infutil.c $(ZUTIL_H) inftrees.h infutil.h | 
|---|
| 83 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 84 |  | 
|---|
| 85 | inffast.obj: inffast.c $(ZUTIL_H) inftrees.h infutil.h inffast.h | 
|---|
| 86 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 87 |  | 
|---|
| 88 | trees.obj: trees.c deflate.h $(ZUTIL_H) | 
|---|
| 89 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 90 |  | 
|---|
| 91 | uncompr.obj: uncompr.c $(ZLIB_H) | 
|---|
| 92 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 93 |  | 
|---|
| 94 | zutil.obj: zutil.c $(ZUTIL_H) | 
|---|
| 95 | $(CC) -c $(LIB_CFLAGS) $*.c | 
|---|
| 96 |  | 
|---|
| 97 | example.obj: example.c $(ZLIB_H) | 
|---|
| 98 | $(CC) -c $(CFLAGS) $*.c | 
|---|
| 99 |  | 
|---|
| 100 | minigzip.obj: minigzip.c $(ZLIB_H) | 
|---|
| 101 | $(CC) -c $(CFLAGS) $*.c | 
|---|
| 102 |  | 
|---|
| 103 | # we must cut the command line to fit in the MS/DOS 128 byte limit: | 
|---|
| 104 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) | 
|---|
| 105 | if exist $(ZLIB_LIB) del $(ZLIB_LIB) | 
|---|
| 106 | lib $(ZLIB_LIB) $(OBJ1); | 
|---|
| 107 | lib $(ZLIB_LIB) $(OBJ2); | 
|---|
| 108 |  | 
|---|
| 109 | example.exe: example.obj $(ZLIB_LIB) | 
|---|
| 110 | $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); | 
|---|
| 111 |  | 
|---|
| 112 | minigzip.exe: minigzip.obj $(ZLIB_LIB) | 
|---|
| 113 | $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); | 
|---|
| 114 |  | 
|---|
| 115 | test: example.exe minigzip.exe | 
|---|
| 116 | example | 
|---|
| 117 | echo hello world | minigzip | minigzip -d | 
|---|
| 118 |  | 
|---|
| 119 | #clean: | 
|---|
| 120 | #       del *.obj | 
|---|
| 121 | #       del *.exe | 
|---|