aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9/makefile
blob: c648d6d4dd0227c8f590a6857ac5b32a4122cda3 (plain)
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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
#BUILD_PLUGINS = 1
libndsdir = $(DEVKITPRO)/libnds

DS_SCUMM_BUILD = 1

#DS_NON_SCUMM_BUILD = 1

USE_MAD = 1

VPATH = $(srcdir)

# Command to build libmad is:
# ./configure --host=arm-elf --enable-speed --enable-sso -enable-fpm=arm CFLAGS='-specs=ds_arm9.specs -mthumb-interwork'

ifdef DS_NON_SCUMM_BUILD
	DEFINES = -DDS_NON_SCUMM_BUILD
	DISABLE_HE = 1
	DISABLE_SCUMM = 1
	DISABLE_SCUMM_7_8 = 1
	#DISABLE_SIMON = 1
	#DISABLE_SKY = 1
	DISABLE_SWORD1 = 1
	DISABLE_SWORD2 = 1
	#DISABLE_QUEEN = 1
	DISABLE_SAGA = 1
	DISABLE_KYRA = 1
	#DISABLE_GOB = 1
	DISABLE_LURE = 1
	DISABLE_CINE = 1
	DISABLE_AGI = 1
	BUILD=scummvm-B
endif

ifdef DS_SCUMM_BUILD
	DEFINES = -DDS_SCUMM_BUILD
	DISABLE_HE = 1
	#DISABLE_SCUMM = 1
	DISABLE_SCUMM_7_8 = 1
	DISABLE_SIMON = 1
	DISABLE_SKY = 1
	DISABLE_SWORD1 = 1
	DISABLE_SWORD2 = 1
	DISABLE_QUEEN = 1
	DISABLE_SAGA = 1
	DISABLE_KYRA = 1
	DISABLE_GOB = 1
	DISABLE_LURE = 1
	DISABLE_CINE = 1
	DISABLE_AGI = 1
	BUILD=scummvm-A
endif

ARM7BIN	:= -7 $(CURDIR)/../../arm7/arm7.bin
ICON 		:= -b ../../../logo.bmp "ScummVM;By Neil Millstone;"

CC      = arm-eabi-gcc
CXX     = arm-eabi-g++

CFLAGS	=	-Wno-multichar -Wall -Os\
		-Wno-multichar -mcpu=arm9tdmi -mtune=arm9tdmi \
 		-mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer\
		-ffast-math -mthumb-interwork
		
CXXFLAGS=	$(CFLAGS) -Wno-non-virtual-dtor	 -Wno-non-virtual-dtor \
		-fno-exceptions -fno-rtti

ASFLAGS = -mcpu=arm9tdmi -mthumb-interwork
DEFINES += -D__DS__ -DNDS -DARM9 -DNONSTANDARD_PORT -DDISABLE_FANCY_THEMES
ifdef USE_MAD
	DEFINES += -DUSE_MAD
endif

LDFLAGS = -specs=ds_arm9.specs -mthumb-interwork -mno-fpu -Wl,-Map,map.txt

INCLUDES= -I./ -I$(portdir)/$(BUILD) -I$(srcdir) -I$(srcdir)/common -I$(portdir)/source -I$(portdir)/source/compressor -I$(portdir)/source/fat \
			-I$(srcdir)/backends/fs  -I$(srcdir)/backends/fs/ds -I$(portdir)/data -I$(libndsdir)/include -I$(portdir)/../commoninclude\
			-I$(srcdir)/scumm -I$(libndsdir)/include -I$(libndsdir)/include/nds -I$(srcdir)/engines -I$(portdir)/source/mad
			

LIBS	= -lm -L$(libndsdir)/lib -L$(portdir)/lib -lnds9
ifdef USE_MAD
	LIBS += -lmad
endif

