forked from msikma/allegro-4.2.2-xc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile.bcc
499 lines (389 loc) · 12.9 KB
/
makefile.bcc
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
#
# Rules for building the Allegro library with Borland C++Builder (BCC32)
# This file is included by the primary makefile, and should not be used
# directly.
#
# The "depend" target uses sed.
#
# See makefile.all for a list of the available targets.
# -------- define some variables that the primary makefile will use --------
PLATFORM = BCC32
GCC = gcc
EXE = .exe
OBJ = .obj
HTML = html
PLATFORM_DIR = obj/bcc32
ifneq (,$(findstring bash,$(SHELL)))
UNIX_TOOLS = 1
endif
# -------- link as a DLL --------
OBJ_DIR = obj/bcc32/$(VERSION)
DLL_BASENAME = $(VERSION)$(LIBRARY_VERSION).dll
DLL_NAME = lib/bcc32/$(DLL_BASENAME)
IMPLIB_BASENAME = $(VERSION).lib
IMPLIB_NAME = lib/bcc32/$(IMPLIB_BASENAME)
LIB_NAME = $(IMPLIB_NAME)
EXPDEF_NAME = lib/bcc32/allegro.def
# -------- check that environment path variables are set --------
.PHONY: badwin badbcc32
ifeq ($(OS),Windows_NT)
WINSYSDIR = $(SYSTEMROOT)
ifeq ($(WINSYSDIR),)
WINSYSDIR = $(SystemRoot)
endif
WINSUBDIR = system32
else
WINSYSDIR = $(WINDIR)
ifeq ($(WINSYSDIR),)
WINSYSDIR = $(windir)
endif
WINSUBDIR = system
endif
ifneq ($(WINSYSDIR),)
WINDIR_U = $(subst \,/,$(WINSYSDIR)/$(WINSUBDIR))
WINDIR_D = $(subst /,\,$(WINSYSDIR)/$(WINSUBDIR))
else
badwin:
@echo Your SYSTEMROOT or windir environment variable is not set!
endif
ifdef BCC32DIR
BCC32DIR_U = $(subst \,/,$(BCC32DIR))
BCC32DIR_D = $(subst /,\,$(BCC32DIR))
else
badbcc32:
@echo Your BCC32DIR environment variable is not set!
@echo See the docs/build/bcc32.txt file!
endif
NULLSTRING :=
SPACE := $(NULLSTRING) # special magic to get an isolated space character
ifneq ($(findstring $(SPACE),$(BCC32DIR)),)
badspaces:
@echo There are spaces in your BCC32DIR environment variable:
@echo please change it to the 8.3 short filename version,
@echo or move your compiler to a different directory.
endif
# -------- give a sensible default target for make without any args --------
.PHONY: _default
_default: default
# -------- decide what compiler options to use --------
ifdef WARNMODE
WFLAGS = -w
else
WFLAGS = -w-8060
endif
OFLAGS = -O2 -OS
ifdef DEBUGMODE
# -------- debugging build --------
CFLAGS = -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS) -Od -q -R -v
SFLAGS = -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS)
LFLAGS += -q -Gn -v
else
ifdef PROFILEMODE
# -------- profiling build --------
CFLAGS = $(WFLAGS) $(OFLAGS) -q -R -v
SFLAGS = $(WFLAGS)
LFLAGS += -q -Gn -v
else
# -------- optimised build --------
CFLAGS = $(WFLAGS) $(OFLAGS) -q
SFLAGS = $(WFLAGS)
LFLAGS += -x -q -Gn
DELETE_TDS_FILES = 1
endif
endif
# -------- list platform specific objects and programs --------
VPATH = tests/win tools/win
LIBRARIES = cw32 import32
PROGRAMS = dibgrab dibhello dibsound dxwindow scrsave wfixicon
dibgrab: tests/win/dibgrab.exe
dibhello: tests/win/dibhello.exe
dibsound: tests/win/dibsound.exe
dxwindow: tests/win/dxwindow.exe
scrsave: tests/win/scrsave.scr
wfixicon: tools/win/wfixicon.exe
# -------- rules for installing and removing the library files --------
INSTALLDIR = $(BCC32DIR_U)
LIBDIR = lib
INCDIR = include
ifdef UNIX_TOOLS
$(BCC32DIR_U)/lib/$(IMPLIB_BASENAME): $(IMPLIB_NAME) $(BCC32DIR_U)/lib
cp lib/bcc32/$(IMPLIB_BASENAME) $(BCC32DIR_U)/lib
$(WINDIR_U)/$(DLL_BASENAME): lib/msvc/$(DLL_BASENAME)
cp lib/msvc/$(DLL_BASENAME) $(WINDIR_U)
else
$(BCC32DIR_U)/lib/$(IMPLIB_BASENAME): $(IMPLIB_NAME) $(BCC32DIR_U)/lib
copy lib\bcc32\$(IMPLIB_BASENAME) $(BCC32DIR_D)\lib
$(WINDIR_U)/$(DLL_BASENAME): lib/msvc/$(DLL_BASENAME)
copy lib\msvc\$(DLL_BASENAME) $(WINDIR_D)
endif # UNIX_TOOLS
HEADERS = $(BCC32DIR_U)/include/winalleg.h \
$(BCC32DIR_U)/include/allegro/platform/aintwin.h \
$(BCC32DIR_U)/include/allegro/platform/al386gcc.h \
$(BCC32DIR_U)/include/allegro/platform/albcc32.h \
$(BCC32DIR_U)/include/allegro/platform/alplatf.h \
$(BCC32DIR_U)/include/allegro/platform/astdint.h \
$(BCC32DIR_U)/include/allegro/platform/alwin.h
INSTALL_FILES = $(BCC32DIR_U)/lib/$(IMPLIB_BASENAME)
ifneq ($(wildcard lib/msvc/$(DLL_BASENAME)),)
INSTALL_FILES += $(WINDIR_U)/$(DLL_BASENAME)
endif
INSTALL_FILES += $(HEADERS)
install: generic-install
@echo The $(DESCRIPTION) $(PLATFORM) library has been installed.
UNINSTALL_FILES = $(BCC32DIR_U)/lib/alleg.lib \
$(BCC32DIR_U)/lib/alld.lib \
$(BCC32DIR_U)/lib/allp.lib \
$(WINDIR_U)/alleg$(LIBRARY_VERSION).dll \
$(WINDIR_U)/alld$(LIBRARY_VERSION).dll \
$(WINDIR_U)/allp$(LIBRARY_VERSION).dll \
$(HEADERS)
uninstall: generic-uninstall
@echo All gone!
# -------- helper function for compressing the executables --------
.PHONY: compress
compress:
ifdef UPX_BIN
$(UPX_BIN) demo/*.exe examples/*.exe setup/*.exe tests/*.exe tools/*.exe lib/mingw32/all*.dll
else
@echo No executable compressor specified! You must set the environment variable
@echo UPX_BIN to point to upx.exe.
endif
# -------- test capabilities --------
TEST_CPP = @echo ...integrated
include makefile.tst
# -------- link as a DLL (sort of ;-) --------
ifdef UNIX_TOOLS
define MAKE_LIB
echo LIBRARY $(DLL_BASENAME) > _allegro.def
cat _allegro.def $(EXPDEF_NAME) > _allegr2.def
implib $(subst /,\,$(IMPLIB_NAME)) _allegr2.def
rm _allegro.def _allegr2.def
endef
else
define MAKE_LIB
echo LIBRARY $(DLL_BASENAME) > _allegro.def
copy _allegro.def + $(subst /,\,$(EXPDEF_NAME)) _allegr2.def
implib $(subst /,\,$(IMPLIB_NAME)) _allegr2.def
del _allegro.def
del _allegr2.def
endef
endif
COMPILE_FLAGS += $(subst src/,-DALLEGRO_SRC ,$(findstring src/, $<))$(CFLAGS)
$(OBJ_DIR)/%.obj: %.c
bcc32 $(COMPILE_FLAGS) -W -I. -I./include -c -o$(subst /,\,$@) $(subst /,\,$<)
$(OBJ_DIR)/%.obj: %.cpp
bcc32 $(COMPILE_FLAGS) -W -I. -I./include -c -o$(subst /,\,$@) $(subst /,\,$<)
obj/bcc32/%.res: %.rc
brcc32 -i $(BCC32DIR)\include -fo $(subst /,\,$@) $(subst /,\,$<)
tests/win/dibsound.exe: $(OBJ_DIR)/dibsound.obj obj/bcc32/dibsound.res $(IMPLIB_NAME)
@echo obj\\bcc32\\dibsound.res > res.rsp
ilink32 $(LFLAGS) -aa -Tpe c0w32 $(subst /,\,$(OBJ_DIR)/dibsound.obj),tests\win\dibsound.exe,,$(subst /,\,$(LIB_NAME) $(LIBRARIES)),,@res.rsp
ifdef UNIX_TOOLS
@rm res.rsp
ifdef DELETE_TDS_FILES
@rm tests/win/dibsound.tds
endif
else
@del res.rsp
ifdef DELETE_TDS_FILES
@del tests\win\dibsound.tds
endif
endif
tests/win/dxwindow.exe: $(OBJ_DIR)/dxwindow.obj obj/bcc32/dxwindow.res $(IMPLIB_NAME)
@echo obj\\bcc32\\dxwindow.res > res.rsp
ilink32 $(LFLAGS) -aa -Tpe c0w32 $(subst /,\,$(OBJ_DIR)/dxwindow.obj),tests\win\dxwindow.exe,,$(subst /,\,$(LIB_NAME) $(LIBRARIES)),,@res.rsp
ifdef UNIX_TOOLS
@rm res.rsp
ifdef DELETE_TDS_FILES
@rm tests/win/dxwindow.tds
endif
else
@del res.rsp
ifdef DELETE_TDS_FILES
@del tests\win\dxwindow.tds
endif
endif
tests/win/%.exe: $(OBJ_DIR)/%.obj $(IMPLIB_NAME)
ilink32 $(LFLAGS) -aa -Tpe c0w32 $(subst /,\,$<),$(subst /,\,$@),,$(subst /,\,$(LIB_NAME) $(LIBRARIES))
ifdef DELETE_TDS_FILES
ifdef UNIX_TOOLS
@rm $(subst .exe,.tds,$@)
else
@del $(subst .exe,.tds,$(subst /,\,$@))
endif
endif
tests/win/scrsave.scr: $(OBJ_DIR)/scrsave.obj obj/bcc32/scrsave.res $(IMPLIB_NAME)
@echo obj\\bcc32\\scrsave.res > res.rsp
ilink32 $(LFLAGS) -aa -Tpe c0w32 $(subst /,\,$(OBJ_DIR)/scrsave.obj),tests\win\scrsave.scr,,$(subst /,\,$(LIB_NAME) $(LIBRARIES)),,@res.rsp
ifdef UNIX_TOOLS
@rm res.rsp
ifdef DELETE_TDS_FILES
@rm tests/win/scrsave.tds
endif
else
@del res.rsp
ifdef DELETE_TDS_FILES
@del tests\win\scrsave.tds
endif
endif
tools/win/%.exe: $(OBJ_DIR)/%.obj $(IMPLIB_NAME)
ilink32 $(LFLAGS) -ap -Tpe c0x32 $(subst /,\,$<),$(subst /,\,$@),,$(subst /,\,$(LIB_NAME) $(LIBRARIES))
ifdef DELETE_TDS_FILES
ifdef UNIX_TOOLS
@rm $(subst .exe,.tds,$@)
else
@del $(subst .exe,.tds,$(subst /,\,$@))
endif
endif
*/%.exe: $(OBJ_DIR)/%.obj $(IMPLIB_NAME)
ilink32 $(LFLAGS) -aa -Tpe c0w32 $(subst /,\,$<),$(subst /,\,$@),,$(subst /,\,$(LIB_NAME) $(LIBRARIES))
ifdef DELETE_TDS_FILES
ifdef UNIX_TOOLS
@rm $(subst .exe,.tds,$@)
else
@del $(subst .exe,.tds,$(subst /,\,$@))
endif
endif
LINK_CONSOLE_DEPS = $(IMPLIB_NAME)
define DO_LINK_CONSOLE
ilink32 $(LFLAGS) -ap -Tpe c0x32 $(subst /,\,$<),$(subst /,\,$@),,$(subst /,\,$(LIB_NAME) $(LIBRARIES))
endef
ifdef DELETE_TDS_FILES
ifdef UNIX_TOOLS
define LINK_CONSOLE
$(DO_LINK_CONSOLE)
@rm $(subst .exe,.tds,$@)
endef
else
define LINK_CONSOLE
$(DO_LINK_CONSOLE)
@del $(subst .exe,.tds,$(subst /,\,$@))
endef
endif
else
LINK_CONSOLE = $(DO_LINK_CONSOLE)
endif
define DO_LINK_WITHOUT_LIB
$(foreach objfile, $^, echo $(subst /,\\,$(objfile)) + >> obj.rsp
)
ilink32 $(LFLAGS) -ap -Tpe c0x32 @obj.rsp,$(subst /,\,$@),,$(LIBRARIES)
del obj.rsp
endef
ifdef DELETE_TDS_FILES
ifdef UNIX_TOOLS
define LINK_WITHOUT_LIB
$(DO_LINK_WITHOUT_LIB)
@rm $(subst .exe,.tds,$@)
endef
else
define LINK_WITHOUT_LIB
$(DO_LINK_WITHOUT_LIB)
@del $(subst .exe,.tds,$(subst /,\,$@))
endef
endif
else
LINK_WITHOUT_LIB = $(DO_LINK_WITHOUT_LIB)
endif
PLUGIN_LIB = lib/bcc32/$(VERY_SHORT_VERSION)dat.lib
PLUGINS_H = obj/bcc32/plugins.h
PLUGIN_DEPS = $(LIB_NAME) $(PLUGIN_LIB)
PLUGIN_SCR = scv
ifdef UNIX_TOOLS
define GENERATE_PLUGINS_H
cat tools/plugins/*.inc > obj/bcc32/plugins.h
endef
else
define GENERATE_PLUGINS_H
copy /B tools\plugins\*.inc obj\bcc32\plugins.h
endef
endif
ifdef UNIX_TOOLS
define MAKE_PLUGIN_LIB
$(foreach objfile, $(PLUGIN_OBJS), tlib $(subst /,\,$(PLUGIN_LIB) + $(objfile))
)
@rm $(subst .lib,.BAK,$(PLUGIN_LIB))
endef
else
define MAKE_PLUGIN_LIB
$(foreach objfile, $(PLUGIN_OBJS), tlib $(subst /,\,$(PLUGIN_LIB) + $(objfile))
)
@del $(subst .lib,.BAK,$(subst /,\,$(PLUGIN_LIB)))
endef
endif
define DO_LINK_WITH_PLUGINS
ilink32 $(LFLAGS) -aa -Tpe c0w32 $(subst /,\,$<),$(subst /,\,$@),,$(subst /,\,$(LIB_NAME) $(PLUGIN_LIB) $(LIBRARIES))
endef
ifdef DELETE_TDS_FILES
ifdef UNIX_TOOLS
define LINK_WITH_PLUGINS
$(DO_LINK_WITH_PLUGINS)
@rm $(subst .exe,.tds,$@)
endef
else
define LINK_WITH_PLUGINS
$(DO_LINK_WITH_PLUGINS)
@del $(subst .exe,.tds,$(subst /,\,$@))
endef
endif
else
LINK_WITH_PLUGINS = $(DO_LINK_WITH_PLUGINS)
endif
define DO_LINK_CONSOLE_WITH_PLUGINS
ilink32 $(LFLAGS) -ap -Tpe c0x32 $(subst /,\,$<),$(subst /,\,$@),,$(subst /,\,$(LIB_NAME) $(PLUGIN_LIB) $(LIBRARIES))
endef
ifdef DELETE_TDS_FILES
ifdef UNIX_TOOLS
define LINK_CONSOLE_WITH_PLUGINS
$(DO_LINK_CONSOLE_WITH_PLUGINS)
@rm $(subst .exe,.tds,$@)
endef
else
define LINK_CONSOLE_WITH_PLUGINS
$(DO_LINK_CONSOLE_WITH_PLUGINS)
@del $(subst .exe,.tds,$(subst /,\,$@))
endef
endif
else
LINK_CONSOLE_WITH_PLUGINS = $(DO_LINK_CONSOLE_WITH_PLUGINS)
endif
# -------- link demo --------
demo/demo.exe: $(OBJ_DIR)/demo.obj $(OBJ_DIR)/demo.res
ilink32 $(LFLAGS) -aa -Tpe c0w32 $(subst /,\,$(OBJECTS_DEMO)),demo\demo.exe,,$(subst /,\,$(LIB_NAME) $(LIBRARIES))
# -------- demo program iconification --------
.PHONY: fixdemo
$(OBJ_DIR)/demo.res: demo/demo.dat tools/win/wfixicon.exe
tools/win/wfixicon.exe $(OBJ_DIR)/demo.ico -ro -d demo/demo.dat SHIP3 GAME_PAL
fixdemo: $(OBJ_DIR)/demo.obj $(OBJ_DIR)/demo.res $(IMPLIB_NAME)
@echo $(subst /,\\,$(OBJ_DIR)/demo.res) > res.rsp
ilink32 $(LFLAGS) -aa -Tpe c0w32 $(subst /,\,$(OBJ_DIR)/demo.obj),demo\demo.exe,,$(subst /,\,$(LIB_NAME) $(LIBRARIES)),,@res.rsp
ifdef UNIX_TOOLS
@rm res.rsp
ifdef DELETE_TDS_FILES
@rm demo/demo.tds
endif
else
@del res.rsp
ifdef DELETE_TDS_FILES
@del demo\demo.tds
endif
endif
# -------- generate automatic dependencies --------
DEPEND_PARAMS = -MM -MG -I. -I./include -DSCAN_DEPEND -DALLEGRO_BCC32
depend:
$(GCC) $(DEPEND_PARAMS) demo/*.c docs/src/makedoc/*.c examples/*.c setup/*.c tests/*.c > _depend.tmp
$(GCC) $(DEPEND_PARAMS) tests/win/*.c tools/*.c tools/win/*.c tools/plugins/*.c >> _depend.tmp
$(GCC) $(DEPEND_PARAMS) -x c tests/*.cpp >> _depend.tmp
sed -e "s/^[a-zA-Z0-9_\/]*\///" _depend.tmp > _depend2.tmp
sed -e "s/asmdef\.o/asmdef\.exe/" _depend2.tmp > _depend.tmp
ifdef UNIX_TOOLS
sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/bcc32\/alleg\/\1\.obj:/" _depend.tmp > obj/bcc32/alleg/makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/bcc32\/alld\/\1\.obj:/" _depend.tmp > obj/bcc32/alld/makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/bcc32\/allp\/\1\.obj:/" _depend.tmp > obj/bcc32/allp/makefile.dep
rm _depend.tmp _depend2.tmp
else
sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/bcc32\/alleg\/\1\.obj:/" _depend.tmp > obj\bcc32\alleg\makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/bcc32\/alld\/\1\.obj:/" _depend.tmp > obj\bcc32\alld\makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/bcc32\/allp\/\1\.obj:/" _depend.tmp > obj\bcc32\allp\makefile.dep
del _depend.tmp
del _depend2.tmp
endif