mirror of
https://github.com/pret/pokeplatinum.git
synced 2026-03-21 17:55:13 -05:00
Some checks are pending
build / build (push) Waiting to run
* Remove extraneous `include/` directory level from brightness_controller * Wrap WSL_ACCESSING_WINDOWS detection in realpath * Integrate metroskrew as the default compiler * Remove tools/cw contents
156 lines
3.7 KiB
Makefile
156 lines
3.7 KiB
Makefile
.PHONY: all release debug check rom data target format clean distclean purge update setup_release setup_debug configure skrew meson
|
|
|
|
SUBPROJ_DIR := subprojects
|
|
|
|
MESON_VER := 1.7.0
|
|
MESON_DIR := $(SUBPROJ_DIR)/meson-$(MESON_VER)
|
|
MESON_SUB := $(MESON_DIR)/meson.py
|
|
|
|
MESON ?= $(MESON_SUB)
|
|
NINJA ?= ninja
|
|
GIT ?= git
|
|
|
|
BUILD ?= build
|
|
ROOT_INI := $(BUILD)/root.ini
|
|
|
|
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.2
|
|
SKREW_DIR := $(SUBPROJ_DIR)/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)
|
|
|
|
.NOTPARALLEL: rom
|
|
# We use a two-stage pipeline to absolve what appears to be a bug in Ninja
|
|
# where generated headers that are listed as order-only dependencies are not
|
|
# respected by the depfiles generated by compiling source code. To that end, we
|
|
# generate data-targets first (archives and generated headers), then proceed
|
|
# with compiling the ROM code.
|
|
rom: $(BUILD)/build.ninja data
|
|
$(NINJA) -C $(BUILD) pokeplatinum.us.nds
|
|
|
|
data: $(BUILD)/build.ninja
|
|
$(NINJA) -C $(BUILD) data
|
|
|
|
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
|
|
|
|
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
|
|
$(MESON) subprojects update
|
|
|
|
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) | $(BUILD) $(SKREW_EXE) meson
|
|
$(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'" >> $@
|
|
|
|
$(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)
|
|
|
|
$(SKREW_EXE):
|
|
SKREW_SYS=$(SKREW_SYS) SKREW_VER=$(SKREW_VER) SKREW_DIR=$(SKREW_DIR) $(SKREW_GET)
|