forked from PikalaxALT/gba_bios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (54 loc) · 1.46 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
#### Tools ####
GBAGFX := tools/gbagfx/gbagfx
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
ASFLAGS := -mcpu=arm7tdmi
#### Files ####
ROM := gba_bios.bin
ELF := $(ROM:.bin=.elf)
MAP := $(ROM:.bin=.map)
LDSCRIPT := ld_script.txt
SOURCES := $(wildcard asm/*.s)
OFILES := $(addsuffix .o, $(basename $(SOURCES)))
LD_DEPS := sym_ewram.txt sym_iwram.txt
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:
# Clear the default suffixes
.SUFFIXES:
# Don't delete intermediate files
.SECONDARY:
# Delete files that weren't built properly
.DELETE_ON_ERROR:
#### Main Targets ####
compare: $(ROM)
md5sum -c checksum.md5
clean:
$(RM) $(ROM) $(ELF) $(MAP) $(OFILES)
#### Recipes ####
# Get rid of the idiotic built-in rules
.SUFFIXES:
# Stop deleting my files
.PRECIOUS: %.4bpp
# Link ELF file
$(ELF): $(OFILES) $(LDSCRIPT) $(LD_DEPS)
$(LD) -T $(LDSCRIPT) -Map $(MAP) $(OFILES) -o $@
# Build GBA ROM
%.bin: %.elf
$(OBJCOPY) -S -O binary --gap-fill 0x00 --pad-to 0x4000 $< $@
# Assembly source code
asm/%.o: ASM_DEPS = $(shell tools/scaninc/scaninc asm/$*.s)
asm/%.o: asm/%.s $$(ASM_DEPS)
$(AS) $(ASFLAGS) $< -o $@
# Graphics files
%.4bpp: %.png
$(GBAGFX) $< $@
%.gbapal: %.pal
$(GBAGFX) $< $@
%.lz: %
$(GBAGFX) $< $@
%.huff: %
$(GBAGFX) $< $@
%.inc: ;
include gfxdep.mk