#-Lscumm -lscumm -Lbase -lbase -Lcommon -lcommon -Lgraphics -lgraphics -Lgui -lgui -Lsound -lsound
EXECUTABLE = scummvm.elf
PLUGIN_PREFIX =
PLUGIN_SUFFIX = .plg
PLUGIN_EXTRA_DEPS = plugin.x plugin.syms scummvm.elf
PLUGIN_LDFLAGS = -nostartfiles -Wl,-q,-Tplugin.x,--just-symbols,scummvm.elf,--retain-symbols-file,plugin.syms -L$(ronindir)/lib
MKDIR = mkdir -p
RM = rm -f
RM_REC = rm -rf
AR = arm-eabi-ar cru
RANLIB = arm-eabi-ranlib
OBJCOPY = arm-eabi-objcopy
AS = arm-eabi-as
HAVE_GCC3 = true
DISABLE_SCALERS = true

ifdef BUILD_PLUGINS
DEFINES += -DDYNAMIC_MODULES
PRE_OBJS_FLAGS = -Wl,--whole-archive
POST_OBJS_FLAGS = -Wl,--no-whole-archive
endif

PORT_OBJS :=	$(portdir)/source/blitters.o $(portdir)/source/cdaudio.o $(portdir)/source/dsmain.o \
		$(portdir)/../../../fs/ds/ds-fs.o $(portdir)/source/gbampsave.o $(portdir)/source/scummhelp.o\
		$(portdir)/source/osystem_ds.o $(portdir)/source/portdefs.o $(portdir)/source/ramsave.o\
		$(portdir)/source/scummconsole.o $(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\
		$(portdir)/source/dsoptions.o
		
DATA_OBJS := $(portdir)/data/icons.o $(portdir)/data/keyboard.o $(portdir)/data/keyboard_pal.o $(portdir)/data/default_font.o
			
		
COMPRESSOR_OBJS := $(portdir)/source/compressor/lz.o

FAT_OBJS :=  $(portdir)/source/fat/disc_io.o $(portdir)/source/fat/gba_nds_fat.o\
			$(portdir)/source/fat/io_fcsr.o $(portdir)/source/fat/io_m3cf.o\
			$(portdir)/source/fat/io_mpcf.o $(portdir)/source/fat/io_sccf.o\
			$(portdir)/source/fat/io_m3sd.o\
			$(portdir)/source/fat/io_nmmc.o $(portdir)/source/fat/io_scsd.o \
			$(portdir)/source/fat/io_m3sd_asm.o $(portdir)/source/fat/io_scsd_asm.o 
			
			
			
OBJS := $(DATA_OBJS) $(PORT_OBJS) $(COMPRESSOR_OBJS) $(FAT_OBJS) 
		

		
MODULE_DIRS += .

ndsall:
	@[ -d $(BUILD) ] || mkdir -p $(BUILD)
	make -C ./$(BUILD) -f ../makefile scummvm.nds

include $(srcdir)/Makefile.common

clean:
	$(RM) $(OBJS) $(EXECUTABLE)
	rm -fr $(BUILD)

plugin_dist :
	find . -name '*.plg' | while read p; do \
	  sh-elf-strip -g -o "`basename \"$$p\" | tr '[:lower:]' '[:upper:]'`" "$$p"; \
	done

dist : SCUMMVM.BIN plugins plugin_dist


#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
#define bin2o
#	bin2s $< | $(AS) -mthumb -mthumb-interwork -o $(@)
#	echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_raw_end[];" > `(echo $(<F) | tr . _)`.h
#	echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_raw[];" >> `(echo $(<F) | tr . _)`.h
#	echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_raw_size";" >> `(echo $(<F) | tr . _)`.h
#endef


define bin2o
	bin2s $< | $(AS) -mthumb -mthumb-interwork -o $(@)
	echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
	echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
	echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef


#define bin2o
#	@echo $(*)
#	cp $(<) $(*).tmp
#	$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
#	--rename-section .data=.rodata \
#	--redefine-sym _binary_$(subst .,_,$(subst /,_,$(*)))_tmp_start=$(notdir $*)\
#	--redefine-sym _binary_$(subst .,_,$(subst /,_,$(*)))_tmp_end=$(notdir $*)_end\
#	$(*).tmp $(@)
#	echo "extern const u8" $(notdir $*)"[] __attribute__ ((aligned (4)));" > $(*).h
#	echo "extern const u32" $(notdir $(*))_size[]";" >> $(*).h
#	
#	echo $(*).h
#	rm $(*).tmp
#endef

##############
# Replacement rule for the one in makefile.common
##############
ifndef HAVE_GCC3
# If you use GCC, disable the above and enable this for intelligent
# dependency tracking. 
.cpp.o:
	$(MKDIR) $(*D)/$(DEPDIR)
	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d2" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
	$(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d
	$(CAT) "$(*D)/$(DEPDIR)/$(*F).d2" >> "$(*D)/$(DEPDIR)/$(*F).d"
	$(RM) "$(*D)/$(DEPDIR)/$(*F).d2"
else
# If you even have GCC 3.x, you can use this build rule, which is safer; the above
# rule can get you into a bad state if you Ctrl-C at the wrong moment.
# Also, with this GCC inserts additional dummy rules for the involved headers,
# which ensures a smooth compilation even if said headers become obsolete.
.cpp.o:
	$(MKDIR) $(*D)/$(DEPDIR)
#	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
	$(CXX) -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d"              $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
endif


 
#---------------------------------------------------------------------------------
%.o	:	%.pcx
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)
 
#---------------------------------------------------------------------------------
%.o	:	%.bin
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)
 
