forked from MutantStargoat/voxelburg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
138 lines (99 loc) · 2.81 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
src = $(wildcard src/*.c) $(wildcard src/gba/*.c)
ssrc = $(wildcard src/*.s) $(wildcard src/gba/*.s) data/lut.s
obj = $(src:.c=.arm.o) $(ssrc:.s=.arm.o)
dep = $(src:.c=.arm.d)
name = voxelburg
elf = $(name).elf
bin = $(name).gba
data = data/color.raw data/color.pal data/color.gpal data/height.raw \
data/spr_game.raw data/spr_game.pal data/spr_game.gpal \
data/spr_logo.raw data/spr_logo.pal \
data/menuscr.raw data/menuscr.pal data/menuscr.gpal \
data/spr_menu.raw data/spr_menu.pal \
data/controls.raw data/controls.pal data/controls.gpal
libs = libs/maxmod/libmm.a
TCPREFIX = arm-none-eabi-
CPP = $(TCPREFIX)cpp
CC = $(TCPREFIX)gcc
AS = $(TCPREFIX)as
OBJCOPY = $(TCPREFIX)objcopy
OBJDUMP = $(TCPREFIX)objdump
def = -DBUILD_GBA
opt = -O3 -fomit-frame-pointer -mcpu=arm7tdmi -mtune=arm7tdmi -mthumb -mthumb-interwork
dbg = -g
inc = -I. -Isrc -Isrc/gba -Ilibs/maxmod
warn = -pedantic -Wall
CFLAGS = $(opt) $(dbg) $(warn) -MMD $(def) $(inc)
ASFLAGS = -mthumb-interwork
LDFLAGS = -mthumb -mthumb-interwork $(libs) -lm
-include cfg.mk
.PHONY: all
all: $(bin) $(bin_mb)
$(bin): $(elf)
$(OBJCOPY) -O binary $(elf) $(bin)
gbafix -r0 $(bin)
$(elf): $(obj) $(libs)
$(CC) -o $(elf) $(obj) -specs=gba.specs -Wl,-Map,link.map $(LDFLAGS)
-include $(dep)
%.arm.o: %.c
$(CC) -o $@ $(CFLAGS) -c $<
%.arm.o: %.s
$(AS) -o $@ $(ASFLAGS) $<
src/data.o: src/data.s $(data)
src/data.arm.o: src/data.s $(data)
tools/pngdump/pngdump:
$(MAKE) -C tools/pngdump
tools/meshdump/meshdump:
$(MAKE) -C tools/meshdump
tools/lutgen: tools/lutgen.c
cc -o $@ $< -lm
tools/vistab: tools/vistab.c
cc -o $@ $< -lm
tools/mmutil/mmutil:
$(MAKE) -C tools/mmutil
#data/spr_game.raw: data/spr_ui.png data/spr_hud.png
# tools/pngdump/pngdump -o $@ -n $^
%.sraw: %.png tools/pngdump/pngdump
tools/pngdump/pngdump -o $@ -oc $(subst .sraw,.spal,$@) -os $(subst .sraw,.shade,$@) -s 8 $<
%.raw: %.png tools/pngdump/pngdump
tools/pngdump/pngdump -o $@ -n $<
%.pal: %.png tools/pngdump/pngdump
tools/pngdump/pngdump -o $@ -c $<
%.gpal: %.png tools/pngdump/pngdump
tools/pngdump/pngdump -o $@ -c -g $<
%.555: %.png tools/pngdump/pngdump
tools/pngdump/pngdump -o $@ -555 $<
data/lut.s: tools/lutgen
tools/lutgen >$@
data/snd.bin: $(audata) tools/mmutil/mmutil
tools/mmutil/mmutil -o$@ -hdata/snd.h $(audata)
data/snd.h: data/snd.bin
.PHONY: clean
clean:
rm -f $(obj) $(bin) $(bin_mb) $(elf) $(elf_mb)
.PHONY: cleandep
cleandep:
rm -f $(dep)
.PHONY: cleanlibs
cleanlibs:
$(MAKE) -C libs/maxmod clean
.PHONY: install
install: $(bin)
if2a -n -f -W $<
.PHONY: run
run: $(bin)
mgba -3 --log-level=16 $(bin)
.PHONY: debug
debug: $(elf)
mgba -2 -g $(bin) &
$(TCPREFIX)gdb -x gdbmgba $<
.PHONY: disasm
disasm: $(elf)
$(OBJDUMP) -d $< >$@
.PHONY: libs
libs: $(libs)
libs/maxmod/libmm.a:
$(MAKE) -C libs/maxmod
.PHONY: pc
pc:
$(MAKE) -f Makefile.pc