From bfc6612cbf0460955deca28e9ad92d0ff8856668 Mon Sep 17 00:00:00 2001 From: Rangi Date: Fri, 17 Apr 2020 10:59:01 -0400 Subject: [PATCH] Use a separate build object to check the rgbds version rgbdscheck.o is built without passing potentially non-backwards-compatible flags to rgbasm. Resolves #710. --- Makefile | 7 +++++-- constants.asm | 4 ---- rgbdscheck.asm | 12 ++++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 rgbdscheck.asm diff --git a/Makefile b/Makefile index e3671d582..a8709f914 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ crystal11: pokecrystal11.gbc crystal-au: pokecrystal-au.gbc clean: - rm -f $(roms) $(crystal_obj) $(crystal11_obj) $(crystal_au_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) + rm -f $(roms) $(crystal_obj) $(crystal11_obj) $(crystal_au_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) rgbdscheck.o find gfx \( -name "*.[12]bpp" -o -name "*.lz" -o -name "*.gbcpal" -o -name "*.sgb.tilemap" \) -delete find gfx/pokemon -mindepth 1 ! -path "gfx/pokemon/unown/*" \( -name "bitmask.asm" -o -name "frames.asm" -o -name "front.animated.tilemap" -o -name "front.dimensions" \) -delete $(MAKE) clean -C tools/ @@ -71,11 +71,14 @@ $(crystal_obj): RGBASMFLAGS += $(crystal11_obj): RGBASMFLAGS += -D _CRYSTAL11 $(crystal_au_obj): RGBASMFLAGS += -D _CRYSTAL11 -D _CRYSTAL_AU +rgbdscheck.o: rgbdscheck.asm + $(RGMASM) -o $@ $< + # The dep rules have to be explicit or else missing files won't be reported. # As a side effect, they're evaluated immediately instead of when the rule is invoked. # It doesn't look like $(shell) can be deferred so there might not be a better way. define DEP -$1: $2 $$(shell tools/scan_includes $2) +$1: $2 $$(shell tools/scan_includes $2) | rgbdscheck.o $$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$< endef diff --git a/constants.asm b/constants.asm index 758b3abcc..7864ec9d0 100644 --- a/constants.asm +++ b/constants.asm @@ -1,7 +1,3 @@ -if __RGBDS_MAJOR__ <= 0 && __RGBDS_MINOR__ < 4 - fail "pokecrystal requires rgbds 0.4.0 or newer." -endc - INCLUDE "charmap.asm" INCLUDE "macros.asm" diff --git a/rgbdscheck.asm b/rgbdscheck.asm new file mode 100644 index 000000000..d5e2e5011 --- /dev/null +++ b/rgbdscheck.asm @@ -0,0 +1,12 @@ +; pokecrystal requires rgbds 0.4.0 or newer. +MAJOR EQU 0 +MINOR EQU 4 +PATCH EQU 0 + +if !DEF(__RGBDS_MAJOR__) || !DEF(__RGBDS_MINOR__) || !DEF(__RGBDS_PATCH__) + fail "pokecrystal requires rgbds {MAJOR}.{MINOR}.{PATCH} or newer." +elif (__RGBDS_MAJOR__ < MAJOR) || \ + (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ < MINOR) || \ + (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ < PATCH) + fail "pokecrystal requires rgbds {MAJOR}.{MINOR}.{PATCH} or newer." +endc