From 80e9af79a82ddce0e56852e53d3bebd9b27e62a9 Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 16 Aug 2025 12:14:46 -0700 Subject: [PATCH] build: portability fixes - Invoke Python scripts with `python3` if `python` is not available. Despite SciresM preferring Python 2, the scripts used in the build all worked in Python 3 already, so this is just a Makefile change. - Export `MAKE` to work around a GNU bug. See the comment for details. - `rmdir --ignore-fail-on-non-empty` -> `rmdir 2>/dev/null` macOS `rmdir` doesn't support `--ignore-fail-on-non-empty`. This is a slight downgrade in functionality, because now we ignore all errors from `rmdir` rather than just 'Directory not empty'. I could have avoided this with a more complicated fix, but the benefit strikes me as not worth the complexity. Let me know if you disagree. - Append `$(DEVKITPRO)/tools/bin/` to `$PATH` when invoking `build_romfs`. This avoids the need to add devkitPro directories to `$PATH` when building Atmosphere. If you already have `build_romfs` in your PATH, then that will still take precedence. (This seemed like the nicer option, though I don't have strong opinions.) --- config/common.mk | 17 +++++++++++++++++ libexosphere/libexosphere.mk | 2 +- libmesosphere/libmesosphere.mk | 2 +- libstratosphere/libstratosphere.mk | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/config/common.mk b/config/common.mk index ed196586..7ef3708f 100644 --- a/config/common.mk +++ b/config/common.mk @@ -297,6 +297,23 @@ FIND_SOURCE_FILES=$(foreach dir,$1,$(filter-out $(notdir $(wildcard $(dir)/*.arc ATMOSPHERE_GCH_IDENTIFIER := $(ATMOSPHERE_FULL_NAME) +#--------------------------------------------------------------------------------- +# Python. The scripts should work with Python 2 or 3, but 2 is preferred. +#--------------------------------------------------------------------------------- +PYTHON = $(shell command -v python >/dev/null && echo python || echo python3) + +#--------------------------------------------------------------------------------- +# Export MAKE: +# GCC's LTO driver invokes Make internally. This invocation respects both $(MAKE) +# and $(MAKEFLAGS), but only if they're in the environment. By default, MAKEFLAGS +# is in the environment while MAKE isn't, so GCC will always use the default +# `make` command, yet it inherits MAKEFLAGS from the copy of Make the user +# invoked, which might have incompatible flags. In practice this is an issue on +# macOS when running e.g. `gmake -j32 -Otarget`. This behavior is arguably a bug +# in GCC and/or Make, but we can work around it by exporting MAKE. +#--------------------------------------------------------------------------------- +export MAKE + #--------------------------------------------------------------------------------- # Rules for compiling pre-compiled headers #--------------------------------------------------------------------------------- diff --git a/libexosphere/libexosphere.mk b/libexosphere/libexosphere.mk index c24c9472..616e1e53 100644 --- a/libexosphere/libexosphere.mk +++ b/libexosphere/libexosphere.mk @@ -104,7 +104,7 @@ clean: @echo clean $(ATMOSPHERE_BUILD_NAME) ... @rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR) @rm -fr $(foreach hdr,$(GCH_DIRS),$(hdr)/$(ATMOSPHERE_GCH_IDENTIFIER)) - @for i in $(GCH_DIRS); do [ -d $$i ] && rmdir --ignore-fail-on-non-empty $$i || true; done + @for i in $(GCH_DIRS); do [ -d $$i ] && rmdir $$i 2>/dev/null || true; done $(ATMOSPHERE_LIBRARY_DIR) $(ATMOSPHERE_BUILD_DIR) $(GCH_DIRS): @[ -d $@ ] || mkdir -p $@ diff --git a/libmesosphere/libmesosphere.mk b/libmesosphere/libmesosphere.mk index 79c2c13e..2ab310a2 100644 --- a/libmesosphere/libmesosphere.mk +++ b/libmesosphere/libmesosphere.mk @@ -86,7 +86,7 @@ clean: @echo clean $(ATMOSPHERE_BUILD_NAME) ... @rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR) @rm -fr $(foreach hdr,$(GCH_DIRS),$(hdr)/$(ATMOSPHERE_GCH_IDENTIFIER)) - @for i in $(GCH_DIRS); do [ -d $$i ] && rmdir --ignore-fail-on-non-empty $$i || true; done + @for i in $(GCH_DIRS); do [ -d $$i ] && rmdir $$i 2>/dev/null || true; done $(ATMOSPHERE_LIBRARY_DIR) $(ATMOSPHERE_BUILD_DIR) $(GCH_DIRS): @[ -d $@ ] || mkdir -p $@ diff --git a/libstratosphere/libstratosphere.mk b/libstratosphere/libstratosphere.mk index faec4fdb..5c444caf 100644 --- a/libstratosphere/libstratosphere.mk +++ b/libstratosphere/libstratosphere.mk @@ -118,7 +118,7 @@ clean: @echo clean $(ATMOSPHERE_BUILD_NAME) ... @rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR) @rm -fr $(foreach hdr,$(GCH_DIRS),$(hdr)/$(ATMOSPHERE_GCH_IDENTIFIER)) - @for i in $(GCH_DIRS); do [ -d $$i ] && rmdir --ignore-fail-on-non-empty $$i || true; done + @for i in $(GCH_DIRS); do [ -d $$i ] && rmdir $$i 2>/dev/null || true; done $(ATMOSPHERE_LIBRARY_DIR) $(ATMOSPHERE_BUILD_DIR) $(GCH_DIRS): @[ -d $@ ] || mkdir -p $@