2023-10-03 06:59:01 +00:00
# Build options can be changed by modifying the makefile or by building with 'make SETTING=value'.
# It is also possible to override the settings in Defaults in a file called .make_options as 'SETTING=value'.
- i n c l u d e . m a k e _ o p t i o n s
2023-10-15 22:14:57 +00:00
MAKEFLAGS += --no-builtin-rules --no-print-directory
2023-10-03 06:59:01 +00:00
2023-12-26 20:55:57 +00:00
# Returns the path to the command $(1) if exists. Otherwise returns an empty string.
find-command = $( shell which $( 1) 2>/dev/null)
2023-10-03 06:59:01 +00:00
#### Defaults ####
# If COMPARE is 1, check the output md5sum after building
COMPARE ?= 1
# If NON_MATCHING is 1, define the NON_MATCHING C flag when building
NON_MATCHING ?= 0
# if WERROR is 1, pass -Werror to CC_CHECK, so warnings would be treated as errors
WERROR ?= 0
# Keep .mdebug section in build
KEEP_MDEBUG ?= 0
# Check code syntax with host compiler
RUN_CC_CHECK ?= 1
CC_CHECK_COMP ?= gcc
# Dump build object files
OBJDUMP_BUILD ?= 0
# Number of threads to compress with
N_THREADS ?= $( shell nproc)
2024-04-15 23:15:45 +00:00
# If COMPILER is GCC, compile with GCC instead of IDO.
COMPILER ?= ido
2023-12-04 21:36:31 +00:00
# Whether to colorize build messages
COLOR ?= 1
# Whether to hide commands or not
VERBOSE ?= 0
# Command for printing messages during the make.
PRINT ?= printf
2023-10-03 06:59:01 +00:00
# Set prefix to mips binutils binaries (mips-linux-gnu-ld => 'mips-linux-gnu-') - Change at your own risk!
2023-12-26 20:55:57 +00:00
# Auto-detect prefix for MIPS toolchain
i f n e q ( $( call find -command ,mips -linux -gnu -ld ) , )
MIPS_BINUTILS_PREFIX := mips-linux-gnu-
e l s e i f n e q ( $( call find -command ,mips 64-linux -gnu -ld ) , )
MIPS_BINUTILS_PREFIX := mips64-linux-gnu-
e l s e i f n e q ( $( call find -command ,mips 64-elf -ld ) , )
MIPS_BINUTILS_PREFIX := mips64-elf-
e l s e
$( error Unable to detect a suitable MIPS toolchain installed)
e n d i f
2023-10-03 06:59:01 +00:00
2023-10-03 05:57:03 +00:00
VERSION ?= us
2024-05-12 00:11:29 +00:00
REV ?= rev1
2023-10-03 05:57:03 +00:00
2024-05-12 00:11:29 +00:00
BASEROM := baserom.$( VERSION) .$( REV) .z64
BASEROM_UNCOMPRESSED := baserom.$( VERSION) .$( REV) .uncompressed.z64
2023-10-03 05:57:03 +00:00
TARGET := starfox64
2023-10-03 06:59:01 +00:00
### Output ###
BUILD_DIR := build
2023-10-16 09:17:33 +00:00
TOOLS := tools
PYTHON := python3
2024-05-12 00:11:29 +00:00
ROM := $( BUILD_DIR) /$( TARGET) .$( VERSION) .$( REV) .uncompressed.z64
ROMC := $( BUILD_DIR) /$( TARGET) .$( VERSION) .$( REV) .z64
ELF := $( BUILD_DIR) /$( TARGET) .$( VERSION) .$( REV) .elf
LD_MAP := $( BUILD_DIR) /$( TARGET) .$( VERSION) .$( REV) .map
LD_SCRIPT := linker_scripts/$( VERSION) /$( REV) /$( TARGET) .ld
2023-10-03 06:59:01 +00:00
#### Setup ####
2024-04-15 23:15:45 +00:00
# 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.
i f e q ( $( COMPILER ) , g c c )
$( warning WARNING: GCC support is experimental. Use at your own risk.)
CFLAGS += -DCOMPILER_GCC
NON_MATCHING := 1
e n d i f
# Detect compiler and set variables appropriately.
i f e q ( $( COMPILER ) , g c c )
CC := $( MIPS_BINUTILS_PREFIX) gcc
e l s e
i f e q ( $( COMPILER ) , i d o )
2024-05-14 18:06:35 +00:00
CC := $( TOOLS) /ido_recomp/$( DETECTED_OS) /7.1/cc
CC_OLD := $( TOOLS) /ido_recomp/$( DETECTED_OS) /5.3/cc
2024-04-15 23:15:45 +00:00
e l s e
$( error Unsupported compiler . Please use either ido or gcc as the COMPILER variable .)
e n d i f
e n d i f
i f e q ( $( COMPILER ) , g c c )
2024-04-21 21:31:57 +00:00
OPTFLAGS := -Os
2024-04-15 23:15:45 +00:00
e l s e
OPTFLAGS := -O2 -g3
e n d i f
i f e q ( $( COMPILER ) , g c c )
CFLAGS += -G 0 -ffast-math -fno-unsafe-math-optimizations -march= vr4300 -mfix4300 -mabi= 32 -mno-abicalls -mdivide-breaks -fno-zero-initialized-in-bss -fno-toplevel-reorder -ffreestanding -fno-common -fno-merge-constants -mno-explicit-relocs -mno-split-addresses $( CHECK_WARNINGS) -funsigned-char
MIPS_VERSION := -mips3
e l s e
# 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 -fullwarn -verbose -Xcpluscomm $( IINC) -nostdinc -Wab,-r4300_mul -woff 649,838,712,516
MIPS_VERSION := -mips2
2024-08-12 14:58:54 +00:00
WARNINGS := -fullwarn -verbose -woff 624,649,838,712,516,513,596,564,594,709,807
2024-04-15 23:15:45 +00:00
e n d i f
i f e q ( $( COMPILER ) , i d o )
# 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
CC_CHECK = gcc -fno-builtin -fsyntax-only -funsigned-char -std= gnu90 -D_LANGUAGE_C -DNON_MATCHING $( MIPS_BUILTIN_DEFS) $( IINC) $( CHECK_WARNINGS)
ifeq ( $( shell getconf LONG_BIT) , 32)
# Work around memory allocation bug in QEMU
export QEMU_GUEST_BASE := 1
else
# Ensure that gcc (warning check) treats the code as 32-bit
CC_CHECK += -m32
endif
e l s e
CC_CHECK = @:
e n d i f
2023-10-03 06:59:01 +00:00
BUILD_DEFINES ?=
2024-05-15 01:29:21 +00:00
# Version check
i f e q ( $( VERSION ) , j p )
BUILD_DEFINES += -DVERSION_JP= 1
e n d i f
2023-10-03 06:59:01 +00:00
i f e q ( $( VERSION ) , u s )
BUILD_DEFINES += -DVERSION_US= 1
2024-05-12 04:07:54 +00:00
e n d i f
2024-05-15 01:29:21 +00:00
i f e q ( $( VERSION ) , e u )
BUILD_DEFINES += -DVERSION_EU= 1
2024-05-15 16:39:32 +00:00
REV := rev0
e n d i f
i f e q ( $( VERSION ) , a u )
BUILD_DEFINES += -DVERSION_AU= 1
REV := rev0
e n d i f
i f e q ( $( VERSION ) , l n )
BUILD_DEFINES += -DVERSION_LN= 1
REV := rev0
2023-10-03 06:59:01 +00:00
e n d i f
i f e q ( $( NON_MATCHING ) , 1 )
BUILD_DEFINES += -DNON_MATCHING -DAVOID_UB
2024-04-15 23:15:45 +00:00
CPPFLAGS += -DNON_MATCHING -DAVOID_UB
2023-10-03 06:59:01 +00:00
e n d i f
MAKE = make
CPPFLAGS += -fno-dollars-in-identifiers -P
LDFLAGS := --no-check-sections --accept-unknown-input-arch --emit-relocs
UNAME_S := $( shell uname -s)
2023-12-04 21:36:31 +00:00
UNAME_M := $( shell uname -m)
2023-10-03 06:59:01 +00:00
i f e q ( $( OS ) , W i n d o w s _ N T )
$(error Native Windows is currently unsupported for building this repository, use WSL instead c : )
e l s e i f e q ( $( UNAME_S ) , L i n u x )
DETECTED_OS := linux
2023-12-04 21:36:31 +00:00
#Detect aarch64 devices (Like Raspberry Pi OS 64-bit)
#If it's found, then change the compiler to a version that can compile in 32 bit mode.
ifeq ( $( UNAME_M) ,aarch64)
CC_CHECK_COMP := arm-linux-gnueabihf-gcc
endif
2023-10-03 06:59:01 +00:00
e l s e i f e q ( $( UNAME_S ) , D a r w i n )
2023-12-26 20:55:57 +00:00
DETECTED_OS := macos
2023-10-03 06:59:01 +00:00
MAKE := gmake
CPPFLAGS += -xc++
2024-06-16 02:49:48 +00:00
CC_CHECK_COMP := clang
2023-10-03 06:59:01 +00:00
e n d i f
2023-12-04 21:36:31 +00:00
# Support python venv's if one is installed.
PYTHON_VENV = .venv/bin/python3
i f n e q "$(wildcard $(PYTHON_VENV) )" ""
PYTHON = $( PYTHON_VENV)
e n d i f
i f e q ( $( VERBOSE ) , 0 )
V := @
e n d i f
i f e q ( $( COLOR ) , 1 )
NO_COL := \0 33[ 0m
RED := \0 33[ 0; 31m
GREEN := \0 33[ 0; 32m
BLUE := \0 33[ 0; 34m
YELLOW := \0 33[ 0; 33m
BLINK := \0 33[ 33; 5m
e n d i f
# Common build print status function
d e f i n e p r i n t
@$( PRINT) " $( GREEN) $( 1) $( YELLOW) $( 2) $( GREEN) -> $( BLUE) $( 3) $( NO_COL) \n "
e n d e f
2023-10-03 06:59:01 +00:00
#### Tools ####
i f n e q ( $( shell type $ ( MIPS_BINUTILS_PREFIX ) ld >/dev /null 2>/dev /null ; echo $ $ ?) , 0 )
$( error Unable to find $ ( MIPS_BINUTILS_PREFIX ) ld . Please install or build MIPS binutils , commonly mips -linux -gnu . ( or set MIPS_BINUTILS_PREFIX if your MIPS binutils install uses another prefix ) )
e n d i f
### Compiler ###
2023-12-04 21:36:31 +00:00
IDO := $( TOOLS) /ido-recomp/$( DETECTED_OS) /cc
2023-10-03 06:59:01 +00:00
AS := $( MIPS_BINUTILS_PREFIX) as
LD := $( MIPS_BINUTILS_PREFIX) ld
OBJCOPY := $( MIPS_BINUTILS_PREFIX) objcopy
OBJDUMP := $( MIPS_BINUTILS_PREFIX) objdump
ICONV := iconv
2023-10-16 09:17:33 +00:00
ASM_PROC := $( PYTHON) $( TOOLS) /asm-processor/build.py
2023-10-03 06:59:01 +00:00
CAT := cat
2024-05-14 18:06:35 +00:00
TORCH := $( TOOLS) /Torch/cmake-build-release/torch
2023-10-03 06:59:01 +00:00
2023-12-26 20:55:57 +00:00
# Prefer clang as C preprocessor if installed on the system
i f n e q ( , $( call find -command ,clang ) )
CPP := clang
2024-04-05 20:11:36 +00:00
CPPFLAGS := -E -P -x c -Wno-trigraphs -Wmissing-prototypes -Wstrict-prototypes -D_LANGUAGE_ASSEMBLY
2023-12-26 20:55:57 +00:00
e l s e
CPP := cpp
2024-04-05 20:11:36 +00:00
CPPFLAGS := -P -Wno-trigraphs -Wmissing-prototypes -Wstrict-prototypes -D_LANGUAGE_ASSEMBLY
2023-12-26 20:55:57 +00:00
e n d i f
2023-10-03 06:59:01 +00:00
ASM_PROC_FLAGS := --input-enc= utf-8 --output-enc= euc-jp --convert-statics= global-with-filename
2023-12-04 21:36:31 +00:00
SPLAT ?= $( PYTHON) $( TOOLS) /splat/split.py
2024-05-12 00:11:29 +00:00
SPLAT_YAML ?= $( TARGET) .$( VERSION) .$( REV) .yaml
2023-10-03 05:57:03 +00:00
2023-10-16 09:17:33 +00:00
COMPTOOL := $( TOOLS) /comptool.py
2023-10-16 13:54:41 +00:00
COMPTOOL_DIR := baserom
MIO0 := $( TOOLS) /mio0
2023-10-03 05:57:03 +00:00
2024-05-12 00:11:29 +00:00
IINC := -Iinclude -Ibin/$( VERSION) .$( REV) -I.
2023-10-03 06:59:01 +00:00
IINC += -Ilib/ultralib/include -Ilib/ultralib/include/PR -Ilib/ultralib/include/ido
i f e q ( $( KEEP_MDEBUG ) , 0 )
RM_MDEBUG = $( OBJCOPY) --remove-section .mdebug $@
e l s e
RM_MDEBUG = @:
e n d i f
# Check code syntax with host compiler
CHECK_WARNINGS := -Wall -Wextra -Wimplicit-fallthrough -Wno-unknown-pragmas -Wno-missing-braces -Wno-sign-compare -Wno-uninitialized
# Have CC_CHECK pretend to be a MIPS compiler
MIPS_BUILTIN_DEFS := -DMIPSEB -D_MIPS_FPSET= 16 -D_MIPS_ISA= 2 -D_ABIO32= 1 -D_MIPS_SIM= _ABIO32 -D_MIPS_SZINT= 32 -D_MIPS_SZPTR= 32
i f n e q ( $( RUN_CC_CHECK ) , 0 )
# The -MMD flags additionaly creates a .d file with the same name as the .o file.
2023-12-08 21:58:37 +00:00
CHECK_WARNINGS := -Wno-unused-variable -Wno-int-conversion
2023-10-03 06:59:01 +00:00
CC_CHECK := $( CC_CHECK_COMP)
2023-12-04 21:36:31 +00:00
CC_CHECK_FLAGS := -MMD -MP -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std= gnu89 -DNON_MATCHING -DAVOID_UB -DCC_CHECK= 1
# Ensure that gcc treats the code as 32-bit
ifeq ( $( UNAME_M) ,aarch64)
CC_CHECK_FLAGS += -march= armv7-a+fp
else
CC_CHECK_FLAGS += -m32
endif
ifneq ( $( WERROR) , 0)
2023-10-03 06:59:01 +00:00
CHECK_WARNINGS += -Werror
endif
e l s e
CC_CHECK := @:
e n d i f
ASFLAGS := -march= vr4300 -32 -G0
COMMON_DEFINES := -D_MIPS_SZLONG= 32
GBI_DEFINES := -DF3DEX_GBI
Match Libultra (#120)
* Matched perspective, contquery, contreaddata, recvmesg and sendmesg
* Fixed libultra compilation flags
* Matched viblack
* Matched virepeatline, visetmode, visetspecial and viswapbuf
* Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread
* Fixed bss bs
* Matched even more libultra stuff
* Matched even more
* __osRdbSend
* Decompiled most of the functions of libultra <3
* Matched last functions
* Added a separation to libultra macros
* Removed ARRLEN from controller.h
* Fix libultra warnings
---------
Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
2024-02-14 15:24:31 +00:00
RELEASE_DEFINES := -DNDEBUG
2023-10-03 06:59:01 +00:00
AS_DEFINES := -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64
Match Libultra (#120)
* Matched perspective, contquery, contreaddata, recvmesg and sendmesg
* Fixed libultra compilation flags
* Matched viblack
* Matched virepeatline, visetmode, visetspecial and viswapbuf
* Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread
* Fixed bss bs
* Matched even more libultra stuff
* Matched even more
* __osRdbSend
* Decompiled most of the functions of libultra <3
* Matched last functions
* Added a separation to libultra macros
* Removed ARRLEN from controller.h
* Fix libultra warnings
---------
Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
2024-02-14 15:24:31 +00:00
C_DEFINES := -DLANGUAGE_C -D_LANGUAGE_C -DBUILD_VERSION= VERSION_H ${ RELEASE_DEFINES }
2023-10-03 06:59:01 +00:00
ENDIAN := -EB
ICONV_FLAGS := --from-code= UTF-8 --to-code= EUC-JP
# Use relocations and abi fpr names in the dump
OBJDUMP_FLAGS := --disassemble --reloc --disassemble-zeroes -Mreg-names= 32 -Mno-aliases
i f n e q ( $( OBJDUMP_BUILD ) , 0 )
OBJDUMP_CMD = $( OBJDUMP) $( OBJDUMP_FLAGS) $@ > $( @:.o= .dump.s)
OBJCOPY_BIN = $( OBJCOPY) -O binary $@ $@ .bin
e l s e
OBJDUMP_CMD = @:
OBJCOPY_BIN = @:
e n d i f
# rom compression flags
COMPFLAGS := --threads $( N_THREADS)
i f e q ( $( NON_MATCHING ) , 0 )
COMPFLAGS += --matching
e n d i f
#### Files ####
2024-05-12 00:11:29 +00:00
$( shell mkdir -p asm bin linker_scripts /$ ( VERSION ) /$ ( REV ) /auto )
2023-10-03 06:59:01 +00:00
SRC_DIRS := $( shell find src -type d)
2024-05-14 13:59:18 +00:00
# Temporary, until we decide how we're gonna handle other versions
2024-05-16 14:08:02 +00:00
i f e q ( $( VERSION ) , j p )
2024-05-14 13:59:18 +00:00
SRC_DIRS := $( shell find srcjp -type d)
e n d i f
2024-05-18 22:49:49 +00:00
i f e q ( $( VERSION ) , e u )
SRC_DIRS := $( shell find srceu -type d)
e n d i f
2024-05-12 00:11:29 +00:00
ASM_DIRS := $( shell find asm/$( VERSION) /$( REV) -type d -not -path " asm/ $( VERSION) / $( REV) /nonmatchings/* " )
2023-10-03 06:59:01 +00:00
BIN_DIRS := $( shell find bin -type d)
2024-05-14 13:59:18 +00:00
2023-10-03 06:59:01 +00:00
C_FILES := $( foreach dir,$( SRC_DIRS) ,$( wildcard $( dir) /*.c) )
2024-02-18 02:19:18 +00:00
C_FILES := $( filter-out %.inc.c,$( C_FILES) )
2023-10-03 06:59:01 +00:00
S_FILES := $( foreach dir,$( ASM_DIRS) $( SRC_DIRS) ,$( wildcard $( dir) /*.s) )
BIN_FILES := $( foreach dir,$( BIN_DIRS) ,$( wildcard $( dir) /*.bin) )
O_FILES := $( foreach f,$( C_FILES:.c= .o) ,$( BUILD_DIR) /$f ) \
$( foreach f,$( S_FILES:.s= .o) ,$( BUILD_DIR) /$f ) \
$( foreach f,$( BIN_FILES:.bin= .o) ,$( BUILD_DIR) /$f )
# Automatic dependency files
DEP_FILES := $( O_FILES:.o= .d) \
$( O_FILES:.o= .asmproc.d)
# create build directories
2024-05-12 00:11:29 +00:00
$( shell mkdir -p $ ( BUILD_DIR ) /linker_scripts /$ ( VERSION ) /$ ( REV ) $ ( BUILD_DIR ) /linker_scripts /$ ( VERSION ) /$ ( REV ) /auto $ ( foreach dir ,$ ( SRC_DIRS ) $ ( ASM_DIRS ) $ ( BIN_DIRS ) ,$ ( BUILD_DIR ) /$ ( dir ) ) )
2023-10-03 06:59:01 +00:00
2024-04-15 23:15:45 +00:00
i f e q ( $( COMPILER ) , i d o )
2023-10-03 06:59:01 +00:00
2023-10-14 10:03:11 +00:00
# directory flags
2024-03-03 22:44:36 +00:00
build/src/libultra/gu/%.o : OPTFLAGS := -O 3 -g 0
build/src/libultra/io/%.o : OPTFLAGS := -O 1 -g 0
build/src/libultra/os/%.o : OPTFLAGS := -O 1 -g 0
build/src/libultra/rmon/%.o : OPTFLAGS := -O 1 -g 0
2024-04-03 14:30:50 +00:00
build/src/libultra/debug/%.o : OPTFLAGS := -O 1 -g 0
build/src/libultra/host/%.o : OPTFLAGS := -O 1 -g 0
build/src/audio/%.o : OPTFLAGS := -O 2 -g 0
2023-10-14 10:03:11 +00:00
# per-file flags
2024-05-14 14:44:12 +00:00
build/src/audio/audio_effects.o : CFLAGS += -use_readwrite_const
build/src/audio/audio_heap.o : CFLAGS += -use_readwrite_const
build/src/audio/audio_load.o : CFLAGS += -use_readwrite_const
build/src/audio/audio_seqplayer.o : CFLAGS += -use_readwrite_const
build/src/audio/audio_playback.o : CFLAGS += -use_readwrite_const
build/src/audio/audio_synthesis.o : CFLAGS += -use_readwrite_const
2024-04-03 14:30:50 +00:00
build/src/libc_sprintf.o : OPTFLAGS := -O 2 -g 0
build/src/libc_math64.o : OPTFLAGS := -O 2 -g 0
Match Libultra (#120)
* Matched perspective, contquery, contreaddata, recvmesg and sendmesg
* Fixed libultra compilation flags
* Matched viblack
* Matched virepeatline, visetmode, visetspecial and viswapbuf
* Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread
* Fixed bss bs
* Matched even more libultra stuff
* Matched even more
* __osRdbSend
* Decompiled most of the functions of libultra <3
* Matched last functions
* Added a separation to libultra macros
* Removed ARRLEN from controller.h
* Fix libultra warnings
---------
Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
2024-02-14 15:24:31 +00:00
2023-11-02 23:36:13 +00:00
build/src/libultra/libc/ldiv.o : OPTFLAGS := -O 2 -g 0
build/src/libultra/libc/string.o : OPTFLAGS := -O 2 -g 0
build/src/libultra/libc/xlitob.o : OPTFLAGS := -O 2 -g 0
Match Libultra (#120)
* Matched perspective, contquery, contreaddata, recvmesg and sendmesg
* Fixed libultra compilation flags
* Matched viblack
* Matched virepeatline, visetmode, visetspecial and viswapbuf
* Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread
* Fixed bss bs
* Matched even more libultra stuff
* Matched even more
* __osRdbSend
* Decompiled most of the functions of libultra <3
* Matched last functions
* Added a separation to libultra macros
* Removed ARRLEN from controller.h
* Fix libultra warnings
---------
Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
2024-02-14 15:24:31 +00:00
build/src/libultra/libc/xldtob.o : OPTFLAGS := -O 3 -g 0
build/src/libultra/libc/xprintf.o : OPTFLAGS := -O 3 -g 0
2023-10-17 21:50:39 +00:00
build/src/libultra/libc/ll.o : OPTFLAGS := -O 1 -g 0
build/src/libultra/libc/ll.o : MIPS_VERSION := -mips 3 -32
2023-10-29 21:19:30 +00:00
2023-10-03 06:59:01 +00:00
# cc & asm-processor
2023-10-17 20:43:47 +00:00
CC := $( ASM_PROC) $( ASM_PROC_FLAGS) $( IDO) -- $( AS) $( ASFLAGS) --
2023-11-02 23:36:13 +00:00
build/src/libultra/gu/sqrtf.o : CC := $( IDO )
Match Libultra (#120)
* Matched perspective, contquery, contreaddata, recvmesg and sendmesg
* Fixed libultra compilation flags
* Matched viblack
* Matched virepeatline, visetmode, visetspecial and viswapbuf
* Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread
* Fixed bss bs
* Matched even more libultra stuff
* Matched even more
* __osRdbSend
* Decompiled most of the functions of libultra <3
* Matched last functions
* Added a separation to libultra macros
* Removed ARRLEN from controller.h
* Fix libultra warnings
---------
Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
2024-02-14 15:24:31 +00:00
build/src/libultra/gu/sinf.o : CC := $( IDO )
2023-10-17 20:43:47 +00:00
build/src/libultra/gu/lookat.o : CC := $( IDO )
2023-10-17 21:11:17 +00:00
build/src/libultra/gu/ortho.o : CC := $( IDO )
2023-10-17 21:50:39 +00:00
build/src/libultra/libc/ll.o : CC := $( IDO )
Match Libultra (#120)
* Matched perspective, contquery, contreaddata, recvmesg and sendmesg
* Fixed libultra compilation flags
* Matched viblack
* Matched virepeatline, visetmode, visetspecial and viswapbuf
* Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread
* Fixed bss bs
* Matched even more libultra stuff
* Matched even more
* __osRdbSend
* Decompiled most of the functions of libultra <3
* Matched last functions
* Added a separation to libultra macros
* Removed ARRLEN from controller.h
* Fix libultra warnings
---------
Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
2024-02-14 15:24:31 +00:00
build/src/libultra/gu/perspective.o : CC := $( IDO )
build/src/libultra/gu/mtxutil.o : CC := $( IDO )
build/src/libultra/gu/cosf.o : CC := $( IDO )
build/src/libultra/libc/xprintf.o : CC := $( IDO )
build/src/libultra/libc/xldtob.o : CC := $( IDO )
2024-04-15 23:15:45 +00:00
e l s e
# directory flags
build/src/libultra/gu/%.o : OPTFLAGS := -Os
build/src/libultra/io/%.o : OPTFLAGS := -Os
build/src/libultra/os/%.o : OPTFLAGS := -Os
build/src/libultra/rmon/%.o : OPTFLAGS := -Os
build/src/libultra/debug/%.o : OPTFLAGS := -Os
build/src/libultra/host/%.o : OPTFLAGS := -Os
# per-file flags
2024-04-20 19:18:09 +00:00
build/src/audio/audio_load.o : OPTFLAGS := -Os
build/src/audio/audio_heap.o : OPTFLAGS := -Os
build/src/audio/audio_effects.o : OPTFLAGS := -Os
build/src/audio/audio_general.o : OPTFLAGS := -Os
build/src/audio/audio_playback.o : OPTFLAGS := -Os
build/src/audio/audio_seqplayer.o : OPTFLAGS := -Os
build/src/audio/audio_thread.o : OPTFLAGS := -Os
2024-04-21 21:31:57 +00:00
build/src/libc_sprintf.o : OPTFLAGS := -Os
build/src/libc_math64.o : OPTFLAGS := -Os
2023-10-17 21:50:39 +00:00
2024-04-15 23:15:45 +00:00
build/src/libultra/libc/ldiv.o : OPTFLAGS := -Os
build/src/libultra/libc/string.o : OPTFLAGS := -Os
build/src/libultra/libc/xlitob.o : OPTFLAGS := -Os
build/src/libultra/libc/xldtob.o : OPTFLAGS := -Os
build/src/libultra/libc/xprintf.o : OPTFLAGS := -Os
2024-04-15 23:55:24 +00:00
build/src/libultra/libc/ll.o : OPTFLAGS := -O 2
2024-04-15 23:15:45 +00:00
build/src/libultra/libc/ll.o : MIPS_VERSION := -mips 3
# cc & asm-processor
2024-04-21 21:31:57 +00:00
build/src/libultra/gu/sqrtf.o : OPTFLAGS := -Os
build/src/libultra/gu/sinf.o : OPTFLAGS := -Os
2024-04-15 23:15:45 +00:00
build/src/libultra/gu/lookat.o : OPTFLAGS := -Os
2024-04-20 19:18:09 +00:00
build/src/libultra/gu/ortho.o : OPTFLAGS := -Os
2024-04-15 23:15:45 +00:00
build/src/libultra/gu/perspective.o : OPTFLAGS := -Os
build/src/libultra/gu/mtxutil.o : OPTFLAGS := -Os
build/src/libultra/gu/cosf.o : OPTFLAGS := -Os
build/src/libultra/libc/xprintf.o : OPTFLAGS := -Os
build/src/libultra/libc/xldtob.o : OPTFLAGS := -Os
e n d i f
2023-10-03 06:59:01 +00:00
2023-10-16 09:04:16 +00:00
all : uncompressed
2023-10-03 06:59:01 +00:00
2023-12-10 19:27:26 +00:00
toolchain :
2024-05-14 18:06:35 +00:00
@$( MAKE) -s -C $( TOOLS)
2023-12-08 21:58:37 +00:00
2024-03-17 04:06:28 +00:00
torch :
2024-05-14 18:06:35 +00:00
@$( MAKE) -s -C $( TOOLS) torch
2024-04-25 04:14:49 +00:00
rm -f torch.hash.yml
2024-03-17 04:06:28 +00:00
2023-10-06 08:00:22 +00:00
init :
2023-10-16 15:33:45 +00:00
@$( MAKE) clean
@$( MAKE) decompress
@$( MAKE) extract -j $( N_THREADS)
2024-02-18 02:19:18 +00:00
@$( MAKE) assets -j $( N_THREADS)
2023-12-08 21:58:37 +00:00
@$( MAKE) uncompressed -j $( N_THREADS)
2023-10-16 15:33:45 +00:00
@$( MAKE) compressed
2023-10-06 08:00:22 +00:00
2023-12-04 21:36:31 +00:00
SF := ___ ___\n / __|| _| \n \_ _ \| _| \n | ___/| _| \n
2023-10-03 06:59:01 +00:00
uncompressed : $( ROM )
i f n e q ( $( COMPARE ) , 0 )
2023-12-26 20:55:57 +00:00
@echo " $( GREEN) Calculating Rom Header Checksum... $( YELLOW) $< $( NO_COL) "
2023-11-30 22:35:40 +00:00
@$( PYTHON) $( COMPTOOL) -r $( ROM) .
2024-05-12 00:11:29 +00:00
@md5sum --status -c $( TARGET) .$( VERSION) .$( REV) .uncompressed.md5 && \
$( PRINT) " $( BLUE) $( TARGET) . $( VERSION) . $( REV) .uncompressed.z64 $( NO_COL) : $( GREEN) OK $( NO_COL) \n $( YELLOW) $( SF) " || \
$( PRINT) " $( BLUE) $( TARGET) . $( VERSION) . $( REV) .uncompressed.z64 $( RED) FAILED $( NO_COL) \n\
2023-12-24 20:01:44 +00:00
$( RED) CAN' T LET YOU DO THAT, STARFOX.$( NO_COL) \n "
2024-05-12 00:11:29 +00:00
@md5sum --status -c $( TARGET) .$( VERSION) .$( REV) .uncompressed.md5
2023-10-03 06:59:01 +00:00
e n d i f
2023-10-15 21:00:39 +00:00
compressed : $( ROMC )
i f e q ( $( COMPARE ) , 1 )
2023-12-04 21:36:31 +00:00
@echo " $( GREEN) Calculating Rom Header Checksum... $( YELLOW) $< $( NO_COL) "
2023-11-30 22:35:40 +00:00
@$( PYTHON) $( COMPTOOL) -r $( ROMC) .
2024-05-12 00:11:29 +00:00
@md5sum --status -c $( TARGET) .$( VERSION) .$( REV) .md5 && \
$( PRINT) " $( BLUE) $( TARGET) . $( VERSION) . $( REV) .z64 $( NO_COL) : $( GREEN) OK $( NO_COL) \n " || \
$( PRINT) " $( BLUE) $( TARGET) . $( VERSION) . $( REV) .z64 $( RED) FAILED $( NO_COL) \n "
@md5sum --status -c $( TARGET) .$( VERSION) .$( REV) .uncompressed.md5
2023-10-15 21:00:39 +00:00
e n d i f
2023-10-03 06:59:01 +00:00
#### Main Targets ###
2023-10-16 09:12:15 +00:00
decompress : $( BASEROM )
2023-10-15 22:04:03 +00:00
@echo "Decompressing ROM..."
2024-05-15 18:41:15 +00:00
@$( PYTHON) $( COMPTOOL) $( DECOMPRESS_OPT) -dse $( COMPTOOL_DIR) -m $( MIO0) $( BASEROM) $( BASEROM_UNCOMPRESSED)
2024-05-11 20:53:37 +00:00
compress : $( BASEROM )
@echo "Compressing ROM..."
2024-05-12 15:45:33 +00:00
@$( PYTHON) $( COMPTOOL) $( COMPRESS_OPT) -c -m $( MIO0) $( ROM) $( ROMC)
2023-10-15 07:50:10 +00:00
2023-10-03 05:57:03 +00:00
extract :
2024-05-12 00:11:29 +00:00
@$( RM) -r asm/$( VERSION) /$( REV) bin/$( VERSION) /$( REV)
2023-10-16 17:55:18 +00:00
@echo "Unifying yamls..."
2024-05-12 00:11:29 +00:00
@$( CAT) yamls/$( VERSION) /$( REV) /header.yaml yamls/$( VERSION) /$( REV) /main.yaml yamls/$( VERSION) /$( REV) /assets.yaml yamls/$( VERSION) /$( REV) /overlays.yaml > $( SPLAT_YAML)
2023-10-16 17:55:18 +00:00
@echo "Extracting..."
@$( SPLAT) $( SPLAT_YAML)
2023-10-03 06:59:01 +00:00
2024-02-18 02:19:18 +00:00
assets :
2024-03-27 04:12:50 +00:00
@echo "Extracting assets from ROM..."
2024-05-05 20:23:49 +00:00
@$( TORCH) code $( BASEROM_UNCOMPRESSED)
2024-02-19 01:34:56 +00:00
@$( TORCH) header $( BASEROM_UNCOMPRESSED)
2024-03-03 15:19:57 +00:00
@$( TORCH) modding export $( BASEROM_UNCOMPRESSED)
2024-02-18 02:19:18 +00:00
2024-05-16 14:08:02 +00:00
mod :
@$( TORCH) modding import code $( BASEROM_UNCOMPRESSED)
2023-10-03 06:59:01 +00:00
clean :
2024-03-29 17:31:28 +00:00
rm -f torch.hash.yml
2024-05-14 18:04:04 +00:00
@git clean -fdx asm/$( VERSION) /$( REV)
@git clean -fdx bin/$( VERSION) /$( REV)
@git clean -fdx build/
2024-05-14 18:04:49 +00:00
@git clean -fdx src/assets/
2024-02-22 03:24:52 +00:00
@git clean -fdx include/assets/
2024-05-14 14:46:46 +00:00
@git clean -fdx linker_scripts/$( VERSION) /$( REV) /*.ld
2023-10-03 06:59:01 +00:00
2023-10-07 07:38:28 +00:00
format :
2023-12-04 21:36:31 +00:00
@$( PYTHON) $( TOOLS) /format.py -j $( N_THREADS)
2023-10-07 07:38:28 +00:00
checkformat :
2023-10-16 09:46:40 +00:00
@$( TOOLS) /check_format.sh -j $( N_THREADS)
2023-10-07 07:38:28 +00:00
2023-10-14 08:14:25 +00:00
# asm-differ expected object files
expected :
mkdir -p expected/build
rm -rf expected/build/
cp -r build/ expected/build/
2023-11-27 12:39:12 +00:00
context :
@echo "Generating ctx.c ..."
2024-05-14 18:06:35 +00:00
@$( PYTHON) ./$( TOOLS) /m2ctx.py $( filter-out $@ , $( MAKECMDGOALS) )
2023-10-03 06:59:01 +00:00
2023-11-28 18:26:18 +00:00
disasm :
2024-05-12 00:11:29 +00:00
@$( RM) -r asm/$( VERSION) /$( REV) bin/$( VERSION) /$( REV)
2023-11-28 18:26:18 +00:00
@echo "Unifying yamls..."
2024-05-12 00:11:29 +00:00
@$( CAT) yamls/$( VERSION) /$( REV) /header.yaml yamls/$( VERSION) /$( REV) /main.yaml yamls/$( VERSION) /$( REV) /assets.yaml yamls/$( VERSION) /$( REV) /overlays.yaml > $( SPLAT_YAML)
2023-11-28 18:26:18 +00:00
@echo "Extracting..."
@$( SPLAT) $( SPLAT_YAML) --disassemble-all
2023-10-03 06:59:01 +00:00
#### Various Recipes ####
2023-10-16 17:47:20 +00:00
# Final ROM
2023-10-15 22:47:03 +00:00
$(ROMC) : $( BASEROM_UNCOMPRESSED )
2023-12-04 21:36:31 +00:00
$( call print,Compressing ROM...,$<,$@ )
2024-05-11 20:53:37 +00:00
@$( PYTHON) $( COMPTOOL) -c -m $( MIO0) $( ROM) $( ROMC)
2023-10-15 21:00:39 +00:00
2023-10-16 17:51:04 +00:00
# Uncompressed ROM
$(ROM) : $( ELF )
2023-12-04 21:36:31 +00:00
$( call print,ELF->ROM:,$<,$@ )
$( V) $( OBJCOPY) -O binary $< $@
2023-10-16 17:51:04 +00:00
2023-10-16 17:50:24 +00:00
# Link
2024-05-12 00:11:29 +00:00
$(ELF) : $( LIBULTRA_O ) $( O_FILES ) $( LD_SCRIPT ) $( BUILD_DIR ) /linker_scripts /$( VERSION ) /$( REV ) /hardware_regs .ld $( BUILD_DIR ) /linker_scripts /$( VERSION ) /$( REV ) /undefined_syms .ld $( BUILD_DIR ) /linker_scripts /$( VERSION ) /$( REV ) /pif_syms .ld
2023-12-04 21:36:31 +00:00
$( call print,Linking:,$<,$@ )
$( V) $( LD) $( LDFLAGS) -T $( LD_SCRIPT) \
2024-05-12 00:11:29 +00:00
-T $( BUILD_DIR) /linker_scripts/$( VERSION) /$( REV) /hardware_regs.ld -T $( BUILD_DIR) /linker_scripts/$( VERSION) /$( REV) /undefined_syms.ld -T $( BUILD_DIR) /linker_scripts/$( VERSION) /$( REV) /pif_syms.ld \
2023-10-03 06:59:01 +00:00
-Map $( LD_MAP) -o $@
2023-10-16 17:50:24 +00:00
# PreProcessor
2023-10-03 06:59:01 +00:00
$(BUILD_DIR)/%.ld : %.ld
2023-12-04 21:36:31 +00:00
$( call print,PreProcessor:,$<,$@ )
$( V) $( CPP) $( CPPFLAGS) $( BUILD_DEFINES) $( IINC) $< > $@
2023-10-03 06:59:01 +00:00
2023-10-14 08:21:21 +00:00
# Binary
2023-10-03 06:59:01 +00:00
$(BUILD_DIR)/%.o : %.bin
2023-12-04 21:36:31 +00:00
$( call print,Binary:,$<,$@ )
$( V) $( OBJCOPY) -I binary -O elf32-big $< $@
2023-10-03 06:59:01 +00:00
2023-10-14 08:21:21 +00:00
# Assembly
2023-10-03 06:59:01 +00:00
$(BUILD_DIR)/%.o : %.s
2023-12-04 21:36:31 +00:00
$( call print,Assembling:,$<,$@ )
$( V) $( CPP) $( CPPFLAGS) $( BUILD_DEFINES) $( IINC) -I $( dir $* ) $( COMMON_DEFINES) $( RELEASE_DEFINES) $( GBI_DEFINES) $( AS_DEFINES) $< | $( ICONV) $( ICONV_FLAGS) | $( AS) $( ASFLAGS) $( ENDIAN) $( IINC) -I $( dir $* ) -o $@
$( V) $( OBJDUMP_CMD)
2023-10-03 06:59:01 +00:00
2023-10-14 08:21:21 +00:00
# C
2023-10-03 06:59:01 +00:00
$(BUILD_DIR)/%.o : %.c
2023-12-04 21:36:31 +00:00
$( call print,Compiling:,$<,$@ )
@$( CC_CHECK) $( CC_CHECK_FLAGS) $( IINC) -I $( dir $* ) $( CHECK_WARNINGS) $( BUILD_DEFINES) $( COMMON_DEFINES) $( RELEASE_DEFINES) $( GBI_DEFINES) $( C_DEFINES) $( MIPS_BUILTIN_DEFS) -o $@ $<
$( V) $( CC) -c $( CFLAGS) $( BUILD_DEFINES) $( IINC) $( WARNINGS) $( MIPS_VERSION) $( ENDIAN) $( COMMON_DEFINES) $( RELEASE_DEFINES) $( GBI_DEFINES) $( C_DEFINES) $( OPTFLAGS) -o $@ $<
$( V) $( OBJDUMP_CMD)
$( V) $( RM_MDEBUG)
2023-10-03 06:59:01 +00:00
2023-10-17 21:50:39 +00:00
# Patch ll.o
build/src/libultra/libc/ll.o : src /libultra /libc /ll .c
2023-12-04 21:36:31 +00:00
$( call print,Patching:,$<,$@ )
@$( CC_CHECK) $( CC_CHECK_FLAGS) $( IINC) -I $( dir $* ) $( CHECK_WARNINGS) $( BUILD_DEFINES) $( COMMON_DEFINES) $( RELEASE_DEFINES) $( GBI_DEFINES) $( C_DEFINES) $( MIPS_BUILTIN_DEFS) -o $@ $<
$( V) $( CC) -c $( CFLAGS) $( BUILD_DEFINES) $( IINC) $( WARNINGS) $( MIPS_VERSION) $( ENDIAN) $( COMMON_DEFINES) $( RELEASE_DEFINES) $( GBI_DEFINES) $( C_DEFINES) $( OPTFLAGS) -o $@ $<
2024-05-14 18:06:35 +00:00
$( V) $( PYTHON) $( TOOLS) /set_o32abi_bit.py $@
2023-12-04 21:36:31 +00:00
$( V) $( OBJDUMP_CMD)
$( V) $( RM_MDEBUG)
2023-10-17 21:50:39 +00:00
2023-10-03 06:59:01 +00:00
- i n c l u d e $( DEP_FILES )
# Print target for debugging
2023-10-15 23:41:23 +00:00
print-% : ; $( info $ * is a $ ( flavor $ *) variable set to [$ ( $ *) ]) @true
2024-05-11 20:53:37 +00:00
.PHONY : all uncompressed compressed clean init extract expected format checkformat decompress compress assets context disasm toolchain