#---------------------------------------------------------------------------------
%.o	:	%.raw
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)
 
#---------------------------------------------------------------------------------
%.o	:	%.pal
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)
 
#---------------------------------------------------------------------------------
%.o	:	%.map
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)

#---------------------------------------------------------------------------------
%.o	:	%.mdl
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)

#---------------------------------------------------------------------------------
%.nds: %.bin
	@echo ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../../logo.bmp "$(shell basename $@);ScummVM 0.9.0;Port v0.6"
	ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../../logo.bmp "$(shell basename $@);ScummVM 0.9.0;Port v0.6"
	dsbuild $@
	padbin 16 $(basename $@).ds.gba

#---------------------------------------------------------------------------------
%.bin: %.elf
	$(OBJCOPY) -S scummvm.elf scummvm-stripped.elf
	$(OBJCOPY) -O binary scummvm-stripped.elf scummvm.bin

#%.o: %.s
#	$(MKDIR) $(*D)/$(DEPDIR)
#	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
	
#BUILD_PLUGINS = 1
libndsdir = $(DEVKITPRO)/libnds

DS_SCUMM_BUILD = 1

#DS_NON_SCUMM_BUILD = 1

USE_MAD = 1

VPATH = $(srcdir)

# Command to build libmad is:
# ./configure --host=arm-elf --enable-speed --enable-sso -enable-fpm=arm CFLAGS='-specs=ds_arm9.specs -mthumb-interwork'

ifdef DS_NON_SCUMM_BUILD
	DEFINES = -DDS_NON_SCUMM_BUILD
	DISABLE_HE = 1
	DISABLE_SCUMM = 1
	DISABLE_SCUMM_7_8 = 1
	#DISABLE_SIMON = 1
	#DISABLE_SKY = 1
	DISABLE_SWORD1 = 1
	DISABLE_SWORD2 = 1
	#DISABLE_QUEEN = 1
	DISABLE_SAGA = 1
	DISABLE_KYRA = 1
	#DISABLE_GOB = 1
	DISABLE_LURE = 1
	DISABLE_CINE = 1
	DISABLE_AGI = 1
	BUILD=scummvm-B
endif

ifdef DS_SCUMM_BUILD
	DEFINES = -DDS_SCUMM_BUILD
	DISABLE_HE = 1
	#DISABLE_SCUMM = 1
	DISABLE_SCUMM_7_8 = 1
	DISABLE_SIMON = 1
	DISABLE_SKY = 1
	DISABLE_SWORD1 = 1
	DISABLE_SWORD2 = 1
	DISABLE_QUEEN = 1
	DISABLE_SAGA = 1
	DISABLE_KYRA = 1
	DISABLE_GOB = 1
	DISABLE_LURE = 1
	DISABLE_CINE = 1
	DISABLE_AGI = 1
	BUILD=scummvm-A
endif

ARM7BIN	:= -7 $(CURDIR)/../../arm7/arm7.bin
ICON 		:= -b ../../../logo.bmp "ScummVM;By Neil Millstone;"

