-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (67 loc) · 1.9 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
# binary tools used in build
# (devkitpro/devkitARM/bin should be in path)
MAKE = make
CC = arm-none-eabi-gcc
# CC = "/c/Program Files (x86)/GNU Tools Arm Embedded/7 2018-q2-update/bin/arm-none-eabi-gcc"
AS = arm-none-eabi-as
LD = arm-none-eabi-ld
# CC = "/c/Program Files (x86)/GNU Tools Arm Embedded/7 2018-q2-update/bin/arm-none-eabi-ld"
OBJCOPY = arm-none-eabi-objcopy
SHA1SUM = sha1sum
PY = py
# project paths
SRCDIR = asm
BIN = bin
CONST = constants
EXTERNS = externs
INC = inc
# project files
SFILES = $(SRCDIR)/_rom.s
OFILES = $(addprefix $(OBJ),$(notdir $(SFILES:.s=.o)))
ROM = exe4rs
# build flags
COMPLIANCE_FLAGS = -O0 -g3 -I$(INC)
WFLAGS =
ARCH = -march=armv4t -mtune=arm7tdmi -mabi=aapcs -mthumb -mthumb-interwork
CDEBUG =
CFLAGS = $(ARCH) $(WFLAGS) $(COMPLIANCE_FLAGS) $(CDEBUG)
ASFLAGS =
LDFLAGS = -g -Map $(ROM).map
LIB =
all:
rom: $(ROM)
@# TODO: this tab is needed or ROM is executed weirdly?? oops!
$(ROM):
$(CC) $(CFLAGS) -c $(SFILES)
$(LD) $(LDFLAGS) -o $(ROM).elf -T ld_script.x $(OFILES) $(LIB)
$(OBJCOPY) -O binary $(ROM).elf $(ROM).gba
checksum:
$(SHA1SUM) -b $(BIN)/$(ROM).bin $(ROM).gba
fdiff:
$(PY) tools/fdiff.py bin/$(ROM).bin $(ROM).gba -s2
tail: $(ROM)
@# Create tail.bin using the tail location in current elf then compile again
$(PY) tools/gen_obj_tail.py $(ROM).elf bin/$(ROM).bin bin/tail.bin 'tail'
@echo "Updated tail.bin!"
clean:
rm -f *.preout
rm -f *.o
rm -f *.out
rm -f *.d
rm -f *.map
rm -f *.elf
# Rule for how to translate a single c file into an object file.
%.o : %.c
echo compiling $<
echo $(CC) $(CFLAGS) -c $<
$(CC) $(CFLAGS) -E $< > $<.preout
$(CC) $(CFLAGS) -S $<
$(CC) $(CFLAGS) -c $<
echo done compiling $<
# Rule for how to generate the dependencies for the given files.
# -M gcc option generates dependencies.
%.d : %.c
@set -e; rm -f $@; \
$(CC) $(COMPLIANCE_FLAGS ) -M $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$