Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
115 lines (93 loc) · 3.64 KB
/
Copy pathMakefile
File metadata and controls
115 lines (93 loc) · 3.64 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
# WonderMenu -- top-level build
#
# Builds the two sub-projects in dependency order:
#
# payload/ -- the Expansion Pak resident payload (payload.z64 + a stripped
# ELF, which the menu's build flattens into the payload.bin it
# loads in place at runtime)
# menu/ -- the menu ROM itself (WonderMenu.z64)
#
# The menu embeds the payload as a filesystem asset (see PayloadImage /
# BootSession), so the payload must be built first and its output copied into
# menu/assets/ before the menu's DFS is packed.
N64_INST ?= /opt/libdragon
export N64_INST
PAYLOAD_ELF = payload/build/payload.elf.stripped
MENU_PAYLOAD_ELF = menu/assets/payload.elf.stripped
# The payload is built from a sibling checkout that isn't always present. When
# it's missing, build the menu against whatever payload.elf.stripped is already
# in menu/assets/ rather than failing on a directory we can't enter.
HAVE_PAYLOAD := $(wildcard payload/Makefile)
ifeq ($(HAVE_PAYLOAD),)
MENU_PAYLOAD_DEP =
else
MENU_PAYLOAD_DEP = $(MENU_PAYLOAD_ELF)
endif
all: menu
.PHONY: all
# --- payload ---------------------------------------------------------------
payload:
ifeq ($(HAVE_PAYLOAD),)
@echo "==> payload (skipped -- payload/ not found)"
else
@echo "==> payload"
$(MAKE) -C payload
endif
.PHONY: payload
# Phony prerequisite, so the payload's own Makefile always gets a chance to
# decide whether the ELF is out of date -- we don't second-guess it here.
$(PAYLOAD_ELF): payload
# Only touch the copy in menu/assets when the bytes actually differ. Otherwise
# every top-level build would give the menu a newer asset mtime and force a
# full DFS repack for no reason.
$(MENU_PAYLOAD_ELF): $(PAYLOAD_ELF)
@cmp -s "$<" "$@" || { cp -f "$<" "$@" && echo " [PAYLOAD] $< -> $@"; }
# --- menu ------------------------------------------------------------------
menu: $(MENU_PAYLOAD_DEP)
@echo "==> menu"
$(MAKE) -C menu
.PHONY: menu
# The debug build is the menu's default one
debug: menu
.PHONY: debug
# Pass-throughs to menu/, but gated on a current payload asset first, so a
# release ROM can never embed a stale payload.elf.stripped.
release sc64: $(MENU_PAYLOAD_DEP)
$(MAKE) -C menu $@
.PHONY: release sc64
# `console` and `emu` deploy whichever build is named alongside them (e.g.
# `make release emu`), or the debug build when none is. Each goal is only made
# once, so the build named first isn't made again.
ifneq ($(filter release,$(MAKECMDGOALS)),)
MENU_BUILD = release
MENU_ROM = menu/WonderMenu-release.z64
else
MENU_BUILD = debug
MENU_ROM = menu/WonderMenu.z64
endif
# --- console ---------------------------------------------------------------
SC64DEPLOYER ?= sc64deployer
# Build the ROM, then push it to a connected SummerCart64.
console: $(MENU_BUILD)
@command -v $(SC64DEPLOYER) >/dev/null || { echo "console: $(SC64DEPLOYER) not found in PATH"; exit 1; }
@echo " [SC64] upload $(MENU_ROM)"
$(SC64DEPLOYER) upload "$(CURDIR)/$(MENU_ROM)" --direct
$(SC64DEPLOYER) debug
.PHONY: console
# --- emulator --------------------------------------------------------------
ARES ?= /Applications/ares.app/Contents/MacOS/ares
# Build the ROM, then boot it in ares. Invoked via the binary inside the bundle
# rather than `open -a` so that ares takes the ROM path as an argument and its
# stdout/stderr stay attached to this terminal.
emu: $(MENU_BUILD)
@test -x "$(ARES)" || { echo "emu: ares not found at $(ARES)"; exit 1; }
@echo " [ARES] $(MENU_ROM)"
"$(ARES)" "$(CURDIR)/$(MENU_ROM)"
.PHONY: emu
# --- housekeeping ----------------------------------------------------------
clean:
ifneq ($(HAVE_PAYLOAD),)
$(MAKE) -C payload clean
endif
$(MAKE) -C menu clean
.PHONY: clean