CC      = arm-eabi-gcc
CXX     = arm-eabi-g++

CFLAGS	=	-Wno-multichar -Wall -Os\
		-Wno-multichar -mcpu=arm9tdmi -mtune=arm9tdmi \
 		-mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer\
		-ffast-math -mthumb-interwork
		
CXXFLAGS=	$(CFLAGS) -Wno-non-virtual-dtor	 -Wno-non-virtual-dtor \
		-fno-exceptions -fno-rtti

ASFLAGS = -mcpu=arm9tdmi -mthumb-interwork
DEFINES += -D__DS__ -DNDS -DARM9 -DNONSTANDARD_PORT -DDISABLE_FANCY_THEMES
ifdef USE_MAD
	DEFINES += -DUSE_MAD
endif

LDFLAGS = -specs=ds_arm9.specs -mthumb-interwork -mno-fpu -Wl,-Map,map.txt

INCLUDES= -I./ -I$(portdir)/$(BUILD) -I$(srcdir) -I$(srcdir)/common -I$(portdir)/source -I$(portdir)/source/compressor -I$(portdir)/source/fat \
			-I$(srcdir)/backends/fs  -I$(srcdir)/backends/fs/ds -I$(portdir)/data -I$(libndsdir)/include -I$(portdir)/../commoninclude\
			-I$(srcdir)/scumm -I$(libndsdir)/include -I$(libndsdir)/include/nds -I$(srcdir)/engines -I$(portdir)/source/mad
			

LIBS	= -lm -L$(libndsdir)/lib -L$(portdir)/lib -lnds9
ifdef USE_MAD
	LIBS += -lmad
endif

#-Lscumm -lscumm -Lbase -lbase -Lcommon -lcommon -Lgraphics -lgraphics -Lgui -lgui -Lsound -lsound
EXECUTABLE = scummvm.elf
PLUGIN_PREFIX =
PLUGIN_SUFFIX = .plg
PLUGIN_EXTRA_DEPS = plugin.x plugin.syms scummvm.elf
PLUGIN_LDFLAGS = -nostartfiles -Wl,-q,-Tplugin.x,--just-symbols,scummvm.elf,--retain-symbols-file,plugin.syms -L$(ronindir)/lib
MKDIR = mkdir -p
RM = rm -f
RM_REC = rm -rf
AR = arm-eabi-ar cru
RANLIB = arm-eabi-ranlib
OBJCOPY = arm-eabi-objcopy
AS = arm-eabi-as
HAVE_GCC3 = true
DISABLE_SCALERS = true

ifdef BUILD_PLUGINS
DEFINES += -DDYNAMIC_MODULES
PRE_OBJS_FLAGS = -Wl,--whole-archive
POST_OBJS_FLAGS = -Wl,--no-whole-archive
endif

