1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-05-13 04:24:14 +00:00

Run CC_CHECK with the correct CPP defines (#1963)

* Run CC_CHECK with the correct CPP defines

* Add "CPP_DEFINES ?="
This commit is contained in:
cadmic 2024-06-20 15:26:01 -07:00 committed by GitHub
parent adcc1cecb1
commit 8b6a6e6778
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,6 +27,7 @@ RUN_CC_CHECK := 1
CFLAGS ?= CFLAGS ?=
CPPFLAGS ?= CPPFLAGS ?=
CPP_DEFINES ?=
# ORIG_COMPILER cannot be combined with a non-IDO compiler. Check for this case and error out if found. # ORIG_COMPILER cannot be combined with a non-IDO compiler. Check for this case and error out if found.
ifneq ($(COMPILER),ido) ifneq ($(COMPILER),ido)
@ -36,8 +37,7 @@ ifneq ($(COMPILER),ido)
endif endif
ifeq ($(COMPILER),gcc) ifeq ($(COMPILER),gcc)
CFLAGS += -DCOMPILER_GCC CPP_DEFINES += -DCOMPILER_GCC
CPPFLAGS += -DCOMPILER_GCC
NON_MATCHING := 1 NON_MATCHING := 1
endif endif
@ -46,8 +46,7 @@ endif
MIPS_BINUTILS_PREFIX := mips-linux-gnu- MIPS_BINUTILS_PREFIX := mips-linux-gnu-
ifeq ($(NON_MATCHING),1) ifeq ($(NON_MATCHING),1)
CFLAGS += -DNON_MATCHING -DAVOID_UB CPP_DEFINES += -DNON_MATCHING -DAVOID_UB
CPPFLAGS += -DNON_MATCHING -DAVOID_UB
COMPARE := 0 COMPARE := 0
endif endif
@ -57,12 +56,10 @@ ifeq ($(VERSION),gc-eu)
COMPARE := 0 COMPARE := 0
else ifeq ($(VERSION),gc-eu-mq) else ifeq ($(VERSION),gc-eu-mq)
DEBUG := 0 DEBUG := 0
CFLAGS += -DOOT_MQ CPP_DEFINES += -DOOT_MQ
CPPFLAGS += -DOOT_MQ
else ifeq ($(VERSION),gc-eu-mq-dbg) else ifeq ($(VERSION),gc-eu-mq-dbg)
DEBUG := 1 DEBUG := 1
CFLAGS += -DOOT_MQ CPP_DEFINES += -DOOT_MQ
CPPFLAGS += -DOOT_MQ
else else
$(error Unsupported version $(VERSION)) $(error Unsupported version $(VERSION))
endif endif
@ -78,12 +75,10 @@ MAKE = make
CPPFLAGS += -P -xc -fno-dollars-in-identifiers CPPFLAGS += -P -xc -fno-dollars-in-identifiers
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
CFLAGS += -DOOT_DEBUG=1 CPP_DEFINES += -DOOT_DEBUG=1
CPPFLAGS += -DOOT_DEBUG=1
OPTFLAGS := -O2 OPTFLAGS := -O2
else else
CFLAGS += -DNDEBUG -DOOT_DEBUG=0 CPP_DEFINES += -DNDEBUG -DOOT_DEBUG=0
CPPFLAGS += -DNDEBUG -DOOT_DEBUG=0
OPTFLAGS := -O2 -g3 OPTFLAGS := -O2 -g3
endif endif
@ -154,6 +149,9 @@ PYTHON ?= $(VENV)/bin/python3
# preprocessor for this because it won't substitute inside string literals. # preprocessor for this because it won't substitute inside string literals.
SPEC_REPLACE_VARS := sed -e 's|$$(BUILD_DIR)|$(BUILD_DIR)|g' SPEC_REPLACE_VARS := sed -e 's|$$(BUILD_DIR)|$(BUILD_DIR)|g'
CFLAGS += $(CPP_DEFINES)
CPPFLAGS += $(CPP_DEFINES)
ifeq ($(COMPILER),gcc) ifeq ($(COMPILER),gcc)
OPTFLAGS := -Os -ffast-math -fno-unsafe-math-optimizations OPTFLAGS := -Os -ffast-math -fno-unsafe-math-optimizations
endif endif
@ -174,7 +172,7 @@ endif
ifeq ($(COMPILER),ido) ifeq ($(COMPILER),ido)
# Have CC_CHECK pretend to be a MIPS compiler # Have CC_CHECK pretend to be a MIPS compiler
MIPS_BUILTIN_DEFS := -D_MIPS_ISA_MIPS2=2 -D_MIPS_ISA=_MIPS_ISA_MIPS2 -D_ABIO32=1 -D_MIPS_SIM=_ABIO32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32 MIPS_BUILTIN_DEFS := -D_MIPS_ISA_MIPS2=2 -D_MIPS_ISA=_MIPS_ISA_MIPS2 -D_ABIO32=1 -D_MIPS_SIM=_ABIO32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32
CC_CHECK = gcc -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D_LANGUAGE_C -DNON_MATCHING -DOOT_DEBUG=1 $(MIPS_BUILTIN_DEFS) $(INC) $(CHECK_WARNINGS) CC_CHECK = gcc -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D_LANGUAGE_C $(CPP_DEFINES) $(MIPS_BUILTIN_DEFS) $(INC) $(CHECK_WARNINGS)
ifeq ($(shell getconf LONG_BIT), 32) ifeq ($(shell getconf LONG_BIT), 32)
# Work around memory allocation bug in QEMU # Work around memory allocation bug in QEMU
export QEMU_GUEST_BASE := 1 export QEMU_GUEST_BASE := 1