-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
269 lines (200 loc) · 6.94 KB
/
makefile
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
#------------------------------------------------------------------------------
# Protected mode interface (PMI) makefile
#------------------------------------------------------------------------------
# Compiler options
nasm_dos_opts = -i "src" -f obj
nasm_pe_opts = -i "src" -f win32
# Build mode
# Set to "release" in command line parameter to create a release build.
# Example for full recompilation of the release version:
# wmake build=release full
build = debug
# Target stub EXE file without extension
pmi = build build\$(build) build\$(build)\obj &
build\$(build)\pmi.exe
# List of runtime library object files
rtl = build build\$(build) build\$(build)\rtl &
build\$(build)\rtl\env_arg.obj &
build\$(build)\rtl\irq.obj &
build\$(build)\rtl\keyboard.obj &
build\$(build)\rtl\log.obj &
build\$(build)\rtl\profiler.obj &
build\$(build)\rtl\string.obj &
build\$(build)\rtl\systimer.obj &
build\$(build)\rtl\timer.obj
# Validate build target environment value
build_ok = 0
!ifeq build debug
%exceptions = 1
build_ok = 1
!endif
!ifeq build release
%exceptions =
build_ok = 1
!endif
!ifneq build_ok 1
pmi = abort
rtl = abort
!endif
# Append \ at the end of nasm/watcom path variables if not empty
!ifneq nasm_dir
nasm_dir = $(nasm_dir)\
!endif
!ifneq watcom_dir
watcom_dir = $(watcom_dir)\
!endif
# Build PMI and RTL
incremental: $(pmi) $(rtl)
full: clean $(pmi) $(rtl)
# Create binary distribution package
dist: .SYMBOLIC
$(watcom_dir)wmake full
$(watcom_dir)wmake build=release full
@if not exist dist mkdir dist
@if not exist dist\debug mkdir dist\debug
@if not exist dist\debug\rtl mkdir dist\debug\rtl
@if not exist dist\release mkdir dist\release
@if not exist dist\release\rtl mkdir dist\release\rtl
@copy build\debug\pmi.exe dist\debug
@copy build\debug\rtl\*.obj dist\debug\rtl
@copy build\release\pmi.exe dist\release
@copy build\release\rtl\*.obj dist\release\rtl
@copy README.md dist
# Cleanup
clean: .SYMBOLIC .MULTIPLE
@if exist build\$(build)\obj del /q build\$(build)\obj\*.*
@if exist build\$(build)\obj rmdir build\$(build)\obj
@if exist build\$(build)\rtl del /q build\$(build)\rtl\*.*
@if exist build\$(build)\rtl rmdir build\$(build)\rtl
@if exist build\$(build) del /q build\$(build)\*.*
#------------------------------------------------------------------------------
# Build PMI stub
#------------------------------------------------------------------------------
# List of PMI stub objects
pmi_objs = &
build\$(build)\obj\pmi.obj &
build\$(build)\obj\kernel.obj &
build\$(build)\obj\memory.obj &
build\$(build)\obj\file.obj &
build\$(build)\obj\program.obj &
build\$(build)\obj\dma.obj
# Abort if unknown build environment is given
abort:
echo "$(build)" is not a valid build target.
@%abort
# Create directory for binary files
build: .SYMBOLIC .ALWAYS
@if not exist build mkdir build
build\$(build): build .SYMBOLIC .ALWAYS
@if not exist build\$(build) mkdir build\$(build)
build\$(build)\obj: build\$(build) .SYMBOLIC .ALWAYS
@if not exist build\$(build)\obj mkdir build\$(build)\obj
# Binary build and link
build\$(build)\pmi.exe: $(pmi_objs) build\$(build)
@%create build\$(build)\obj\pmi.lnk
@%write build\$(build)\obj\pmi.lnk NAME build\$(build)\pmi
@%write build\$(build)\obj\pmi.lnk OPTION dosseg
@%write build\$(build)\obj\pmi.lnk OPTION map=build\$(build)\obj\pmi.map
@%write build\$(build)\obj\pmi.lnk OPTION packcode=0
@%write build\$(build)\obj\pmi.lnk OPTION packdata=0
@%write build\$(build)\obj\pmi.lnk FORM dos
@%write build\$(build)\obj\pmi.lnk FILE {$(pmi_objs)}
$(watcom_dir)wlink @build\$(build)\obj\pmi.lnk
# .obj file dependencies with included external files and build instructions
build\$(build)\obj\dma.obj: src\pmi\dma.asm &
src\pmi\config.inc &
src\pmi\api\pmi.inc &
src\pmi\api\kernel.inc &
src\pmi\structs\dma.inc
$(nasm_dir)nasm $(nasm_dos_opts) $[@ -o $^@
build\$(build)\obj\file.obj: src\pmi\file.asm &
src\pmi\config.inc &
src\pmi\api\pmi.inc &
src\pmi\api\kernel.inc &
src\pmi\api\memory.inc
$(nasm_dir)nasm $(nasm_dos_opts) $[@ -o $^@
build\$(build)\obj\kernel.obj: src\pmi\kernel.asm &
src\pmi\config.inc &
src\pmi\api\pmi.inc &
src\pmi\api\memory.inc &
src\pmi\api\file.inc &
src\pmi\api\dma.inc &
src\pmi\api\program.inc &
src\pmi\consts\kernel.inc &
src\pmi\structs\kernel.inc &
src\pmi\structs\memory.inc
$(nasm_dir)nasm $(nasm_dos_opts) $[@ -o $^@
build\$(build)\obj\memory.obj: src\pmi\memory.asm &
src\pmi\config.inc &
src\pmi\api\pmi.inc &
src\pmi\api\kernel.inc &
src\pmi\consts\kernel.inc &
src\pmi\consts\memory.inc &
src\pmi\structs\memory.inc
$(nasm_dir)nasm $(nasm_dos_opts) $[@ -o $^@
build\$(build)\obj\pmi.obj: src\pmi\pmi.asm &
src\pmi\config.inc &
src\pmi\api\pmi.inc &
src\pmi\api\kernel.inc &
src\pmi\consts\kernel.inc &
src\pmi\structs\kernel.inc
$(nasm_dir)nasm $(nasm_dos_opts) $[@ -o $^@
build\$(build)\obj\program.obj: src\pmi\program.asm &
src\pmi\config.inc &
src\pmi\api\pmi.inc &
src\pmi\api\kernel.inc &
src\pmi\api\memory.inc &
src\pmi\api\file.inc &
src\pmi\consts\memory.inc &
src\pmi\structs\memory.inc &
src\pmi\structs\program.inc
$(nasm_dir)nasm $(nasm_dos_opts) $[@ -o $^@
#------------------------------------------------------------------------------
# Build PMI runtime library
#------------------------------------------------------------------------------
# Create directory for RTL .obj files
build\$(build)\rtl: build build\$(build) .SYMBOLIC .ALWAYS
@if not exist build\$(build)\rtl mkdir build\$(build)\rtl
# .inc file dependencies
src\rtl\api\log.inc: &
src\rtl\consts\log.inc
$(watcom_dir)wtouch src\rtl\api\log.inc
src\rtl\api\string.inc: &
src\rtl\consts\string.inc
$(watcom_dir)wtouch src\rtl\api\string.inc
# .obj file dependencies with included external files and build instructions
build\$(build)\rtl\env_arg.obj: src\rtl\env_arg.asm &
src\pmi\api\pmi.inc
$(nasm_dir)nasm $(nasm_pe_opts) $[@ -o $^@
build\$(build)\rtl\irq.obj: src\rtl\irq.asm &
src\pmi\api\pmi.inc
$(nasm_dir)nasm $(nasm_pe_opts) $[@ -o $^@
build\$(build)\rtl\keyboard.obj: src\rtl\keyboard.asm &
src\pmi\api\pmi.inc &
src\rtl\api\irq.inc &
src\rtl\consts\keyboard.inc &
src\rtl\kblayout\us.inc
$(nasm_dir)nasm $(nasm_pe_opts) $[@ -o $^@
build\$(build)\rtl\log.obj: src\rtl\log.asm &
src\pmi\api\pmi.inc &
src\pmi\structs\memory.inc &
src\pmi\consts\memory.inc &
src\pmi\structs\program.inc &
src\rtl\api\string.inc &
src\rtl\consts\log.inc
$(nasm_dir)nasm $(nasm_pe_opts) $[@ -o $^@
build\$(build)\rtl\profiler.obj: src\rtl\profiler.asm &
src\pmi\api\pmi.inc &
src\rtl\api\systimer.inc
$(nasm_dir)nasm $(nasm_pe_opts) $[@ -o $^@
build\$(build)\rtl\string.obj: src\rtl\string.asm &
src\rtl\consts\string.inc
$(nasm_dir)nasm $(nasm_pe_opts) $[@ -o $^@
build\$(build)\rtl\systimer.obj: src\rtl\systimer.asm &
src\pmi\api\pmi.inc &
src\rtl\api\irq.inc
$(nasm_dir)nasm $(nasm_pe_opts) $[@ -o $^@
build\$(build)\rtl\timer.obj: src\rtl\timer.asm &
src\pmi\api\pmi.inc &
src\rtl\api\irq.inc
$(nasm_dir)nasm $(nasm_pe_opts) $[@ -o $^@