PORT_OBJS :=	$(portdir)/source/blitters.o $(portdir)/source/cdaudio.o $(portdir)/source/dsmain.o \
		$(portdir)/../../../fs/ds/ds-fs.o $(portdir)/source/gbampsave.o $(portdir)/source/scummhelp.o\
		$(portdir)/source/osystem_ds.o $(portdir)/source/portdefs.o $(portdir)/source/ramsave.o\
		$(portdir)/source/scummconsole.o $(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\
		$(portdir)/source/dsoptions.o
		
DATA_OBJS := $(portdir)/data/icons.o $(portdir)/data/keyboard.o $(portdir)/data/keyboard_pal.o $(portdir)/data/default_font.o
			
		
COMPRESSOR_OBJS := $(portdir)/source/compressor/lz.o

FAT_OBJS :=  $(portdir)/source/fat/disc_io.o $(portdir)/source/fat/gba_nds_fat.o\
			$(portdir)/source/fat/io_fcsr.o $(portdir)/source/fat/io_m3cf.o\
			$(portdir)/source/fat/io_mpcf.o $(portdir)/source/fat/io_sccf.o\
			$(portdir)/source/fat/io_m3sd.o\
			$(portdir)/source/fat/io_nmmc.o $(portdir)/source/fat/io_scsd.o \
			$(portdir)/source/fat/io_m3sd_asm.o $(portdir)/source/fat/io_scsd_asm.o 
			
			
			
OBJS := $(DATA_OBJS) $(PORT_OBJS) $(COMPRESSOR_OBJS) $(FAT_OBJS) 
		

		
MODULE_DIRS += .

ndsall:
	@[ -d $(BUILD) ] || mkdir -p $(BUILD)
	make -C ./$(BUILD) -f ../makefile scummvm.nds

include $(srcdir)/Makefile.common

clean:
	$(RM) $(OBJS) $(EXECUTABLE)
	rm -fr $(BUILD)

plugin_dist :
	find . -name '*.plg' | while read p; do \
	  sh-elf-strip -g -o "`basename \"$$p\" | tr '[:lower:]' '[:upper:]'`" "$$p"; \
	done

dist : SCUMMVM.BIN plugins plugin_dist


#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
#define bin2o
#	bin2s $< | $(AS) -mthumb -mthumb-interwork -o $(@)
#	echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_raw_end[];" > `(echo $(<F) | tr . _)`.h
#	echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_raw[];" >> `(echo $(<F) | tr . _)`.h
#	echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_raw_size";" >> `(echo $(<F) | tr . _)`.h
#endef


define bin2o
	bin2s $< | $(AS) -mthumb -mthumb-interwork -o $(@)
	echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
	echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
	echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef


#define bin2o
#	@echo $(*)
#	cp $(<) $(*).tmp
#	$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
#	--rename-section .data=.rodata \
#	--redefine-sym _binary_$(subst .,_,$(subst /,_,$(*)))_tmp_start=$(notdir $*)\
#	--redefine-sym _binary_$(subst .,_,$(subst /,_,$(*)))_tmp_end=$(notdir $*)_end\
#	$(*).tmp $(@)
#	echo "extern const u8" $(notdir $*)"[] __attribute__ ((aligned (4)));" > $(*).h
#	echo "extern const u32" $(notdir $(*))_size[]";" >> $(*).h
#	
#	echo $(*).h
#	rm $(*).tmp
#endef

##############
# Replacement rule for the one in makefile.common
##############
ifndef HAVE_GCC3
# If you use GCC, disable the above and enable this for intelligent
# dependency tracking. 
.cpp.o:
	$(MKDIR) $(*D)/$(DEPDIR)
	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d2" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
	$(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d
	$(CAT) "$(*D)/$(DEPDIR)/$(*F).d2" >> "$(*D)/$(DEPDIR)/$(*F).d"
	$(RM) "$(*D)/$(DEPDIR)/$(*F).d2"
else
# If you even have GCC 3.x, you can use this build rule, which is safer; the above
# rule can get you into a bad state if you Ctrl-C at the wrong moment.
# Also, with this GCC inserts additional dummy rules for the involved headers,
# which ensures a smooth compilation even if said headers become obsolete.
.cpp.o:
	$(MKDIR) $(*D)/$(DEPDIR)
#	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
	$(CXX) -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d"              $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
endif


 
#---------------------------------------------------------------------------------
%.o	:	%.pcx
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)
 
#---------------------------------------------------------------------------------
%.o	:	%.bin
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)
 
#---------------------------------------------------------------------------------
%.o	:	%.raw
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)
 
#---------------------------------------------------------------------------------
%.o	:	%.pal
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)
 
#---------------------------------------------------------------------------------
%.o	:	%.map
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)

#---------------------------------------------------------------------------------
%.o	:	%.mdl
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	@$(bin2o)

#---------------------------------------------------------------------------------
%.nds: %.bin
	@echo ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../../logo.bmp "$(shell basename $@);ScummVM 0.9.0;Port v0.6"
	ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../../logo.bmp "$(shell basename $@);ScummVM 0.9.0;Port v0.6"
	dsbuild $@
	padbin 16 $(basename $@).ds.gba

#---------------------------------------------------------------------------------
%.bin: %.elf
	$(OBJCOPY) -S scummvm.elf scummvm-stripped.elf
	$(OBJCOPY) -O binary scummvm-stripped.elf scummvm.bin

#%.o: %.s
#	$(MKDIR) $(*D)/$(DEPDIR)
#	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o