1# Makefile for Zip, ZipCloak, ZipNote and ZipSplit
2# using emx 0.9c for DOS.
3# By Kai-Uwe Rommel, Chr. Spieler, E-Yen Tan (and others).
4# Last updated 7th January 2007.
5#
6# This Makefile is a stripped down version of win32/Makefile.emx that
7# builds executables applying the default MSDOS emx setup.  For variant
8# targets (using zlib), and cross-compilation for WIN32 or OS/2, take a
9# look into "win32/makefile.emx" resp. "os2/makefile.os2".
10#
11# Supported Make utilities:
12# - Microsoft/IBM nmake (e.g. from MSC 6.0 or newer)
13# - dmake 3.8 or higher
14# - GNU make, at least version 3.68 (GNUish 16-bit port, RSXNT Make 3.75 in a
15#   Win95/WinNT DOS box, DJGPP v1.12 Make 3.71, some versions of DJGPP v2.x
16#   32-bit Make; current DJGPP v2.01 Make 3.76.1 does NOT work)
17# - NOT watcom make
18# The "smart" Make utilities mentioned below are Christian Spieler's
19# enhanced version of GNUish 16-bit Make (3.74) and his adaption of these
20# GNU Make sources to EMX (32-bit).
21
22# Supported 32-bit C Compilers for MSDOS:
23# - GNU gcc (emx kit 0.9c or newer, 32-bit)
24
25# Supported Assemblers:
26# - GNU as with GNU gcc
27
28
29# To use, enter "make/nmake/dmake -f msdos/makefile.emx"
30# (this makefile depends on its name being "msdos/makefile.emx").
31
32# emx 0.9c, gcc, a.out format, for MS-DOS
33CC=gcc -O2 -m486 -Wall
34CFLAGS=-DDOS -DMSDOS -DASM_CRC
35AS=gcc
36ASFLAGS=-Di386
37LDFLAGS=-o ./
38LDFLAGS2=-s -Zsmall-conv
39OUT=-o
40OBJ=.o
41CRCA_O=crc_gcc.o
42OBJA=matchgcc.o
43OBJZS=msdos.o
44OBJUS=msdos_.o
45OSDEP_H=msdos/osdep.h
46ZIPUP_H=msdos/zipup.h
47
48#default settings for target dependent macros:
49DIRSEP = /
50AS_DIRSEP = /
51RM = del
52LOCAL_OPTS = $(LOCAL_ZIP)
53CCFLAGS = $(CFLAGS) $(LOCAL_OPTS)
54
55
56OBJZ1 = zip$(OBJ) zipfile$(OBJ) zipup$(OBJ) fileio$(OBJ) util$(OBJ) \
57	crc32$(OBJ) $(CRCA_O)
58OBJZ2 = globals$(OBJ) deflate$(OBJ) trees$(OBJ) crypt$(OBJ) \
59	ttyio$(OBJ)
60OBJZ  = $(OBJZ1) $(OBJZ2) $(OBJZS) $(OBJA)
61
62OBJU1 = zipfile_$(OBJ) fileio_$(OBJ) util_$(OBJ) globals$(OBJ)
63OBJU  = $(OBJU1) $(OBJUS)
64
65OBJN  = zipnote$(OBJ) $(OBJU)
66OBJS  = zipsplit$(OBJ) $(OBJU)
67OBJC1 = zipcloak$(OBJ) crc32_$(OBJ) crypt_$(OBJ) ttyio$(OBJ)
68OBJC  = $(OBJC1) $(OBJU)
69
70ZIP_H = zip.h ziperr.h tailor.h $(OSDEP_H)
71
72# rules
73
74.SUFFIXES: .c $(OBJ)
75
76.c$(OBJ):
77	$(CC) -c -I. $(CCFLAGS) $(OUT)$@ $<
78
79# targets
80
81all:    zip.exe zipnote.exe zipsplit.exe zipcloak.exe
82
83zip$(OBJ):      zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h
84zipfile$(OBJ):  zipfile.c $(ZIP_H) crc32.h
85zipup$(OBJ):    zipup.c $(ZIP_H) revision.h crc32.h crypt.h $(ZIPUP_H)
86fileio$(OBJ):   fileio.c $(ZIP_H) crc32.h
87util$(OBJ):     util.c $(ZIP_H)
88globals$(OBJ):  globals.c $(ZIP_H)
89deflate$(OBJ):  deflate.c $(ZIP_H)
90trees$(OBJ):    trees.c $(ZIP_H)
91crc32$(OBJ):    crc32.c $(ZIP_H) crc32.h
92crypt$(OBJ):    crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h
93ttyio$(OBJ):    ttyio.c $(ZIP_H) crypt.h ttyio.h
94
95msdos$(OBJ):    msdos/msdos.c $(ZIP_H)
96	$(CC) -c -I. $(CCFLAGS) msdos$(DIRSEP)msdos.c
97
98win32zip$(OBJ): win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h
99	$(CC) -c -I. $(CCFLAGS) win32$(DIRSEP)win32zip.c
100
101win32$(OBJ):    win32/win32.c $(ZIP_H) win32/win32zip.h
102	$(CC) -c -I. $(CCFLAGS) win32$(DIRSEP)win32.c
103
104nt$(OBJ):       win32/nt.c $(ZIP_H) win32/nt.h
105	$(CC) -c -I. $(CCFLAGS) win32$(DIRSEP)nt.c
106
107crc_gcc$(OBJ):  crc_i386.S                                      # 32bit, GNU AS
108	$(AS) $(ASFLAGS) -x assembler-with-cpp -c -o $@ crc_i386.S
109
110matchgcc$(OBJ): match.S
111	$(AS) $(ASFLAGS) -x assembler-with-cpp -c -o $@ match.S
112
113zipcloak$(OBJ): zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h
114zipnote$(OBJ):  zipnote.c $(ZIP_H) revision.h
115zipsplit$(OBJ): zipsplit.c $(ZIP_H) revision.h
116
117zipfile_$(OBJ): zipfile.c $(ZIP_H) crc32.h
118	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ zipfile.c
119
120fileio_$(OBJ):  fileio.c $(ZIP_H) crc32.h
121	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ fileio.c
122
123util_$(OBJ):    util.c $(ZIP_H)
124	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ util.c
125
126crc32_$(OBJ):   crc32.c $(ZIP_H) crc32.h
127	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ crc32.c
128
129crypt_$(OBJ):   crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h
130	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ crypt.c
131
132msdos_$(OBJ):   msdos/msdos.c $(ZIP_H)
133	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ msdos$(DIRSEP)msdos.c
134
135win32_$(OBJ):   win32/win32.c $(ZIP_H) win32/win32zip.h
136	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ win32$(DIRSEP)win32.c
137
138# This next bit is nasty, but is needed to overcome the MS-DOS command
139# line limit as response files for emx's gcc seem to only work if each
140# file is on a different line. DJGPP doesn't do this (if you are at all
141# interested).
142
143zip.exe: $(OBJZ)
144# for DUMB make utilities, uncomment the following commands:
145	-@$(RM) zip.rsp
146	@for %%f in ($(OBJZ1)) do echo %%f >> zip.rsp
147	@for %%f in ($(OBJZ2)) do echo %%f >> zip.rsp
148	@for %%f in ($(OBJZS) $(OBJA)) do echo %%f >> zip.rsp
149	$(CC) $(LDFLAGS)$@ @zip.rsp $(LDFLAGS2)
150	@$(RM) zip.rsp
151# smart make utilities (like well done ports of GNU Make) can use this:
152#	$(CC) $(LDFLAGS)$@ $(OBJZ) $(LDFLAGS2)
153
154zipcloak.exe: $(OBJC)
155# for DUMB make utilities, uncomment the following commands:
156	-@$(RM) zipcloak.rsp
157	@for %%f in ($(OBJC1)) do echo %%f >> zipcloak.rsp
158	@for %%f in ($(OBJU1)) do echo %%f >> zipcloak.rsp
159	@for %%f in ($(OBJUS)) do echo %%f >> zipcloak.rsp
160	$(CC) $(LDFLAGS)$@ @zipcloak.rsp $(LDFLAGS2)
161	@$(RM) zipcloak.rsp
162# smart make utilities (like well done ports of GNU Make) can use this:
163#	$(CC) $(LDFLAGS)$@ $(OBJC) $(LDFLAGS2)
164
165zipnote.exe: $(OBJN)
166	$(CC) $(LDFLAGS)$@ $(OBJN) $(LDFLAGS2)
167
168zipsplit.exe: $(OBJS)
169	$(CC) $(LDFLAGS)$@ $(OBJS) $(LDFLAGS2)
170