From 0dd3ef7f50dd2227bddddef7cd621ef595db0d40 Mon Sep 17 00:00:00 2001 From: Chasarr <34444482+Chasarr@users.noreply.github.com> Date: Sat, 1 Oct 2022 00:54:07 +0200 Subject: [PATCH] Fix CROSS variable on multiple environments (#483) The name of the compiler that CROSS is set to varies from system to system. (gcc-mips-linux-gnu on Debian) This was not handled in s2d_engine and calc_bss.sh --- Makefile | 24 +++++++++++++----------- src/s2d_engine/Makefile | 1 - tools/calc_bss.sh | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index f109c6ac..6c6e4e33 100644 --- a/Makefile +++ b/Makefile @@ -119,20 +119,10 @@ else ifeq ($(GRUCODE),super3d) # Super3D DEFINES += SUPER3D_GBI=1 F3D_NEW=1 endif -LIBRARIES := nustd hvqm2 z goddard - # TEXT ENGINES # s2dex_text_engine - Text Engine by someone2639 TEXT_ENGINE := none -ifeq ($(TEXT_ENGINE), s2dex_text_engine) - DEFINES += S2DEX_GBI_2=1 S2DEX_TEXT_ENGINE=1 - LIBRARIES += s2d_engine - DUMMY != make -C src/s2d_engine COPY_DIR=$(shell pwd)/lib/ -endif -# add more text engines here - -LINK_LIBRARIES = $(foreach i,$(LIBRARIES),-l$(i)) - +$(eval $(call validate-option,TEXT_ENGINE,none s2dex_text_engine)) #==============================================================================# # Optimization flags # @@ -417,6 +407,18 @@ else $(error Unable to detect a suitable MIPS toolchain installed) endif +LIBRARIES := nustd hvqm2 z goddard + +# Text engine +ifeq ($(TEXT_ENGINE), s2dex_text_engine) + DEFINES += S2DEX_GBI_2=1 S2DEX_TEXT_ENGINE=1 + LIBRARIES += s2d_engine + DUMMY != $(MAKE) -C src/s2d_engine COPY_DIR=$(shell pwd)/lib/ CROSS=$(CROSS) +endif +# add more text engines here + +LINK_LIBRARIES = $(foreach i,$(LIBRARIES),-l$(i)) + export LD_LIBRARY_PATH=./tools AS := $(CROSS)as diff --git a/src/s2d_engine/Makefile b/src/s2d_engine/Makefile index 8531bc83..427d8848 100644 --- a/src/s2d_engine/Makefile +++ b/src/s2d_engine/Makefile @@ -10,7 +10,6 @@ DUMMY != mkdir -p $(BUILD_DIR) C_FILES = $(wildcard ./*.c) O_FILES = $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) -CROSS := mips-linux-gnu- CC = $(CROSS)gcc AR = $(CROSS)ar diff --git a/tools/calc_bss.sh b/tools/calc_bss.sh index e7369d87..a8a417a3 100755 --- a/tools/calc_bss.sh +++ b/tools/calc_bss.sh @@ -18,8 +18,24 @@ if [ -z "$QEMU_IRIX" ]; then exit 1 fi +# detect prefix for MIPS toolchain unless CROSS is already defined if [ -z "$CROSS" ]; then + if command -v mips64-elf-ld &> /dev/null ; then + CROSS=mips64-elf- + elif command -v mips-n64-ld &> /dev/null ; then + CROSS=mips-n64- + elif command -v mips64-ld &> /dev/null ; then + CROSS=mips64- + elif command -v mips-linux-gnu-ld &> /dev/null ; then CROSS=mips-linux-gnu- + elif command -v mips64-linux-gnu-ld &> /dev/null ; then + CROSS=mips64-linux-gnu- + elif command -v mips-ld &> /dev/null ; then + CROSS=mips- + else + echo "Unable to detect a suitable MIPS toolchain installed" + exit 1 + fi fi # bss indexing starts at 3