-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakefileDemo
72 lines (50 loc) · 1.66 KB
/
MakefileDemo
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
CC = thumb-elf-gcc
AS = thumb-elf-as
OBJCOPY = thumb-elf-objcopy
.SFILES = crt0_demo.s
.CFILES = Main.c searchMenu.c menuFunc.c myFunc.c sound.c data.c soundData.c interrupt.c
.BFILES = char/pals.bin char/tmap.bin char/search_tmap.bin char/tiles.bin
.OFILES = $(.SFILES:.s=.o) $(.CFILES:.c=.o) $(.BFILES:.bin=_LZ.o)
AGBINC = $(AGBDIR)/include
AGBLIB = $(AGBDIR)/lib
RFULIB = ./AgbRfuLib
ASFLAGS = -I$(AGBINC) -I$(RFULIB) -mthumb-interwork
CFLAGS = -g -O2 -I$(AGBINC) -I$(RFULIB) -mthumb-interwork \
-nostdlib -Wall -Werror #-DNDEBUG
LDFLAGS += -Map $(MAPFILE) -nostartfiles \
-T $(LINKFILE) \
-L$(RFULIB) -lagbrfu -L$(AGBLIB) -lagbsyscall
LINKFILE = demo.ld
DEPENDFILE = demo.dep
MAPFILE = demo.map
TARGET_ELF = demo.elf
TARGET_BIN = demo.bin
default:
@$(MAKE) -C $(RFULIB)
@$(MAKE) -f MakefileDemo $(TARGET_BIN)
$(TARGET_BIN): $(TARGET_ELF)
$(OBJCOPY) -v -O binary $< $@
$(TARGET_ELF): $(.OFILES) Makefile $(LINKFILE) $(DEPENDFILE) $(RFULIB)/libagbrfu.a
@echo > $(MAPFILE)
$(CC) -g -o $@ $(.OFILES) -Wl,$(LDFLAGS)
%.o: %.bin
$(OBJCOPY) -I binary=.rodata -O elf32-little $< $@
%_LZ.bin: %.bin
agbcomp -b -l 2 $<
%.bin: %.bmp
bmp2agb -np -bi $<
char/tiles.bin: char/tiles.bmp
bmp2agb -np -bi $<
truncate -s 11712 $@
sound.o: CC := ThumbPatch-thumb-elf-gcc
.PHONY: all clean depend
all: clean $(TARGET_BIN)
clean:
@$(MAKE) -C $(RFULIB) clean
-rm $(.OFILES) $(DEPENDFILE) $(MAPFILE) $(TARGET_ELF) $(TARGET_BIN)
depend:
$(CC) $(CFLAGS) -M $(.CFILES) > $(DEPENDFILE)
$(DEPENDFILE):
$(CC) $(CFLAGS) -M $(.CFILES) > $(DEPENDFILE)
include GasdependDemo
include $(DEPENDFILE)