mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 14:34:32 +00:00
GCC support.
This commit is contained in:
parent
4390dd74b6
commit
45ccb7fd05
7 changed files with 237 additions and 14 deletions
62
Makefile
62
Makefile
|
@ -8,10 +8,23 @@ COMPARE ?= 1
|
|||
NON_MATCHING ?= 0
|
||||
# If ORIG_COMPILER is 1, compile with QEMU_IRIX and the original compiler
|
||||
ORIG_COMPILER ?= 0
|
||||
# If COMPILER is GCC, compile with GCC instead of IDO.
|
||||
COMPILER ?= ido
|
||||
# Convert text in source files (.c) to EUC-JP before compilation, but only on GCC.
|
||||
# This is required in order to preserve debug print functionality on GCC since it
|
||||
# doesn't seem to recognize EUC-JP marked files without doing this beforehand.
|
||||
CONV_SOURCE_TEXT ?= 1
|
||||
|
||||
# If gcc is used, define the NON_MATCHING flag respectively so the files that
|
||||
# are safe to be used can avoid using GLOBAL_ASM which doesn't work with gcc.
|
||||
ifeq ($(COMPILER),gcc)
|
||||
NON_MATCHING := 1
|
||||
CPPFLAGS := -DCOMPILER_GCC
|
||||
endif
|
||||
|
||||
ifeq ($(NON_MATCHING),1)
|
||||
CFLAGS := -DNON_MATCHING
|
||||
CPPFLAGS := -DNON_MATCHING
|
||||
CFLAGS += -DNON_MATCHING
|
||||
CPPFLAGS += -DNON_MATCHING
|
||||
COMPARE := 0
|
||||
endif
|
||||
|
||||
|
@ -41,8 +54,22 @@ else
|
|||
$(error Please install or build mips-linux-gnu)
|
||||
endif
|
||||
|
||||
CC := tools/ido_recomp/$(DETECTED_OS)/7.1/cc
|
||||
CC_OLD := tools/ido_recomp/$(DETECTED_OS)/5.3/cc
|
||||
# Detect compiler and set variables appropriately.
|
||||
ifeq ($(COMPILER),gcc)
|
||||
ifeq ($(CONV_SOURCE_TEXT),1)
|
||||
CC = iconv -f UTF-8 -t EUC-JP $< | mips-linux-gnu-gcc -x c -
|
||||
else
|
||||
CC = mips-linux-gnu-gcc $<
|
||||
endif
|
||||
CC_OLD := $(CC)
|
||||
else
|
||||
ifeq ($(COMPILER),ido)
|
||||
CC := tools/ido_recomp/$(DETECTED_OS)/7.1/cc
|
||||
CC_OLD := tools/ido_recomp/$(DETECTED_OS)/5.3/cc
|
||||
else
|
||||
$(error Unsupported compiler. Please use either ido or gcc as the COMPILER variable.)
|
||||
endif
|
||||
endif
|
||||
|
||||
# if ORIG_COMPILER is 1, check that either QEMU_IRIX is set or qemu-irix package installed
|
||||
ifeq ($(ORIG_COMPILER),1)
|
||||
|
@ -77,10 +104,17 @@ ZAPD := tools/ZAPD/ZAPD.out
|
|||
|
||||
OPTFLAGS := -O2
|
||||
ASFLAGS := -march=vr4300 -32 -Iinclude
|
||||
MIPS_VERSION := -mips2
|
||||
|
||||
# we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff.
|
||||
CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(INC) -Wab,-r4300_mul -woff 649,838,712
|
||||
ifeq ($(COMPILER),gcc)
|
||||
CFLAGS += -c -G 0 -nostdinc -Iinclude -Isrc -Iassets -Ibuild -I. -DNON_MATCHING=1 -DMODDING=1 -DNORMAL_GAMEPLAY=1 -DAVOID_UB=1 -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -mno-abicalls -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv $(CHECK_WARNINGS) -g -mno-explicit-relocs -mno-split-addresses -funsigned-char
|
||||
MIPS_VERSION := -mips3
|
||||
PIPEIN =
|
||||
else
|
||||
# we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff.
|
||||
CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(INC) -Wab,-r4300_mul -woff 649,838,712
|
||||
MIPS_VERSION := -mips2
|
||||
PIPEIN = $<
|
||||
endif
|
||||
|
||||
ifeq ($(shell getconf LONG_BIT), 32)
|
||||
# Work around memory allocation bug in QEMU
|
||||
|
@ -126,6 +160,7 @@ TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \
|
|||
# create build directories
|
||||
$(shell mkdir -p build/baserom build/assets/text $(foreach dir,$(SRC_DIRS) $(ASM_DIRS) $(ASSET_BIN_DIRS),build/$(dir)))
|
||||
|
||||
ifeq ($(COMPILER),ido)
|
||||
build/src/code/fault.o: CFLAGS += -trapuv
|
||||
build/src/code/fault.o: OPTFLAGS := -O2 -g3
|
||||
build/src/code/fault_drawer.o: CFLAGS += -trapuv
|
||||
|
@ -162,6 +197,7 @@ build/src/code/%.o: CC := python3 tools/asm_processor/build.py $(CC) -- $(AS) $(
|
|||
build/src/overlays/%.o: CC := python3 tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
|
||||
|
||||
build/assets/%.o: CC := python3 tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
|
||||
endif
|
||||
|
||||
#### Main Targets ###
|
||||
|
||||
|
@ -231,7 +267,7 @@ build/assets/text/nes_message_data_static.o: build/assets/text/message_data.enc.
|
|||
build/assets/text/staff_message_data_static.o: build/assets/text/message_data_staff.enc.h
|
||||
|
||||
build/assets/%.o: assets/%.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
$(CC) -c $(CFLAGS) -I $(<D) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $(PIPEIN)
|
||||
$(OBJCOPY) -O binary $@ $@.bin
|
||||
|
||||
build/dmadata_table_spec.h: build/$(SPEC)
|
||||
|
@ -241,25 +277,25 @@ build/src/boot/z_std_dma.o: build/dmadata_table_spec.h
|
|||
build/src/dmadata/dmadata.o: build/dmadata_table_spec.h
|
||||
|
||||
build/src/overlays/%.o: src/overlays/%.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
$(CC) -c $(CFLAGS) -I $(<D) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $(PIPEIN)
|
||||
$(CC_CHECK) $<
|
||||
$(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s
|
||||
$(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s --gcc-compat
|
||||
-test -f $(@D)/$(notdir $(@D))_reloc.s && $(AS) $(ASFLAGS) $(@D)/$(notdir $(@D))_reloc.s -o $(@D)/$(notdir $(@D))_reloc.o
|
||||
@$(OBJDUMP) -d $@ > $(@:.o=.s)
|
||||
|
||||
build/src/%.o: src/%.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
$(CC) -c $(CFLAGS) -I $(<D) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $(PIPEIN)
|
||||
$(CC_CHECK) $<
|
||||
@$(OBJDUMP) -d $@ > $(@:.o=.s)
|
||||
|
||||
build/src/libultra/libc/ll.o: src/libultra/libc/ll.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
$(CC) -c $(CFLAGS) -I $(<D) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $(PIPEIN)
|
||||
$(CC_CHECK) $<
|
||||
python3 tools/set_o32abi_bit.py $@
|
||||
@$(OBJDUMP) -d $@ > $(@:.o=.s)
|
||||
|
||||
build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
$(CC) -c $(CFLAGS) -I $(<D) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $(PIPEIN)
|
||||
$(CC_CHECK) $<
|
||||
python3 tools/set_o32abi_bit.py $@
|
||||
@$(OBJDUMP) -d $@ > $(@:.o=.s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue