-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
211 lines (165 loc) · 5.31 KB
/
Makefile
File metadata and controls
211 lines (165 loc) · 5.31 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
ifneq ($(findstring MINGW,$(shell uname)),)
WINDOWS := 1
endif
ifneq ($(findstring MSYS,$(shell uname)),)
WINDOWS := 1
endif
NON_MATCHING ?= 0
# If 0, tells the console to chill out. (Quiets the make process.)
VERBOSE ?= 0
# If MAPGENFLAG set to 1, tells LDFLAGS to generate a mapfile, which makes linking take several minutes.
MAPGENFLAG ?= 1
ifeq ($(VERBOSE),0)
QUIET := @
endif
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
NAME := NDDEMO
VERSION ?= 1
VERSION := jp
BUILD_DIR := build/$(NAME)
# Inputs
S_FILES := $(wildcard asm/*.s)
C_FILES := $(wildcard src/*.c)
CPP_FILES := $(wildcard src/*.cpp)
CPP_FILES += $(wildcard src/*.cp)
LDSCRIPT_DOL := $(BUILD_DIR)/ldscript.lcf
# Outputs
DOL := $(BUILD_DIR)/main.dol
ELF := $(DOL:.dol=.elf)
MAP := $(BUILD_DIR)/$(NAME).MAP
ifeq ($(MAPGENFLAG),1)
MAPGEN := -map $(MAP)
endif
include obj_files.mk
O_FILES := $(NDDEMO) $(DOLPHIN)
DEPENDS := $($(filter *.o,O_FILES):.o=.d)
DEPENDS += $($(filter *.o,E_FILES):.o=.d)
# If a specific .o file is passed as a target, also process its deps
DEPENDS += $(MAKECMDGOALS:.o=.d)
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
MWCC_VERSION := 1.2.5
MWLD_VERSION := 1.2.5
CONSOLE := GC
# Tool versions (keep in sync with configure.py)
BINUTILS_TAG := 2.42-1
COMPILERS_TAG := 20250812
DTK_TAG := v1.7.1
SJISWRAP_TAG := v1.2.2
WIBO_TAG := 1.0.0-beta.5
# Programs
BINUTILS ?= build/binutils
COMPILERS ?= build/compilers
DTK ?= build/tools/dtk
SJISWRAP ?= build/tools/sjiswrap.exe
WIBO ?= build/tools/wibo
ifeq ($(WINDOWS),1)
WRAPPER :=
AS := $(BINUTILS)/powerpc-eabi-as.exe
PYTHON := python
else
WRAPPER := $(WIBO)
AS := $(BINUTILS)/powerpc-eabi-as
PYTHON := python3
endif
CC = $(WRAPPER) $(SJISWRAP) $(COMPILERS)/GC/$(MWCC_VERSION)/mwcceppc.exe
LD := $(WRAPPER) $(COMPILERS)/GC/$(MWLD_VERSION)/mwldeppc.exe
ifneq ($(WINDOWS),1)
TRANSFORM_DEP := tools/transform-dep.py
else
TRANSFORM_DEP := tools/transform-win.py
endif
# Options
INCLUDES := -I- -i include/ -i include/std/
ASM_INCLUDES := -I include/
ASFLAGS := -mgekko $(ASM_INCLUDES)
ifeq ($(VERBOSE),1)
# this set of LDFLAGS outputs warnings.
LDFLAGS := $(MAPGEN) -fp hard -nodefaults
endif
ifeq ($(VERBOSE),0)
# this set of LDFLAGS generates no warnings.
LDFLAGS := $(MAPGEN) -fp hard -nodefaults -w off
endif
LIBRARY_LDFLAGS := -nodefaults -fp hard -proc gekko
CFLAGS = -O4,p -enum int -inline auto -proc gekko -fp hard -nodefaults -Cpp_exceptions off -use_lmw_stmw on $(INCLUDES)
ifeq ($(VERBOSE),0)
# this set of ASFLAGS generates no warnings.
ASFLAGS += -W
# this set of CFLAGS generates no warnings.
CFLAGS += -w off
endif
#-------------------------------------------------------------------------------
# Recipes
#-------------------------------------------------------------------------------
### Default target ###
default: all
all: $(DOL)
ALL_DIRS := $(sort $(dir $(O_FILES)))
# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $(ALL_DIRS)
LDSCRIPT := ldscript.lcf
$(DOL): $(ELF) | $(DTK)
$(QUIET) $(DTK) elf2dol $< $@
$(QUIET) $(DTK) shasum -c sha1/$(NAME).sha1
ifneq ($(findstring -map,$(LDFLAGS)),)
$(QUIET) $(PYTHON) tools/calcprogress.py $(DOL) $(MAP)
endif
clean:
rm -f -d -r build
$(DTK):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py dtk $@ --tag $(DTK_TAG)
$(SJISWRAP):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py sjiswrap $@ --tag $(SJISWRAP_TAG)
$(BINUTILS):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py binutils $@ --tag $(BINUTILS_TAG)
$(COMPILERS):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py compilers $@ --tag $(COMPILERS_TAG)
$(WIBO):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py wibo $@ --tag $(WIBO_TAG)
# ELF creation makefile instructions
$(ELF): $(O_FILES) $(LDSCRIPT) $(WRAPPER) $(COMPILERS)
@echo Linking ELF $@
$(QUIET) @echo $(O_FILES) > build/o_files
$(QUIET) $(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files
-include include_link.mk
DEPENDS := $(DEPENDS:.d=.d.unix)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPENDS)
endif
$(BUILD_DIR)/%.o: %.s | $(BINUTILS) $(DTK)
@echo Assembling $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(AS) $(ASFLAGS) -o $@ $<
$(QUIET) $(DTK) elf fixup $@ $@
$(BUILD_DIR)/%.o: %.c | $(WRAPPER) $(COMPILERS) $(SJISWRAP)
@echo "Compiling " $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<
$(BUILD_DIR)/%.o: %.C | $(WRAPPER) $(COMPILERS) $(SJISWRAP)
@echo "Compiling " $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<
$(BUILD_DIR)/%.o: %.cp | $(WRAPPER) $(COMPILERS) $(SJISWRAP)
@echo "Compiling " $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<
$(BUILD_DIR)/%.o: %.cpp | $(WRAPPER) $(COMPILERS) $(SJISWRAP)
@echo "Compiling " $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<
### Debug Print ###
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true