-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
46 lines (30 loc) · 1.25 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
OBJECTS := trampoline.o init.o ar_original_trampoline.o satiator.o pad.o sneaky_hook.o sneaky_hook_isr.o
OBJFILES := $(addprefix out/, $(OBJECTS))
CROSS_COMPILE ?= sh-none-elf-
CFLAGS := -fno-PIC -no-pie -Wall -ggdb -O2 -m2 -nostdlib -ffunction-sections -fdata-sections -ffreestanding
VERSION ?= $(shell git describe --exact-match --tags --dirty || (echo -n git-; git describe --always --dirty))
VERSION_STR ?= $(VERSION) $(shell date +%y%m%d%H%M%S)
CFLAGS += -DVERSION='"$(VERSION_STR)"'
OUT_FILE=ar_patched-$(VERSION)
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
OBJCOPY := $(CROSS_COMPILE)objcopy
AR_SRC_BIN := ARP_202C.BIN
$(shell mkdir -p out)
out/$(OUT_FILE).bin: out/arpatch.srec patch_bin.py
# Saves go in the second half of the cart, so we only use the first half
./patch_bin.py $< $(AR_SRC_BIN) $@ 0x20000
out/%.srec: out/%.elf
$(OBJCOPY) -O srec $< $@
out/arpatch.elf: arpatch.ld $(OBJFILES)
$(LD) -Map=out/arpatch.map --gc-sections -o $@ -T$^
out/ar_original_trampoline.o: $(AR_SRC_BIN)
dd if=$< of=out/ar_original_trampoline.bin bs=1 skip=3840 count=68
$(LD) -r -b binary -o $@ out/ar_original_trampoline.bin
out/%.o: %.S
$(CC) $(CFLAGS) -c $< -o $@
out/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf out/
.PHONY: default clean