forked from msikma/allegro-4.2.2-xc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile.dj
445 lines (292 loc) · 11 KB
/
makefile.dj
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
#
# Rules for building the Allegro library with djgpp. 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 = djgpp
CC = gcc
EXE = .exe
OBJ = .o
AR = ar
PLATFORM_DIR = obj/djgpp
OBJ_DIR = obj/djgpp/$(VERSION)
LIB_NAME = lib/djgpp/lib$(VERSION).a
ifdef CROSSCOMPILE
UNIX_TOOLS = 1
CC = $(XPREFIX)gcc
AR = $(XPREFIX)ar
endif
ifneq (,$(findstring bash,$(SHELL)))
UNIX_TOOLS = 1
endif
# -------- autodetect whether to use LFN --------
ifdef CROSSCOMPILE
HTML = html
INFO = info
TEXI = texi
else
ifeq ($(LFN),y)
HTML = html
INFO = info
TEXI = texi
else
HTML = htm
INFO = inf
TEXI = txi
endif
endif
# -------- run some sanity checks on the djgpp installation --------
.PHONY: baddjgpp baddjdev badgcc badbnu badmake badtxi badpath badalleg
# -------- check that the DJGPP environment variable is set --------
ifndef DJDIR
baddjgpp:
@echo Your DJGPP environment variable is not set correctly! It should
@echo point to the djgpp.env file: see the djgpp readme.1st for details.
endif
DJDIR_U = $(subst \,/,$(DJDIR))
DJDIR_D = $(subst /,\,$(DJDIR))
ifndef CROSSCOMPILE
# -------- check that the djdev package is installed --------
ifeq ($(wildcard $(DJDIR_U)/bin/djasm.exe),)
baddjdev:
@echo Missing djgpp package! You need to install djdev203.zip (or whatever the
@echo latest version is). Download this from wherever you got djgpp, and unzip
@echo it into the root of your djgpp directory.
endif
# -------- check that the gcc package is installed --------
ifeq ($(wildcard $(DJDIR_U)/bin/gcc.exe),)
badgcc:
@echo Missing djgpp package! You need to install gcc2952b.zip (or whatever the
@echo latest version is). Download this from wherever you got djgpp, and unzip
@echo it into the root of your djgpp directory.
endif
# -------- check that the binutils package is installed --------
ifeq ($(wildcard $(DJDIR_U)/bin/ld.exe),)
badbnu:
@echo Missing djgpp package! You need to install bnu210b.zip (or whatever the
@echo latest version is). Download this from wherever you got djgpp, and unzip
@echo it into the root of your djgpp directory.
endif
# -------- check that the make package is installed --------
ifeq ($(wildcard $(DJDIR_U)/bin/make.exe),)
badmake:
@echo Missing djgpp package! You need to install mak3791b.zip (or whatever the
@echo latest version is). Download this from wherever you got djgpp, and unzip
@echo it into the root of your djgpp directory.
endif
# -------- check that the texinfo package is installed --------
ifeq ($(wildcard $(DJDIR_U)/bin/makeinfo.exe),)
badtxi:
@echo Missing djgpp package! You need to install txi40b.zip (or whatever the
@echo latest version is). Download this from wherever you got djgpp, and unzip
@echo it into the root of your djgpp directory. If you do not need the Info
@echo documentation, run make all to ignore this error.
endif
# -------- check that djgpp/bin is pathed --------
ifeq ($(wildcard $(addsuffix /djasm.exe,$(subst ;, ,$(PATH)))),)
badpath:
@echo Your PATH is not set correctly! This must include the
@echo djgpp bin directory: see the djgpp readme.1st for details.
endif
# -------- check that Allegro has a good directory structure --------
ifeq ($(wildcard src/allegro.c),)
badalleg:
@echo Bad Allegro installation! You did not preserve the directory structure
@echo while unzipping it: did you remember to use the -d flag with pkunzip?
endif
endif
# -------- give a sensible default target for make without any args --------
.PHONY: _default
_default: default
# -------- decide what compiler options to use --------
ifdef WARNMODE
WFLAGS = -Wall -W -Wstrict-prototypes -Wno-unused -Werror
else
WFLAGS = -Wall -Wno-unused
endif
ifdef TARGET_ARCH_COMPAT
TARGET_ARCH = $(GCC_MTUNE)=$(TARGET_ARCH_COMPAT)
else
ifdef TARGET_ARCH_EXCL
TARGET_ARCH = -march=$(TARGET_ARCH_EXCL)
else
TARGET_ARCH = $(GCC_MTUNE)=i586
endif
endif
ifndef TARGET_OPTS
TARGET_OPTS = -O2 -funroll-loops -ffast-math
endif
OFLAGS = $(TARGET_ARCH) $(TARGET_OPTS)
CFLAGS = -DALLEGRO_LIB_BUILD -fgnu89-inline
ifdef DEBUGMODE
# -------- debugging build --------
CFLAGS += -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS) -g
SFLAGS = -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS)
LFLAGS = -g
else
ifdef PROFILEMODE
# -------- profiling build --------
CFLAGS += $(WFLAGS) $(OFLAGS) -pg
SFLAGS = $(WFLAGS)
LFLAGS = -pg
else
# -------- optimised build --------
CFLAGS += $(WFLAGS) $(OFLAGS) -fomit-frame-pointer
SFLAGS = $(WFLAGS)
ifndef SYMBOLMODE
LFLAGS = -s
endif
endif
endif
# -------- list which platform specific objects to include --------
VPATH = src/dos src/misc
ifdef ALLEGRO_USE_C
# ------ build a C-only version ------
VPATH += src/c
MY_OBJECTS = $(C_OBJECTS) cmiscs
CFLAGS += -DALLEGRO_NO_ASM
else
# ------ build the normal asm version ------
VPATH += src/i386
MY_OBJECTS = $(I386_OBJECTS)
endif # ALLEGRO_USE_C
OBJECT_LIST = $(COMMON_OBJECTS) $(MY_OBJECTS) \
$(basename $(notdir $(ALLEGRO_SRC_DOS_FILES))) \
djirq djirqs
# -------- rules for installing and removing the library files --------
INSTALLDIR = $(DJDIR_U)
LIBDIR = lib
INCDIR = include
ifdef UNIX_TOOLS
$(DJDIR_U)/lib/lib$(VERSION).a: $(LIB_NAME) $(DJDIR_U)/lib
cp lib/djgpp/lib$(VERSION).a $(DJDIR_U)/lib
$(DJDIR_U)/info/allegro.$(INFO): docs/info/allegro.$(INFO)
-cp docs/info/allegro.$(INFO) $(DJDIR_U)/info
-install-info $(DJDIR_U)/info/allegro.$(INFO) $(DJDIR_U)/info/dir
else
$(DJDIR_U)/lib/lib$(VERSION).a: $(LIB_NAME)
copy lib\djgpp\lib$(VERSION).a $(DJDIR_D)\lib
$(DJDIR_U)/info/allegro.$(INFO): docs/info/allegro.$(INFO)
-copy docs\info\allegro.$(INFO) $(DJDIR_D)\info
-install-info $(DJDIR_U)/info/allegro.$(INFO) $(DJDIR_U)/info/dir
endif
HEADERS = $(DJDIR_U)/include/allegro/platform/aintdos.h \
$(DJDIR_U)/include/allegro/platform/al386gcc.h \
$(DJDIR_U)/include/allegro/platform/aldjgpp.h \
$(DJDIR_U)/include/allegro/platform/alplatf.h \
$(DJDIR_U)/include/allegro/platform/astdint.h \
$(DJDIR_U)/include/allegro/platform/aldos.h
INSTALL_FILES = $(DJDIR_U)/lib/lib$(VERSION).a \
$(DJDIR_U)/info/allegro.$(INFO) \
$(HEADERS)
install: generic-install
@echo The $(DESCRIPTION) $(PLATFORM) library has been installed.
UNINSTALL_FILES = $(DJDIR_U)/lib/liballeg.a \
$(DJDIR_U)/lib/liballd.a \
$(DJDIR_U)/lib/liballp.a \
$(DJDIR_U)/info/allegro.$(INFO) \
$(HEADERS)
uninstall: generic-uninstall
-install-info --delete $(DJDIR_U)/info/allegro.$(INFO) $(DJDIR_U)/info/dir
@echo All gone!
# -------- helper function for compressing the executables --------
ifneq ($(wildcard $(DJDIR_U)/bin/upx.exe),)
DJP = $(DJDIR_U)/bin/upx.exe
else
ifneq ($(wildcard $(DJDIR_U)/bin/djp.exe),)
DJP = $(DJDIR_U)/bin/djp.exe -s
endif
endif
.PHONY: compress
compress: $(PROGRAMS)
ifdef DJP
$(DJP) demo/*.exe examples/*.exe setup/*.exe tests/*.exe tools/*.exe
else
@echo No executable compressor found! This target requires either the
@echo DJP or UPX utilities to be installed in your djgpp bin directory.
endif
# -------- test capabilities --------
TEST_CPP = $(CC) -fno-exceptions -c src/misc/test.cpp -o $(PLATFORM_DIR)/test.o
include makefile.tst
# -------- finally, we get to the fun part... --------
define MAKE_LIB
$(AR) rs $(LIB_NAME) $(OBJECTS)
endef
COMPILE_FLAGS = $(subst src/,-DALLEGRO_SRC ,$(findstring src/, $<))$(CFLAGS)
$(OBJ_DIR)/%.o: %.c
$(CC) $(COMPILE_FLAGS) -I. -I./include -o $@ -c $<
$(OBJ_DIR)/%.o: %.cpp
$(CC) -fno-exceptions $(COMPILE_FLAGS) -I. -I./include -o $@ -c $<
$(OBJ_DIR)/%.o: %.s
$(CC) $(SFLAGS) -I. -I./include -x assembler-with-cpp -o $@ -c $<
ifndef CROSSCOMPILE
obj/djgpp/setupdat.s: setup/setup.dat tools/dat2s.exe
tools/dat2s.exe -p setup -o obj/djgpp/setupdat.s setup/setup.dat
obj/djgpp/setupdat.o: obj/djgpp/setupdat.s
$(CC) -o obj/djgpp/setupdat.o -c obj/djgpp/setupdat.s
$(OBJ_DIR)/setup.o: setup/setup.c
$(CC) $(COMPILE_FLAGS) -DSETUP_USE_COMPILED_DATAFILES -I. -I./include -o $(OBJ_DIR)/setup.o -c setup/setup.c
setup/setup.exe: $(OBJ_DIR)/setup.o obj/djgpp/setupdat.o $(LIB_NAME)
$(CC) $(LFLAGS) -o setup/setup.exe $(OBJ_DIR)/setup.o obj/djgpp/setupdat.o $(LIB_NAME)
endif
demo/demo.exe: $(OBJECTS_DEMO)
$(CC) $(LFLAGS) -o $@ $(OBJECTS_DEMO) $(LIB_NAME)
*/%.exe: $(OBJ_DIR)/%.o $(LIB_NAME)
$(CC) $(LFLAGS) -o $@ $< $(LIB_NAME)
ifdef CROSSCOMPILE
obj/djgpp/asmdef.s: src/i386/asmdef.c include/*.h include/allegro/*.h obj/djgpp/asmcapa.h
$(CC) $(WFLAGS) -I. -I./include -S -o obj/djgpp/asmdef.s src/i386/asmdef.c
obj/djgpp/asmdef.inc: obj/djgpp/asmdef.s
if [ ! -x misc/asmdef.sh ]; then chmod a+x misc/asmdef.sh; fi
misc/asmdef.sh obj/djgpp/asmdef.s obj/djgpp/asmdef.inc
else
obj/djgpp/asmdef.inc: obj/djgpp/asmdef.exe
obj/djgpp/asmdef.exe obj/djgpp/asmdef.inc
obj/djgpp/asmdef.exe: src/i386/asmdef.c include/*.h include/allegro/*.h obj/djgpp/asmcapa.h
$(CC) -O $(WFLAGS) -fgnu89-inline -I. -I./include -o obj/djgpp/asmdef.exe src/i386/asmdef.c
endif
define LINK_WITHOUT_LIB
$(CC) $(LFLAGS) -o $@ $^
endef
PLUGIN_LIB = lib/djgpp/lib$(VERY_SHORT_VERSION)dat.a
PLUGINS_H = obj/djgpp/plugins.h
PLUGIN_DEPS = $(LIB_NAME) $(PLUGIN_LIB)
PLUGIN_SCR = scr
ifdef UNIX_TOOLS
define GENERATE_PLUGINS_H
cat tools/plugins/*.inc > obj/djgpp/plugins.h
endef
else
define GENERATE_PLUGINS_H
copy /B tools\plugins\*.inc obj\djgpp\plugins.h
endef
endif
define MAKE_PLUGIN_LIB
ar rs $(PLUGIN_LIB) $(PLUGIN_OBJS)
endef
define LINK_WITH_PLUGINS
$(CC) $(LFLAGS) -o $@ $< $(strip $(PLUGIN_LIB) $(addprefix @,$(PLUGIN_SCRIPTS)) $(LIB_NAME))
endef
# -------- generate automatic dependencies --------
DEPEND_PARAMS = -MM -MG -I. -I./include -DSCAN_DEPEND -DALLEGRO_DJGPP
depend:
$(CC) $(DEPEND_PARAMS) src/*.c src/dos/*.c src/c/*.c src/i386/*.c src/misc/*.c demo/*.c > _depend.tmp
$(CC) $(DEPEND_PARAMS) docs/src/makedoc/*.c examples/*.c setup/*.c tests/*.c tools/*.c tools/plugins/*.c >> _depend.tmp
$(CC) $(DEPEND_PARAMS) -x c tests/*.cpp >> _depend.tmp
$(CC) $(DEPEND_PARAMS) -x assembler-with-cpp src/i386/*.s src/c/*.s src/dos/*.s src/misc/*.s >> _depend.tmp
sed -e "s/^[a-zA-Z0-9_\/]*\///" _depend.tmp > _depend2.tmp
ifdef UNIX_TOOLS
sed -e "s/^\([a-zA-Z0-9_]*\.o:\)/obj\/djgpp\/alleg\/\1/" _depend2.tmp > obj/djgpp/alleg/makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\.o:\)/obj\/djgpp\/alld\/\1/" _depend2.tmp > obj/djgpp/alld/makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\.o:\)/obj\/djgpp\/allp\/\1/" _depend2.tmp > obj/djgpp/allp/makefile.dep
rm _depend.tmp _depend2.tmp
else
sed -e "s/^\([a-zA-Z0-9_]*\.o:\)/obj\/djgpp\/alleg\/\1/" _depend2.tmp > obj\djgpp\alleg\makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\.o:\)/obj\/djgpp\/alld\/\1/" _depend2.tmp > obj\djgpp\alld\makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\.o:\)/obj\/djgpp\/allp\/\1/" _depend2.tmp > obj\djgpp\allp\makefile.dep
del _depend.tmp
del _depend2.tmp
endif