-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathMakefile
More file actions
167 lines (135 loc) · 3.53 KB
/
Copy pathMakefile
File metadata and controls
167 lines (135 loc) · 3.53 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
# Keep this list in alphabetical order for ease of reference.
.PHONY: \
all \
check \
clean \
configure \
distclean \
debug \
format \
meson \
purge \
release \
rom \
setup_debug \
setup_release \
skrew \
skrewrm \
skrewup \
target \
update
ROM_REVISION ?= 1
SUBPROJ_DIR := subprojects
MESON_VER := 1.10.0
MESON_DIR := $(SUBPROJ_DIR)/meson-$(MESON_VER)
MESON_SUB := $(MESON_DIR)/meson.py
MESON ?= $(MESON_SUB)
NINJA ?= ninja
GIT ?= git
BUILD ?= build
UNAME_R := $(shell uname -r)
UNAME_S := $(shell uname -s)
CWD := $(shell pwd)
# Check for Windows-drive access
ifneq (,$(findstring Microsoft,$(UNAME_R)))
ifneq (,$(filter /mnt/%,$(realpath $(CWD))))
WSL_ACCESSING_WINDOWS := 0
else
WSL_ACCESSING_WINDOWS := 1
endif
else
WSL_ACCESSING_WINDOWS := 1
endif
# Set up the compiler toolchain dependency
SKREW_GET := tools/devtools/get_metroskrew.sh
SKREW_VER := 0.1.3
SKREW_DIR := tools/metroskrew
ifneq (,$(findstring Linux,$(UNAME_S)))
ifeq (0,$(WSL_ACCESSING_WINDOWS))
NATIVE := native.ini
CROSS := cross.ini
SKREW_SYS := windows
SKREW_EXE := $(SKREW_DIR)/bin/skrewrap.exe
else
NATIVE := native.ini
CROSS := cross_unix.ini
SKREW_SYS := linux
SKREW_EXE := $(SKREW_DIR)/bin/skrewrap
endif
else
ifneq (,$(findstring Darwin,$(UNAME_S)))
NATIVE := native_macos.ini
CROSS := cross_unix.ini
SKREW_SYS := wine
SKREW_EXE := $(SKREW_DIR)/bin/skrewrap
else
ifneq (,$(findstring BSD, $(UNAME_S)))
NATIVE := native.ini
CROSS := cross_unix.ini
SKREW_SYS := linux
SKREW_EXE := $(SKREW_DIR)/bin/skrewrap
else
NATIVE := native.ini
CROSS := cross.ini
SKREW_SYS := windows
SKREW_EXE := $(SKREW_DIR)/bin/skrewrap.exe
endif
endif
endif
export NINJA_STATUS := [%p %f/%t]
# Modders can delete the `check` dependency here after their first build.
all: release check
.NOTPARALLEL: release
release: setup_release rom
.NOTPARALLEL: debug
debug: setup_debug rom
$(NINJA) -C $(BUILD) debug.nef overlay.map
check: rom
$(MESON) test -C $(BUILD)
rom: $(BUILD)/build.ninja
$(NINJA) -C $(BUILD) pokeplatinum.us.nds
format: $(BUILD)/build.ninja
$(NINJA) -C $(BUILD) clang-format
target: $(BUILD)/build.ninja
$(MESON) compile -C $(BUILD) $(MESON_TARGET)
clean: $(BUILD)/build.ninja
$(MESON) compile -C $(BUILD) --clean
rm -rf $(BUILD)/res
distclean:
rm -rf $(BUILD)
purge: distclean
rm -rf $(SKREW_DIR)
ifeq ($(MESON),$(MESON_SUB))
! test -f $(MESON) || $(MESON) subprojects purge --confirm
rm -rf $(MESON_DIR)
else
$(MESON) subprojects purge --confirm
endif
update: meson skrewup
$(MESON) subprojects update || true
setup_release: $(BUILD)/build.ninja
$(MESON) configure $(BUILD) -Dgdb_debugging=false -Dlogging_enabled=false
setup_debug: $(BUILD)/build.ninja
$(MESON) configure $(BUILD) -Dgdb_debugging=true -Dlogging_enabled=true
configure: $(BUILD)/build.ninja
$(BUILD)/build.ninja: | $(BUILD) $(SKREW_EXE) meson
$(MESON) setup \
-Drevision=$(ROM_REVISION) \
--wrap-mode=nopromote \
--native-file=meson/$(NATIVE) \
--cross-file=meson/$(CROSS) \
-- $(BUILD)
$(BUILD):
mkdir -p -- $(BUILD)
meson: ;
ifeq ($(MESON),$(MESON_SUB))
meson: $(MESON_SUB)
endif
$(MESON_SUB):
$(GIT) clone --depth=1 -b $(MESON_VER) https://github.com/mesonbuild/meson $(@D)
skrew: $(SKREW_EXE)
skrewrm:
rm -rf $(SKREW_DIR)
skrewup: skrewrm skrew
$(SKREW_EXE):
SKREW_SYS=$(SKREW_SYS) SKREW_VER=$(SKREW_VER) SKREW_DIR=$(SKREW_DIR) $(SKREW_GET)