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.)
This commit is contained in:
comex 2025-08-16 12:14:46 -07:00 committed by Michael Scire
parent 4a51fffa97
commit 80e9af79a8
4 changed files with 20 additions and 3 deletions

View File

@ -297,6 +297,23 @@ FIND_SOURCE_FILES=$(foreach dir,$1,$(filter-out $(notdir $(wildcard $(dir)/*.arc
ATMOSPHERE_GCH_IDENTIFIER := $(ATMOSPHERE_FULL_NAME) 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 # Rules for compiling pre-compiled headers
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

View File

@ -104,7 +104,7 @@ clean:
@echo clean $(ATMOSPHERE_BUILD_NAME) ... @echo clean $(ATMOSPHERE_BUILD_NAME) ...
@rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR) @rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR)
@rm -fr $(foreach hdr,$(GCH_DIRS),$(hdr)/$(ATMOSPHERE_GCH_IDENTIFIER)) @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): $(ATMOSPHERE_LIBRARY_DIR) $(ATMOSPHERE_BUILD_DIR) $(GCH_DIRS):
@[ -d $@ ] || mkdir -p $@ @[ -d $@ ] || mkdir -p $@

View File

@ -86,7 +86,7 @@ clean:
@echo clean $(ATMOSPHERE_BUILD_NAME) ... @echo clean $(ATMOSPHERE_BUILD_NAME) ...
@rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR) @rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR)
@rm -fr $(foreach hdr,$(GCH_DIRS),$(hdr)/$(ATMOSPHERE_GCH_IDENTIFIER)) @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): $(ATMOSPHERE_LIBRARY_DIR) $(ATMOSPHERE_BUILD_DIR) $(GCH_DIRS):
@[ -d $@ ] || mkdir -p $@ @[ -d $@ ] || mkdir -p $@

View File

@ -118,7 +118,7 @@ clean:
@echo clean $(ATMOSPHERE_BUILD_NAME) ... @echo clean $(ATMOSPHERE_BUILD_NAME) ...
@rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR) @rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_OUT_DIR)
@rm -fr $(foreach hdr,$(GCH_DIRS),$(hdr)/$(ATMOSPHERE_GCH_IDENTIFIER)) @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): $(ATMOSPHERE_LIBRARY_DIR) $(ATMOSPHERE_BUILD_DIR) $(GCH_DIRS):
@[ -d $@ ] || mkdir -p $@ @[ -d $@ ] || mkdir -p $@