-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
116 lines (84 loc) · 3.15 KB
/
Makefile
File metadata and controls
116 lines (84 loc) · 3.15 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
ifneq ($(findstring MINGW,$(shell uname)),)
WINDOWS := 1
endif
ifneq ($(findstring MSYS,$(shell uname)),)
WINDOWS := 1
endif
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
TARGET_COL := gamecube
TARGET := gnt4
BUILD_DIR := build/$(TARGET)
SRC_DIRS := src src/msl src/msl/ppc_eabi src/runtime src/sysdolphin
ASM_DIRS := asm asm/sysdolphin asm/hvqm asm/musyx asm/si asm/exi asm/PPCEABI/MSL_C asm/PPCEABI/Runtime \
asm/TRK_MINNOW_DOLPHIN asm/gx asm/card asm/dsp asm/ar asm/ai asm/pad asm/vi asm/dvd \
asm/mtx asm/db asm/os asm/base
# Inputs
LDSCRIPT := $(BUILD_DIR)/ldscript.lcf
# Outputs
DOL := $(BUILD_DIR)/main.dol
ELF := $(DOL:.dol=.elf)
MAP := $(BUILD_DIR)/gnt4.map
include obj_files.mk
O_FILES := $(INIT_O_FILES) $(CTORS_O_FILES) $(DTORS_O_FILES) $(TEXT_O_FILES) \
$(RODATA_O_FILES) $(DATA_O_FILES) $(SDATA_O_FILES) $(SDATA2_O_FILES) \
$(BSS_O_FILES) $(SBSS_O_FILES) $(SBSS2_O_FILES)
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
MWCC_VERSION := 2.7
# Programs
ifeq ($(WINDOWS),1)
WINE :=
else
WINE := wine
endif
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
OBJCOPY := $(DEVKITPPC)/bin/powerpc-eabi-objcopy
CPP := cpp -P
CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc.exe
LD := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwldeppc.exe
ELF2DOL := tools/elf2dol
SHA1SUM := sha1sum
PYTHON := python3
POSTPROC := tools/postprocess.py
# Options
INCLUDES := -i include -i include/dolphin/ -i src -i src/sysdolphin
ASFLAGS := -mgekko -I include
LDFLAGS := -map $(MAP) -fp hard -nodefaults
CFLAGS := -Cpp_exceptions off -proc gekko -fp hard -O4,p -nodefaults -msgstyle gcc $(INCLUDES)
# for postprocess.py
PROCFLAGS := -fprologue-fixup=old_stack
#-------------------------------------------------------------------------------
# Recipes
#-------------------------------------------------------------------------------
### Default target ###
default: all
all: $(DOL)
ALL_DIRS := build $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS))
# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $(ALL_DIRS)
.PHONY: tools
$(LDSCRIPT): ldscript.lcf
$(CPP) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $<
$(DOL): $(ELF) | tools
$(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL)
$(SHA1SUM) -c $(TARGET).sha1
clean:
rm -f -d -r build
$(MAKE) -C tools clean
tools:
$(MAKE) -C tools
$(ELF): $(O_FILES) $(LDSCRIPT)
$(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) $(O_FILES)
# The Metrowerks linker doesn't generate physical addresses in the ELF program headers. This fixes it somehow.
$(OBJCOPY) $@ $@
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
# TODO: See if this is necessary after actually adding some C code
# $(PYTHON) $(POSTPROC) $(PROCFLAGS) $@
### Debug Print ###
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true