This repository has been archived by the owner on Oct 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
82 lines (56 loc) · 1.93 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
AS := $(DEVKITARM)/bin/arm-none-eabi-as
ASFLAGS := -mcpu=arm7tdmi
CC1 := tools/agbcc/bin/agbcc
override CFLAGS += -mno-thumb-interwork -Wimplicit -Wparentheses -Wunused -Werror -O2 -fhex-asm
CPP := $(DEVKITARM)/bin/arm-none-eabi-cpp
CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef
LD := $(DEVKITARM)/bin/arm-none-eabi-ld
OBJCOPY := $(DEVKITARM)/bin/arm-none-eabi-objcopy
GBAFIX := $(DEVKITPRO)/tools/bin/gbafix
LIBGCC := tools/agbcc/lib/libgcc.a
MD5 := md5sum -c
# Clear the default suffixes.
.SUFFIXES:
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:
.PRECIOUS: %.1bpp %.4bpp %.8bpp %.gbapal %.lz %.rl %.pcm %.bin
.PHONY: all clean tidy
C_SRCS := $(wildcard src/*.c)
C_OBJS := $(C_SRCS:%.c=%.o)
ASM_SRCS := $(wildcard asm/*.s)
ASM_OBJS := $(ASM_SRCS:%.s=%.o)
DATA_ASM_SRCS := $(wildcard data/*.s)
DATA_ASM_OBJS := $(DATA_ASM_SRCS:%.s=%.o)
OBJS := $(C_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS)
TITLE := ADVANCEWARS
GAME_CODE := AWRE
MAKER_CODE := 01
GAME_REVISION := 0
all: advancewars.gba
# For contributors to make sure a change didn't affect the contents of the ROM.
compare: all
@$(MD5) rom.md5
clean: tidy
tidy:
rm -f advancewars.gba advancewars.elf advancewars.map
rm -f $(ASM_OBJS)
rm -f $(DATA_ASM_OBJS)
rm -f $(C_OBJS)
rm -f $(ASM_OBJS)
rm -f $(DATA_ASM_OBJS)
rm -f $(C_SRCS:%.c=%.i)
rm -f $(C_SRCS:%.c=%.s)
$(C_OBJS): %.o : %.c
@$(CPP) $(CPPFLAGS) $< -o $*.i
@$(CC1) $(CFLAGS) $*.i -o $*.s
@printf ".text\n\t.align\t2, 0\n" >> $*.s
$(AS) $(ASFLAGS) -o $@ $*.s
$(ASM_OBJS): %.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
$(DATA_ASM_OBJS): %.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
advancewars.elf: linker.ld $(OBJS)
$(LD) -T linker.ld -Map advancewars.map -o $@ $(OBJS) $(LIBGCC)
advancewars.gba: advancewars.elf
$(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x4000000 $< $@
$(GBAFIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(GAME_REVISION)