forked from camthesaxman/gba_bios
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
67 lines (50 loc) · 1.39 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
#### Tools ####
GBAGFX := tools/gbagfx/gbagfx
CC1 := tools/agbcc/bin/agbcc
CC1_OLD := tools/agbcc/bin/old_agbcc
CPP := $(DEVKITARM)/bin/arm-none-eabi-cpp
AS := $(DEVKITARM)/bin/arm-none-eabi-as
LD := $(DEVKITARM)/bin/arm-none-eabi-ld
OBJCOPY := $(DEVKITARM)/bin/arm-none-eabi-objcopy
CC1FLAGS := -g -mthumb-interwork -Wimplicit -Wparentheses -O2 -fhex-asm
CPPFLAGS := -Itools/agbcc/include -iquote include -nostdinc -undef
ASFLAGS := -mcpu=arm7tdmi -mthumb-interwork -Iasminclude
#### Files ####
ROM := gba_bios.bin
ELF := $(ROM:.bin=.elf)
MAP := $(ROM:.bin=.map)
LDSCRIPT := ldscript.txt
SOURCES := asm/bios.s
OFILES := $(addsuffix .o, $(basename $(SOURCES)))
#### Main Targets ####
compare: $(ROM)
md5sum -c checksum.md5
clean:
$(RM) $(ROM) $(ELF) $(MAP) $(OFILES) src/*.s
#### Recipes ####
# Get rid of the idiotic built-in rules
.SUFFIXES:
# Stop deleting my files
.PRECIOUS: %.4bpp
# Link ELF file
$(ELF): $(OFILES) $(LDSCRIPT)
$(LD) -T $(LDSCRIPT) -Map $(MAP) $(OFILES) -o $@
# Build GBA ROM
%.bin: %.elf
$(OBJCOPY) -S -O binary $< $@
# C source code
%.o: %.c
$(CPP) $(CPPFLAGS) $< | $(CC1) $(CC1FLAGS) -o $*.s
echo '.ALIGN 2, 0' >> $*.s
$(AS) $(ASFLAGS) $*.s -o $*.o
# Assembly source code
%.o: %.s
$(AS) $(ASFLAGS) $< -o $@
# Graphics files
%.4bpp: %.png
$(GBAGFX) $< $@
%.gbapal: %.pal
$(GBAGFX) $< $@
%.lz: %
$(GBAGFX) $< $@
include gfxdep.mk