Repository navigation
Expand file tree
/
Copy pathMAKEFILE
More file actions
304 lines (250 loc) · 11.8 KB
/
Copy pathMAKEFILE
File metadata and controls
304 lines (250 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# =============================================================================
# FTP4DOS - Norton Commander FTP Client for MS-DOS 386
# Open Watcom Makefile (wmake)
# =============================================================================
#
# Prerequisites:
# - Open Watcom C/C++ installed and in PATH (WATCOM env variable set)
# - Official mTCP sources as a git submodule in ./mtcp/ (pinned to the
# "2025-01-10" release tag of https://github.com/mbbrutman/mTCP.git):
# git clone --recursive <this repo> (fresh clone)
# git submodule update --init (existing checkout)
#
# Submodule layout (sources live under src/):
# ./mtcp/src/TCPLIB/ = TCP/IP library sources (.CPP)
# ./mtcp/src/TCPINC/ = TCP/IP header files
# ./mtcp/src/INCLUDE/ = cross-app shared includes
# ./mtcp/src/APPS/FTP/ = reference FTP client (for looking things up)
#
# Build: wmake
# Clean: wmake clean
# =============================================================================
CC = wcc
CPP = wpp
ASM = wasm
LINK = wlink
RM = del /Q /F
# -----------------------------------------------------------------------------
# Compiler flags
# -ml = Large Memory Model
# -0 = 8086 instruction set (compatible with 8086/286/386+)
# -zu = SS != DS (mandatory for mTCP!)
# -s = no stack overflow check
# -ox = maximum optimization
# -bt=dos = DOS target
# -zp1 = byte alignment in structs
# -ei = enum as int
# -----------------------------------------------------------------------------
CFLAGS = -ml -0 -zu -s -ox -bt=dos -zp1 -ei
INCPATH = -I./src -I./mtcp/src/TCPINC -I./mtcp/src/INCLUDE
# -----------------------------------------------------------------------------
# Output
# -----------------------------------------------------------------------------
TARGET = FTP4DOS.EXE
MAPFILE = FTP4DOS.MAP
# -----------------------------------------------------------------------------
# Application objects
# -----------------------------------------------------------------------------
APP_OBJS = &
src\ncftp.obj &
src\tui.obj &
src\panel.obj &
src\lpanel.obj &
src\lfn.obj &
src\rpanel.obj &
src\netcore.obj &
src\ftpcli.obj &
src\httpget.obj &
src\update.obj &
src\sha256.obj &
src\rsaverify.obj &
src\rsakeys.obj &
src\dialog.obj &
src\viewer.obj &
src\gfx.obj &
src\imgview.obj &
src\img_bmp.obj &
src\img_pcx.obj &
src\img_gif.obj &
src\img_png.obj &
src\inflate.obj &
src\editor.obj &
src\dircopy.obj &
src\connsave.obj &
src\sites.obj &
src\entrystore.obj &
src\extmem.obj &
src\namestore.obj &
src\checksum.obj &
src\cpmap.obj &
src\i18n.obj
# -----------------------------------------------------------------------------
# mTCP core objects (from TCPLIB/)
# See mtcp\src\APPS\FTP\makefile for the exact file list.
# File list for the official 2025-01-10 version. Compared to older mTCP
# versions, trace.obj was added as a fixed dependency of the FTP client.
# -----------------------------------------------------------------------------
MTCP_OBJS = &
mtcp\src\TCPLIB\arp.obj &
mtcp\src\TCPLIB\dns.obj &
mtcp\src\TCPLIB\eth.obj &
mtcp\src\TCPLIB\ip.obj &
mtcp\src\TCPLIB\ipasm.obj &
mtcp\src\TCPLIB\packet.obj &
mtcp\src\TCPLIB\tcp.obj &
mtcp\src\TCPLIB\tcpsockm.obj &
mtcp\src\TCPLIB\timer.obj &
mtcp\src\TCPLIB\trace.obj &
mtcp\src\TCPLIB\udp.obj &
mtcp\src\TCPLIB\utils.obj
ALL_OBJS = $(APP_OBJS) $(MTCP_OBJS)
# -----------------------------------------------------------------------------
# Main target
# -----------------------------------------------------------------------------
all: $(TARGET) .SYMBOLIC
$(TARGET): $(ALL_OBJS)
$(LINK) &
system dos &
option stack=32768 &
option map=$(MAPFILE) &
name $(TARGET) &
file { $(ALL_OBJS) }
@echo.
@echo Build successful: $(TARGET)
# -----------------------------------------------------------------------------
# Application sources
# -----------------------------------------------------------------------------
# -zt256: put the large panel globals (g_left/g_right, ~25 KB each) into
# FAR data segments so DGROUP (64 KB, large model) doesn't overflow.
src\ncftp.obj: src\ncftp.cpp src\tui.h src\panel.h src\entrystore.h src\extmem.h src\lpanel.h src\rpanel.h src\ftpcli.h src\keymap.h src\dialog.h src\viewer.h src\imgview.h src\imgdec.h src\editor.h src\dircopy.h src\connsave.h src\sites.h src\checksum.h src\i18n.h src\lfn.h src\umlaut.h
$(CPP) $(CFLAGS) -zt256 $(INCPATH) -fo=$@ $[@
src\tui.obj: src\tui.cpp src\tui.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\panel.obj: src\panel.cpp src\panel.h src\entrystore.h src\namestore.h src\tui.h src\i18n.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\lpanel.obj: src\lpanel.cpp src\lpanel.h src\panel.h src\namestore.h src\tui.h src\lfn.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\lfn.obj: src\lfn.cpp src\lfn.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\rpanel.obj: src\rpanel.cpp src\rpanel.h src\panel.h src\namestore.h src\tui.h src\ftpcli.h src\cpmap.h src\i18n.h src\umlaut.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
# netcore pulls in mTCP headers, so it needs CFG_H just like ftpcli.
src\netcore.obj: src\netcore.cpp src\netcore.h src\ncftp.cfg
$(CPP) $(CFLAGS) -DCFG_H="ncftp.cfg" $(INCPATH) -fo=$@ $[@
src\ftpcli.obj: src\ftpcli.cpp src\ftpcli.h src\netcore.h src\ncftp.cfg src\cpmap.h src\i18n.h
$(CPP) $(CFLAGS) -DCFG_H="ncftp.cfg" $(INCPATH) -fo=$@ $[@
# httpget pulls in mTCP headers, so it needs CFG_H just like ftpcli.
src\httpget.obj: src\httpget.cpp src\httpget.h src\netcore.h src\ncftp.cfg src\lfn.h src\i18n.h src\umlaut.h
$(CPP) $(CFLAGS) -DCFG_H="ncftp.cfg" $(INCPATH) -fo=$@ $[@
# update reads MTCP.CFG for the optional host override, so it needs CFG_H.
src\update.obj: src\update.cpp src\update.h src\httpget.h src\sha256.h src\rsaverify.h src\rsakeys.h src\ncftp.cfg src\lfn.h src\i18n.h src\umlaut.h
$(CPP) $(CFLAGS) -DCFG_H="ncftp.cfg" $(INCPATH) -fo=$@ $[@
# Crypto for the signed auto-updater. Both are free of DOS/TUI/mTCP
# dependencies, so no CFG_H here - and they build on the host too, which is
# what tools/test-crypto.ps1 exercises.
src\sha256.obj: src\sha256.cpp src\sha256.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\rsaverify.obj: src\rsaverify.cpp src\rsaverify.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
# -zt64 keeps the two 256-byte public-key arrays out of the scarce DGROUP.
src\rsakeys.obj: src\rsakeys.cpp src\rsakeys.h
$(CPP) $(CFLAGS) -zt64 $(INCPATH) -fo=$@ $[@
src\dialog.obj: src\dialog.cpp src\dialog.h src\tui.h src\keymap.h src\i18n.h src\sites.h src\connsave.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\viewer.obj: src\viewer.cpp src\viewer.h src\tui.h src\keymap.h src\dialog.h src\i18n.h src\umlaut.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\gfx.obj: src\gfx.cpp src\gfx.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\imgview.obj: src\imgview.cpp src\imgview.h src\imgdec.h src\gfx.h src\extmem.h src\tui.h src\keymap.h src\dialog.h src\i18n.h src\umlaut.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\img_bmp.obj: src\img_bmp.cpp src\imgdec.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\img_pcx.obj: src\img_pcx.cpp src\imgdec.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\img_gif.obj: src\img_gif.cpp src\imgdec.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\img_png.obj: src\img_png.cpp src\imgdec.h src\inflate.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\inflate.obj: src\inflate.cpp src\inflate.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\editor.obj: src\editor.cpp src\editor.h src\tui.h src\keymap.h src\dialog.h src\i18n.h src\umlaut.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\dircopy.obj: src\dircopy.cpp src\dircopy.h src\ftpcli.h src\panel.h src\rpanel.h src\cpmap.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\connsave.obj: src\connsave.cpp src\connsave.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\sites.obj: src\sites.cpp src\sites.h src\connsave.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\entrystore.obj: src\entrystore.cpp src\entrystore.h src\panel.h src\extmem.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\extmem.obj: src\extmem.cpp src\extmem.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\namestore.obj: src\namestore.cpp src\namestore.h src\extmem.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\checksum.obj: src\checksum.cpp src\checksum.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\cpmap.obj: src\cpmap.cpp src\cpmap.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
src\i18n.obj: src\i18n.cpp src\i18n.h
$(CPP) $(CFLAGS) $(INCPATH) -fo=$@ $[@
# -----------------------------------------------------------------------------
# mTCP core sources (TCPLIB/)
# Flags: additionally -I./mtcp/src/TCPLIB for internal mTCP includes
# -----------------------------------------------------------------------------
# -DCFG_H="ncftp.cfg": every mTCP header does `#include CFG_H`.
# ncftp.cfg lives in src/ and is found via -I./src (in INCPATH).
# No -zp2: since the mTCP reference build is warning-free with
# -zp2 -zpw -we, -zp2 doesn't add any padding -> the layout is identical
# to our -zp1. This keeps all objects (including ftpcli.obj with inline
# methods from tcp.h) consistent at -zp1.
#
# IMPORTANT: mTCP is built with -0 (8086), NOT with -3 (386)!
# packet.cpp::receiver() is the receive callback invoked by the packet
# driver via FAR CALL. It has a HAND-WRITTEN assembler epilogue
# (pop ax/ax/es/ds/di/si/bp/bx/bx/dx/cx/ax; retf = 12 words + retf) that
# exactly matches the 8086 __interrupt prologue (push ax/cx/dx/bx/sp/bp/si/di +
# ds/es + 2 pad = 12 words). With -3, the compiler prologue ADDITIONALLY
# saves the 386 segment registers FS and GS (pusha+ds+es+fs+gs+sub sp,4 =
# 14 words), which the fixed epilogue does NOT pop back -> after the 12
# pops, FS/GS are still left on the stack -> retf reads garbage as the
# return address -> a hard hang in interrupt context on the FIRST received
# packet (Ctrl+Alt+Del dead). Verified via wdis disassembly. The mTCP
# reference (APPS/FTP/MAKEFILE) also builds with -0. 8086 code runs fine
# on the 386; the application code is built with -0 as well (see CFLAGS).
# (ipasm.asm: already wasm -0, see below.)
MCFLAGS = -ml -0 -zu -s -ox -bt=dos -zp1 -ei
MFLAGS = $(MCFLAGS) -DCFG_H="ncftp.cfg" -I./mtcp/src/TCPLIB $(INCPATH)
mtcp\src\TCPLIB\arp.obj: mtcp\src\TCPLIB\arp.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\dns.obj: mtcp\src\TCPLIB\dns.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\eth.obj: mtcp\src\TCPLIB\eth.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\ip.obj: mtcp\src\TCPLIB\ip.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
# ipasm.asm selects the memory model via __LARGE__ (set by wasm -ml).
mtcp\src\TCPLIB\ipasm.obj: mtcp\src\TCPLIB\ipasm.asm
$(ASM) -0 -ml -fo=$@ $[@
mtcp\src\TCPLIB\packet.obj: mtcp\src\TCPLIB\packet.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\tcp.obj: mtcp\src\TCPLIB\tcp.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\tcpsockm.obj: mtcp\src\TCPLIB\tcpsockm.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\timer.obj: mtcp\src\TCPLIB\timer.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\trace.obj: mtcp\src\TCPLIB\trace.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\udp.obj: mtcp\src\TCPLIB\udp.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
mtcp\src\TCPLIB\utils.obj: mtcp\src\TCPLIB\utils.cpp src\ncftp.cfg
$(CPP) $(MFLAGS) -fo=$@ $[@
# -----------------------------------------------------------------------------
# Cleanup
# -----------------------------------------------------------------------------
clean: .SYMBOLIC
-$(RM) src\*.obj 2>nul
-$(RM) mtcp\src\TCPLIB\*.obj 2>nul
-$(RM) $(TARGET) 2>nul
-$(RM) $(MAPFILE) 2>nul
@echo Clean complete.