forked from yellows8/oot3dhax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
90 lines (66 loc) · 2.04 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
ifndef DEVKITARM
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
## ======================
## Global variables
## ======================
SAVE_FILES = oot3dhax_eur.bin oot3dhax_usa.bin oot3dhax_jpn.bin
REGIONS = 2 1 0
ELF_FILES = $(SAVE_FILES:.bin=.elf)
## ======================
## oot3d_savetool variables
## TODO: Beautiful compilation with .o file.
## ======================
SAVETOOL_NAME = oot3d_savetool
ST_CFLAGS = -W -Wall -Wextra -std=c99 -O3
SAVETOOL_SRCS = oot3d_savetool.c
SAVETOOL_OPT =
## ======================
## ELF build variables
## ======================
DEFINES =
ifdef DISABLE_DSPSHUTDOWN
DEFINES = -DDISABLE_DSPSHUTDOWN
endif
ELF_FLAGS = -x assembler-with-cpp -nostartfiles -nostdlib -DREGION=$(DREGION) -DEXECHAX=$(EXECHAX) -DFWVER=$(FWVER) $(DEFINES)
ELF_SRCS = oot3dhax.s
## ======================
## BIN build variables
## ======================
BIN_FLAGS = -O binary
## ===================================================================
## Targets
## ===================================================================
all: requirements
$(MAKE) DREGION=$(word 1,$(subst :, ,$(REGIONS))) $(word 1,$(subst :, ,$(SAVE_FILES)))
$(MAKE) DREGION=$(word 2,$(subst :, ,$(REGIONS))) $(word 2,$(subst :, ,$(SAVE_FILES)))
$(MAKE) DREGION=$(word 3,$(subst :, ,$(REGIONS))) $(word 3,$(subst :, ,$(SAVE_FILES)))
## ======================
## Check requirements
## ======================
requirements:
ifndef EXECHAX
$(error "EXECHAX not set.")
endif
ifndef FWVER
$(error "FWVER not set.")
endif
include $(DEVKITARM)/base_rules
## ======================
## Builds targets
## ======================
%.bin: %.elf $(SAVETOOL_NAME)
$(OBJCOPY) $(BIN_FLAGS) $< $@
./$(SAVETOOL_NAME) $(SAVETOOL_OPT) $@
%.elf:
$(CC) $(ELF_FLAGS) $(ELF_SRCS) -o $@
$(SAVETOOL_NAME):
gcc -o $@ $(SAVETOOL_SRCS) $(ST_CFLAGS)
## ======================
## Utils targets
## ======================
clean:
rm -f $(SAVE_FILES) $(ELF_FILES) $(SAVETOOL_NAME)
re: clean all
.PHONY: clean all re
.PRECIOUS: %.elf %.bin