forked from pret/pokeplatinum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (107 loc) · 3.07 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
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
.PHONY: all release debug check rom target format clean distclean setup_release setup_debug configure
MESON ?= meson
NINJA ?= ninja
WINELOADER ?= wine
BUILD ?= build
ROOT_INI := $(BUILD)/root.ini
DOT_MWCONFIG := $(BUILD)/.mwconfig
TOOLS := tools
WRAP := $(TOOLS)/cw
WRAP_BUILD := $(WRAP)/build
MWRAP := $(WRAP)/mwrap
UNAME_R := $(shell uname -r)
UNAME_S := $(shell uname -s)
CWD := $(shell pwd)
ifneq (,$(findstring Microsoft,$(UNAME_R)))
ifneq (,$(filter /mnt/%,$(CWD)))
WSL_ACCESSING_WINDOWS := 0
else
WSL_ACCESSING_WINDOWS := 1
endif
else
WSL_ACCESSING_WINDOWS := 1
endif
WRAP_CONFIG := 0
ifneq (,$(findstring Linux,$(UNAME_S)))
ifeq (0,$(WSL_ACCESSING_WINDOWS))
NATIVE := native.ini
CROSS := cross_unix.ini
else
NATIVE := native_unix.ini
CROSS := cross_unix.ini
endif
else
ifneq (,$(findstring Darwin,$(UNAME_S)))
NATIVE := native_macos.ini
CROSS := cross_unix.ini
else
NATIVE := native.ini
CROSS := cross.ini
endif
endif
export LM_LICENSE_FILE ?= $(WRAP)/license.dat
export NINJA_STATUS := [%p %f/%t]
all: release check
.NOTPARALLEL: release
release: setup_release rom
.NOTPARALLEL: debug
debug: setup_debug rom
$(MESON) compile -C $(BUILD) debug.nef overlay.map
check: rom
$(MESON) test -C $(BUILD)
rom: $(BUILD)/build.ninja
$(MESON) compile -C $(BUILD) pokeplatinum.us.nds
target: $(BUILD)/build.ninja
$(MESON) compile -C $(BUILD) $(MESON_TARGET)
format: $(BUILD)/build.ninja
$(NINJA) -C $(BUILD) clang-format
clean: $(BUILD)/build.ninja
$(MESON) compile -C $(BUILD) --clean
update: $(BUILD)/build.ninja
$(MESON) subprojects update
distclean:
rm -rf $(BUILD) $(MWRAP)
setup_release: $(BUILD)/build.ninja
$(MESON) configure build -Dgdb_debugging=false
setup_debug: $(BUILD)/build.ninja
$(MESON) configure build -Dgdb_debugging=true
configure: $(BUILD)/build.ninja
$(BUILD)/build.ninja: $(ROOT_INI) $(DOT_MWCONFIG) | $(BUILD)
MWCONFIG=$(abspath $(DOT_MWCONFIG)) $(MESON) setup \
--wrap-mode=nopromote \
--native-file=meson/$(NATIVE) \
--native-file=$(ROOT_INI) \
--cross-file=meson/$(CROSS) \
--cross-file=$(ROOT_INI) \
-- $(BUILD)
$(ROOT_INI): | $(BUILD)
echo "[constants]" > $@
echo "root = '$$PWD'" >> $@
$(DOT_MWCONFIG): $(MWRAP) | $(BUILD)
ifneq (,$(filter native_%.ini,$(NATIVE)))
WINE="$$(command -v $(WINELOADER))"; \
BUILD="$(BUILD)"; \
MWCONFIG=$(abspath $(DOT_MWCONFIG)) $(MWRAP) -conf \
-wine "$$WINE" \
-path_unx "$$PWD" \
-path_win "$$("$$WINE" winepath -w "$$PWD")" \
-path_build_unx "$$BUILD" \
-path_build_win "$$("$$WINE" winepath -w "$$BUILD")"
else ifeq (0,$(WSL_ACCESSING_WINDOWS))
BUILD="$(BUILD)"; \
MWCONFIG=$(abspath $(DOT_MWCONFIG)) $(MWRAP) -conf \
-path_unx "$$PWD" \
-path_win "$$(wslpath -w "$$PWD")" \
-path_build_unx "$$BUILD" \
-path_build_win "$$(wslpath -w "$$PWD")"
else
touch $(DOT_MWCONFIG)
endif
$(BUILD):
mkdir -p -- $(BUILD)
$(MWRAP):
rm -rf $(MWRAP) $(WRAP_BUILD)
$(MESON) setup $(WRAP_BUILD) $(WRAP)
$(MESON) compile -C $(WRAP_BUILD)
install -m755 $(WRAP_BUILD)/$(@F) $@
rm -rf $(WRAP_BUILD)