-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
90 lines (68 loc) · 2.16 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
# binary tools used in build
MAKE = make
AS = tools/binutils/bin/arm-none-eabi-as
LD = tools/binutils/bin/arm-none-eabi-ld
OBJCOPY = tools/binutils/bin/arm-none-eabi-objcopy
OBJDUMP := tools/binutils/bin/arm-none-eabi-objdump
GBAGFX = tools/gbagfx/gbagfx
SHA1SUM = sha1sum
PY = py
# project paths
SRCDIR = asm
BIN = bin
CONST = constants
INC = include
# project files
SFILES = rom.s data.s ewram.s iwram.s
# to keep track of compressed files and to build decompressed versions into them
# defines rules to build and compress lz files
include lz_assets.mk
OFILES = $(addprefix $(OBJ),$(SFILES:.s=.o))
BUILD_NAME = bn6f
ROM = $(BUILD_NAME).gba
ELF := $(ROM:.gba=.elf)
SYM = $(ROM:.gba=.sym)
NOGBASYM = bn6f_nogba.sym
# build flags
COMPLIANCE_FLAGS = -g -I$(INC)
WFLAGS =
ARCH = -mcpu=arm7tdmi -march=armv4t -mthumb -mthumb-interwork
CDEBUG =
CFLAGS =
ASFLAGS = $(ARCH) $(WFLAGS) $(COMPLIANCE_FLAGS) --agbasm-colonless-labels --agbasm-colon-defined-global-labels --agbasm-local-labels --agbasm-multiline-macros \
--agbasm-charmap --agbasm-no-gba-thumb-after-label-disasm-fix
ASDEBUGFLAGS = --agbasm-debug $(@:.o=.dump)
LDFLAGS = -Map $(BUILD_NAME).map
LIB =
.PHONY: syms
# TODO: INTEGRATE SCAN INCLUDES
all: $(ROM)
@$(SHA1SUM) -c $(BUILD_NAME).sha1
$(ROM): %.elf
$(OBJCOPY) -O binary $(ELF) $(ROM)
%.elf: $(OFILES)
$(LD) $(LDFLAGS) -o $(ELF) -T ld_script.ld $(OFILES) $(LIB)
%.o: %.s
$(AS) $(ASFLAGS) $< -o $@
assets: $(LZ_FILES) $(LZ_BINFILES)
checksum:
@$(SHA1SUM) -c $(BUILD_NAME).sha1
fdiff:
$(PY) tools/fdiff.py $(BUILD_NAME).ign $(ROM) -s2
tail: $(ROM)
@# Create tail.bin using the tail location in current elf then compile again
$(PY) tools/gen_obj_tail.py $(ELF) _$(ROM) bin/tail.bin 'tail'
@echo "Updated tail.bin!"
clean:
rm -f *.o
rm -f *.map
rm -f *.elf
# rm -f *.gba
rm -f $(COMPRESSED_TEXT_ARCHIVES_DIR)/*.lz
rm -f $(COMPRESSED_TEXT_ARCHIVES_DIR)/*.bin
syms: $(SYM)
$(SYM): $(ELF)
$(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" | perl -p -e 's/^(\w{8}) (\w).{6} \S+\t(\w{8}) (\S+)$$/\1 \2 \3 \4/g' > $@
nogbasyms: $(NOGBASYM)
$(NOGBASYM): $(ELF)
$(OBJDUMP) -t $< | sort -u | grep -E "^0" | perl -p -e 's/^(\w{8}) (\w).{6} \S+\t(\w{8}) (\S+)$$/\1 \4/g' > $@