2019-08-25 04:46:40 +00:00
# Makefile to rebuild SM64 split image
2022-03-13 08:17:10 +00:00
i n c l u d e u t i l . m k
# Default target
2019-08-25 04:46:40 +00:00
default : all
2022-03-13 08:17:10 +00:00
# Preprocessor definitions
DEFINES :=
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Build Options #
#==============================================================================#
# These options can either be set by building with 'make SETTING=value'.
# 'make clean' may be required first.
2019-12-02 02:52:53 +00:00
2020-06-20 01:32:12 +00:00
# Build debug version
DEBUG ?= 0
2022-03-13 08:17:10 +00:00
# Enable development/testing flags
DEVELOPMENT ?= 0
# Build for the N64 (turn this off for ports)
TARGET_N64 = 0
2020-05-10 08:11:27 +00:00
2020-05-08 07:38:50 +00:00
# Build and optimize for Raspberry Pi(s)
TARGET_RPI ?= 0
2020-05-16 19:30:27 +00:00
# Makeflag to enable OSX fixes
OSX_BUILD ?= 0
2020-04-03 18:57:26 +00:00
2020-05-19 19:22:52 +00:00
# Specify the target you are building for, TARGET_BITS=0 means native
TARGET_ARCH ?= native
TARGET_BITS ?= 0
2020-05-16 12:41:57 +00:00
# Disable texture fixes by default (helps with them purists)
2023-02-21 02:48:53 +00:00
TEXTURE_FIX ?= 0
2023-11-11 17:15:32 +00:00
# Enable level texture enhancements by default (Castle Grounds and Castle Courtyard recolorable texture hills)
ENHANCE_LEVEL_TEXTURES ?= 1
2023-04-16 02:53:34 +00:00
# Enable Discord Game SDK (used for Discord invites)
2020-09-19 07:51:40 +00:00
DISCORD_SDK ?= 1
2023-04-10 06:45:52 +00:00
# Enable CoopNet SDK (used for CoopNet server hosting)
COOPNET ?= 1
2020-09-05 00:02:09 +00:00
# Enable docker build workarounds
DOCKERBUILD ?= 0
2023-02-19 08:40:49 +00:00
# Sets your optimization level for building.
# A choose is chosen by default for you.
OPT_LEVEL ?= -1
2022-04-14 05:55:15 +00:00
# Enable compiling with more debug info.
DEBUG_INFO_LEVEL ?= 2
2022-04-20 01:18:15 +00:00
# Enable profiling
PROFILE ?= 0
2023-05-11 20:05:06 +00:00
# Enable address sanitizer
ASAN ?= 0
2022-05-20 00:12:39 +00:00
# Compile headless
HEADLESS ?= 0
2022-05-19 23:33:17 +00:00
# Enable Game ICON
ICON ?= 1
2023-12-08 18:02:08 +00:00
# Use .app (for macOS)
2022-06-06 02:11:58 +00:00
USE_APP ?= 1
2024-07-01 16:28:42 +00:00
# Make some small adjustments for handheld devices
HANDHELD ?= 0
2020-05-08 01:24:42 +00:00
2023-11-02 00:17:55 +00:00
# Various workarounds for weird toolchains
2020-05-19 19:22:52 +00:00
NO_BZERO_BCOPY ?= 0
NO_LDIV ?= 0
2020-06-11 00:44:08 +00:00
# Backend selection
2020-05-20 03:58:35 +00:00
2024-03-30 18:02:58 +00:00
# Renderers: GL, GL_LEGACY, D3D11, DUMMY
2020-06-11 00:44:08 +00:00
RENDER_API ?= GL
2024-03-30 18:02:58 +00:00
# Window managers: SDL1, SDL2, DXGI (forced if RENDER_API is D3D11), DUMMY (forced if RENDER_API is DUMMY)
2020-06-11 00:44:08 +00:00
WINDOW_API ?= SDL2
2022-01-22 03:13:41 +00:00
# Audio backends: SDL1, SDL2, DUMMY
2020-06-11 00:44:08 +00:00
AUDIO_API ?= SDL2
2020-08-30 13:06:22 +00:00
# Controller backends (can have multiple, space separated): SDL2, SDL1
2020-06-11 00:44:08 +00:00
CONTROLLER_API ?= SDL2
2020-05-20 03:58:35 +00:00
2020-05-19 19:22:52 +00:00
# Automatic settings for PC port(s)
WINDOWS_BUILD ?= 0
2022-02-11 02:03:44 +00:00
WINDOWS_AUTO_BUILDER ?= 0
2022-03-28 00:26:39 +00:00
# Setup extra cflags
EXTRA_CFLAGS ?=
EXTRA_CPP_FLAGS ?=
EXTRA_CFLAGS += -Wno-format-security -Wno-trigraphs
2022-02-11 02:03:44 +00:00
2023-03-21 23:43:29 +00:00
dev : ; @$( MAKE ) DEVELOPMENT =1
2022-10-31 00:29:59 +00:00
2022-03-13 08:17:10 +00:00
# COMPILER - selects the C compiler to use
# gcc - uses the GNU C Compiler
COMPILER = gcc
2022-03-28 00:26:39 +00:00
$( eval $ ( call validate -option ,COMPILER ,ido gcc clang ) )
2022-02-12 02:38:25 +00:00
2020-06-02 19:37:43 +00:00
# Attempt to detect OS
2020-05-19 19:22:52 +00:00
i f e q ( $( OS ) , W i n d o w s _ N T )
2020-06-02 19:37:43 +00:00
HOST_OS ?= Windows
e l s e
HOST_OS ?= $( shell uname -s 2>/dev/null || echo Unknown)
# some weird MINGW/Cygwin env that doesn't define $OS
ifneq ( ,$( findstring MINGW,HOST_OS) )
HOST_OS := Windows
endif
e n d i f
2022-08-26 00:32:20 +00:00
i f e q ( $( HOST_OS ) , W i n d o w s )
WINDOWS_BUILD := 1
2020-05-17 00:04:55 +00:00
e n d i f
2023-12-06 19:56:50 +00:00
i f e q ( $( HOST_OS ) , D a r w i n )
OSX_BUILD := 1
e n d i f
2020-05-19 19:22:52 +00:00
# MXE overrides
2020-05-19 13:38:08 +00:00
i f e q ( $( WINDOWS_BUILD ) , 1 )
ifeq ( $( CROSS) ,i686-w64-mingw32.static-)
2020-05-19 19:22:52 +00:00
TARGET_ARCH = i386pe
2020-05-19 13:38:08 +00:00
TARGET_BITS = 32
2020-05-19 19:22:52 +00:00
NO_BZERO_BCOPY := 1
2020-05-19 13:38:08 +00:00
else ifeq ( $( CROSS) ,x86_64-w64-mingw32.static-)
2020-05-19 19:22:52 +00:00
TARGET_ARCH = i386pe
2020-05-19 13:38:08 +00:00
TARGET_BITS = 64
2020-05-19 19:22:52 +00:00
NO_BZERO_BCOPY := 1
2020-05-19 13:38:08 +00:00
endif
e n d i f
2020-05-07 18:21:22 +00:00
2020-09-26 06:18:56 +00:00
# Determine default windows target bits
i f e q ( $( WINDOWS_BUILD ) , 1 )
ifeq ( $( TARGET_BITS) , 0)
CPU_TYPE := $( firstword $( subst -, ,$( shell $( CC) -dumpmachine) ) )
ifeq ( $( CPU_TYPE) , x86_64)
TARGET_BITS := 64
else ifeq ( $( CPU_TYPE) , i686)
TARGET_BITS := 32
else ifeq ( $( CPU_TYPE) , mingw32)
TARGET_BITS := 32
endif
endif
e n d i f
2022-04-14 05:55:15 +00:00
i f n e q ( $( TARGET_BITS ) , 0 )
BITS := -m$( TARGET_BITS)
e n d i f
2023-04-30 01:14:44 +00:00
i f e q ( $( WINDOWS_AUTO_BUILDER ) , 1 )
export SHELL = sh.exe
2023-05-04 08:03:18 +00:00
ifeq ( $( TARGET_BITS) ,32)
2023-04-30 01:14:44 +00:00
EXTRA_INCLUDES := ../include/1 ../include/2 ../include/3 ../include/4
2023-05-04 08:03:18 +00:00
EXTRA_CPP_INCLUDES := -I../include/cpp
2023-04-30 01:14:44 +00:00
else
EXTRA_INCLUDES :=
EXTRA_CPP_INCLUDES :=
endif
EXTRA_CFLAGS += -Wno-expansion-to-defined
EXTRA_CPP_FLAGS := -Wno-class-conversion -Wno-packed-not-aligned
e l s e
EXTRA_INCLUDES ?=
EXTRA_CPP_INCLUDES ?=
e n d i f
2023-06-24 20:48:44 +00:00
i f e q ( $( TARGET_BITS ) , 3 2 )
DEFINES += BITS_32 = 1
e n d i f
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
# VERSION - selects the version of the game to build
# jp - builds the 1996 Japanese version
# us - builds the 1996 North American version
# eu - builds the 1997 PAL version
# sh - builds the 1997 Japanese Shindou version, with rumble pak support
VERSION ?= us
2024-05-15 22:07:42 +00:00
$( eval $ ( call validate -option ,VERSION ,us ) )
2022-03-13 08:17:10 +00:00
# Graphics microcode used
GRUCODE ?= f3dex2e
i f e q ( $( VERSION ) , j p )
DEFINES += VERSION_JP = 1
#GRUCODE ?= f3d_old
VERSION_JP_US ?= true
e l s e i f e q ( $( VERSION ) , u s )
DEFINES += VERSION_US = 1
#GRUCODE ?= f3d_old
VERSION_JP_US ?= true
e l s e i f e q ( $( VERSION ) , e u )
DEFINES += VERSION_EU = 1
#GRUCODE ?= f3d_new
VERSION_JP_US ?= false
e l s e i f e q ( $( VERSION ) , s h )
DEFINES += VERSION_SH = 1
#GRUCODE ?= f3d_new
VERSION_JP_US ?= false
2019-08-25 04:46:40 +00:00
e n d i f
2022-03-13 08:17:10 +00:00
2022-04-14 05:55:15 +00:00
# Determine our optimization level.
2023-02-19 08:40:49 +00:00
# Optimization Levels 0 through 5 optimize for speed,
# While optimization levels 6, and 7 optimize for size.
# If no optimization is specified, A default is chosen.
i f e q ( $( OPT_LEVEL ) , 0 ) # No optimization
OPT_FLAGS := -O0
e l s e i f e q ( $( OPT_LEVEL ) , 1 ) # Debugging optimization
OPT_FLAGS := -Og
e l s e i f e q ( $( OPT_LEVEL ) , 2 ) # Level 1 Optimization
OPT_FLAGS := -O1
e l s e i f e q ( $( OPT_LEVEL ) , 3 ) # Level 2 Optimization
2022-04-24 03:01:52 +00:00
OPT_FLAGS := -O2
2023-02-19 08:40:49 +00:00
e l s e i f e q ( $( OPT_LEVEL ) , 4 ) # Level 3 Optimization
OPT_FLAGS := -O3
e l s e i f e q ( $( OPT_LEVEL ) , 5 ) # Fastest Optimization
OPT_FLAGS := -Ofast
e l s e i f e q ( $( OPT_LEVEL ) , 6 ) # Size Optimization
OPT_FLAGS := -Os
e l s e i f e q ( $( OPT_LEVEL ) , 7 ) # Aggresive Size Optimization
OPT_FLAGS := -Oz
2022-04-14 05:55:15 +00:00
e l s e
2023-02-19 08:40:49 +00:00
ifeq ( $( DEBUG) ,0)
# Can't use O2 or higher right now for auto-builders, coop-compiler produces strange graphical errors
# likely due to undefined behavior somewhere
#ifeq ($(WINDOWS_AUTO_BUILDER),1)
# OPT_FLAGS := -O1
#else
OPT_FLAGS := -O2
#endif
else
OPT_FLAGS := -O0
endif
2022-04-14 05:55:15 +00:00
e n d i f
# Set our level of debug symbol info,
# Including an option to disable it.
# Level 0 produces no debug information at all. Thus, -g0 negates -g.
# Level 1 produces minimal information, enough for making backtraces in parts of the program that you don’ t plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.
# Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.
# From https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
i f e q ( $( DEBUG_INFO_LEVEL ) , 3 )
OPT_FLAGS += -g -g3
e l s e i f e q ( $( DEBUG_INFO_LEVEL ) , 1 )
OPT_FLAGS += -g -g1
e l s e i f e q ( $( DEBUG_INFO_LEVEL ) , 0 )
# If we're compiling with -0g. I don't believe this will do anything worthwhile.
OPT_FLAGS += -g0
2022-08-26 00:30:19 +00:00
e l s e
2022-04-14 05:55:15 +00:00
# This is our default AND level 2.
OPT_FLAGS += -g
e n d i f
2022-04-20 01:18:15 +00:00
i f e q ( $( PROFILE ) , 1 )
PROF_FLAGS := -pg
e l s e
PROF_FLAGS :=
e n d i f
2022-03-13 08:17:10 +00:00
i f e q ( $( TARGET_RPI ) , 1 )
2022-09-13 03:00:51 +00:00
$( info Compiling for Raspberry Pi)
DISCORD_SDK := 0
2023-11-27 02:04:10 +00:00
COOPNET := 0
2022-03-13 08:17:10 +00:00
machine = $( shell sh -c 'uname -m 2>/dev/null || echo unknown' )
# Raspberry Pi B+, Zero, etc
ifneq ( ,$( findstring armv6l,$( machine) ) )
OPT_FLAGS := -march= armv6zk+fp -mfpu= vfp -Ofast
endif
# Raspberry Pi 2 and 3 in ARM 32bit mode
ifneq ( ,$( findstring armv7l,$( machine) ) )
2022-09-13 03:00:51 +00:00
$( info ARM 32bit mode)
2022-03-13 08:17:10 +00:00
model = $( shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown' )
ifneq ( ,$( findstring 3,$( model) ) )
OPT_FLAGS := -march= armv8-a+crc -mtune= cortex-a53 -mfpu= neon-fp-armv8 -O3
else
OPT_FLAGS := -march= armv7-a -mtune= cortex-a7 -mfpu= neon-vfpv4 -O3
endif
endif
# RPi3 or RPi4, in ARM64 (aarch64) mode. NEEDS TESTING 32BIT.
# DO NOT pass -mfpu stuff here, thats for 32bit ARM only and will fail for 64bit ARM.
ifneq ( ,$( findstring aarch64,$( machine) ) )
2022-09-13 03:00:51 +00:00
$( info ARM64 mode)
2022-03-13 08:17:10 +00:00
model = $( shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown' )
ifneq ( ,$( findstring 3,$( model) ) )
OPT_FLAGS := -march= armv8-a+crc -mtune= cortex-a53 -O3
else ifneq ( ,$( findstring 4,$( model) ) )
OPT_FLAGS := -march= armv8-a+crc+simd -mtune= cortex-a72 -O3
endif
endif
2020-03-02 03:42:52 +00:00
e n d i f
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
# Set BITS (32/64) to compile for
OPT_FLAGS += $( BITS)
2020-06-02 16:44:34 +00:00
TARGET := sm64.$( VERSION)
2020-05-21 17:19:20 +00:00
# Stuff for showing the git hash in the intro on nightly builds
# From https://stackoverflow.com/questions/44038428/include-git-commit-hash-and-or-branch-name-in-c-c-source
2020-09-11 23:07:45 +00:00
#ifeq ($(shell git rev-parse --abbrev-ref HEAD),nightly)
2022-03-13 08:17:10 +00:00
# GIT_HASH=`git rev-parse --short HEAD`
# COMPILE_TIME=`date -u +'%Y-%m-%d %H:%M:%S UTC'`
# DEFINES += -DNIGHTLY -DGIT_HASH="\"$(GIT_HASH)\"" -DCOMPILE_TIME="\"$(COMPILE_TIME)\""
2020-09-11 23:07:45 +00:00
#endif
2020-05-21 17:19:20 +00:00
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
# GRUCODE - selects which RSP microcode to use.
# f3d_old - default for JP and US versions
# f3d_new - default for EU and Shindou versions
# f3dex -
# f3dex2 -
2023-11-20 00:38:26 +00:00
# f3dex2e - default for PC Port
2022-03-13 08:17:10 +00:00
# f3dzex - newer, experimental microcode used in Animal Crossing
$( eval $ ( call validate -option ,GRUCODE ,f 3d_old f 3dex f 3dex 2 f 3dex 2e f 3d_new f 3dzex ) )
i f e q ( $( GRUCODE ) , f 3 d _ o l d )
DEFINES += F3D_OLD = 1
e l s e i f e q ( $( GRUCODE ) , f 3 d _ n e w ) # Fast3D 2.0H
DEFINES += F3D_NEW = 1
e l s e i f e q ( $( GRUCODE ) , f 3 d e x ) # Fast3DEX
DEFINES += F3DEX_GBI = 1 F3DEX_GBI_SHARED = 1
e l s e i f e q ( $( GRUCODE ) , f 3 d e x 2 ) # Fast3DEX2
DEFINES += F3DEX_GBI_2 = 1 F3DEX_GBI_SHARED = 1
e l s e i f e q ( $( GRUCODE ) , f 3 d e x 2 e ) # Fast3DEX2 Extended (PC default)
DEFINES += F3DEX_GBI_2E = 1 F3DEX_GBI_SHARED = 1
e l s e i f e q ( $( GRUCODE ) , f 3 d z e x ) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori)
2019-08-25 04:46:40 +00:00
$( warning Fast3DZEX is experimental. Try at your own risk.)
2022-03-13 08:17:10 +00:00
DEFINES += F3DZEX_GBI_2 = 1 F3DEX_GBI_2 = 1 F3DEX_GBI_SHARED = 1
2019-08-25 04:46:40 +00:00
e n d i f
2020-06-02 16:44:34 +00:00
2022-03-13 08:17:10 +00:00
# Check for certain target types.
2019-08-25 04:46:40 +00:00
2020-05-10 08:11:27 +00:00
i f e q ( $( TARGET_RPI ) , 1 ) # Define RPi to change SDL2 title & GLES2 hints
2022-03-21 21:02:23 +00:00
DEFINES += USE_GLES = 1
2019-08-25 04:46:40 +00:00
e n d i f
2020-05-16 19:30:27 +00:00
i f e q ( $( OSX_BUILD ) , 1 ) # Modify GFX & SDL2 for OSX GL
2022-03-21 21:02:23 +00:00
DEFINES += OSX_BUILD = 1
2020-05-16 19:30:27 +00:00
e n d i f
2020-06-11 00:44:08 +00:00
# Check backends
2024-03-30 18:02:58 +00:00
i f n e q ( , $( filter $ ( RENDER_API ) ,D 3D 11) )
2020-06-11 00:44:08 +00:00
ifneq ( $( WINDOWS_BUILD) ,1)
$( error DirectX is only supported on Windows)
endif
ifneq ( $( WINDOW_API) ,DXGI)
$( warning DirectX renderers require DXGI, forcing WINDOW_API value)
WINDOW_API := DXGI
endif
e l s e
ifeq ( $( WINDOW_API) ,DXGI)
$( error DXGI can only be used with DirectX renderers)
endif
2022-01-22 03:13:41 +00:00
ifneq ( $( WINDOW_API) ,DUMMY)
ifeq ( $( RENDER_API) ,DUMMY)
$( warning Dummy renderer requires dummy window API, forcing WINDOW_API value)
WINDOW_API := DUMMY
endif
else
ifneq ( $( RENDER_API) ,DUMMY)
$( warning Dummy window API requires dummy renderer, forcing RENDER_API value)
RENDER_API := DUMMY
endif
endif
2020-06-11 00:44:08 +00:00
e n d i f
2022-05-20 00:12:39 +00:00
i f e q ( $( HEADLESS ) , 1 )
2022-06-06 02:40:21 +00:00
$( info Compiling headless)
2022-05-20 00:12:39 +00:00
RENDER_API := DUMMY
WINDOW_API := DUMMY
AUDIO_API := DUMMY
2022-08-26 00:30:19 +00:00
CONTROLLER_API :=
2022-05-20 00:12:39 +00:00
e n d i f
2022-03-13 08:17:10 +00:00
# NON_MATCHING - whether to build a matching, identical copy of the ROM
# 1 - enable some alternate, more portable code that does not produce a matching ROM
# 0 - build a matching ROM
NON_MATCHING ?= 0
$( eval $ ( call validate -option ,NON_MATCHING ,0 1) )
i f e q ( $( TARGET_N 64) , 0 )
NON_MATCHING := 1
e n d i f
i f e q ( $( NON_MATCHING ) , 1 )
DEFINES += NON_MATCHING = 1 AVOID_UB = 1
e n d i f
2022-06-06 02:11:58 +00:00
i f e q ( $( OSX_BUILD ) , 0 )
USE_APP := 0
e n d i f
2022-03-13 08:17:10 +00:00
# Whether to hide commands or not
VERBOSE ?= 0
i f e q ( $( VERBOSE ) , 0 )
V := @
e n d i f
# Whether to colorize build messages
COLOR ?= 1
# display selected options unless 'make clean' or 'make distclean' is run
i f e q ( $( filter clean distclean ,$ ( MAKECMDGOALS ) ) , )
$( info = = = = Build Options = = = = )
$( info Version: $( VERSION) )
$( info Microcode: $( GRUCODE) )
ifeq ( $( NON_MATCHING) ,1)
$( info Build Matching: no)
else
$( info Build Matching: yes)
endif
$( info = = = = = = = = = = = = = = = = = = = = = = = )
e n d i f
#==============================================================================#
# Universal Dependencies #
#==============================================================================#
TOOLS_DIR := tools
2019-08-25 04:46:40 +00:00
# (This is a bit hacky, but a lot of rules implicitly depend
# on tools and assets, and we use directory globs further down
# in the makefile that we want should cover assets.)
2022-03-13 08:17:10 +00:00
PYTHON := python3
i f e q ( $( filter clean distclean print -%,$ ( MAKECMDGOALS ) ) , )
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
# Make sure assets exist
NOEXTRACT ?= 0
ifeq ( $( NOEXTRACT) ,0)
DUMMY != $( PYTHON) extract_assets.py $( VERSION) >& 2 || echo FAIL
ifeq ( $( DUMMY) ,FAIL)
$( error Failed to extract assets)
endif
2022-02-11 02:03:44 +00:00
endif
2022-03-13 08:17:10 +00:00
2022-03-22 05:42:25 +00:00
ifeq ( $( WINDOWS_AUTO_BUILDER) ,0)
$( info Building tools...)
DUMMY != $( MAKE) -C $( TOOLS_DIR) >& 2 || echo FAIL
ifeq ( $( DUMMY) ,FAIL)
$( error Failed to build tools)
endif
endif
2022-03-13 08:17:10 +00:00
$( info Building Game...)
2019-08-25 04:46:40 +00:00
e n d i f
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Extra Source Files #
#==============================================================================#
2023-03-22 23:04:16 +00:00
# Copy missing instrument samples from the music sound banks
_ := $( shell $( PYTHON) $( TOOLS_DIR) /copy_extended_sounds.py)
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Target Executable and Sources #
#==============================================================================#
2019-08-25 04:46:40 +00:00
BUILD_DIR_BASE := build
2022-03-13 08:17:10 +00:00
# BUILD_DIR is the location where all build artifacts are placed
2022-08-26 00:32:20 +00:00
BUILD_DIR := $( BUILD_DIR_BASE) /$( VERSION) _pc
2019-08-25 04:46:40 +00:00
2022-08-26 00:32:20 +00:00
i f e q ( $( WINDOWS_BUILD ) , 1 )
2023-11-20 00:38:26 +00:00
EXE := $( BUILD_DIR) /sm64coopdx.exe
2022-08-26 00:32:20 +00:00
e l s e # Linux builds/binary namer
ifeq ( $( TARGET_RPI) ,1)
2023-11-20 00:38:26 +00:00
EXE := $( BUILD_DIR) /sm64coopdx.arm
2022-08-26 00:32:20 +00:00
else
2023-11-20 00:38:26 +00:00
EXE := $( BUILD_DIR) /sm64coopdx
2020-05-10 08:11:27 +00:00
endif
2020-05-08 07:38:50 +00:00
e n d i f
2022-03-13 08:17:10 +00:00
ELF := $( BUILD_DIR) /$( TARGET) .elf
LIBULTRA := $( BUILD_DIR) /libultra.a
LD_SCRIPT := sm64.ld
MIO0_DIR := $( BUILD_DIR) /bin
SOUND_BIN_DIR := $( BUILD_DIR) /sound
TEXTURE_DIR := textures
ACTOR_DIR := actors
LEVEL_DIRS := $( patsubst levels/%,%,$( dir $( wildcard levels/*/header.h) ) )
2019-08-25 04:46:40 +00:00
# Directories containing source files
2024-03-23 20:14:53 +00:00
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets asm lib sound
2022-03-13 08:17:10 +00:00
BIN_DIRS := bin bin/$( VERSION)
2020-05-10 08:11:27 +00:00
2022-03-13 08:17:10 +00:00
# PC files
2024-03-23 14:10:15 +00:00
SRC_DIRS += src/pc src/pc/gfx src/pc/audio src/pc/controller src/pc/fs src/pc/fs/packtypes src/pc/mods src/pc/dev src/pc/network src/pc/network/packets src/pc/network/socket src/pc/network/coopnet src/pc/utils src/pc/utils/miniz src/pc/djui src/pc/lua src/pc/lua/utils src/pc/os
2020-05-10 08:11:27 +00:00
2020-09-19 07:51:40 +00:00
i f e q ( $( DISCORD_SDK ) , 1 )
2023-04-16 02:53:34 +00:00
SRC_DIRS += src/pc/discord
2020-09-19 07:51:40 +00:00
e n d i f
2022-03-13 08:17:10 +00:00
ULTRA_SRC_DIRS := lib/src lib/src/math lib/asm lib/data
2019-08-25 04:46:40 +00:00
ULTRA_BIN_DIRS := lib/bin
GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists
# File dependencies and variables for specific files
i n c l u d e M a k e f i l e . s p l i t
2022-03-21 23:46:31 +00:00
# Dynos
i n c l u d e d y n o s . m k
2019-08-25 04:46:40 +00:00
# Source code files
2022-03-13 08:17:10 +00:00
LEVEL_C_FILES := $( wildcard levels/*/leveldata.c) $( wildcard levels/*/script.c) $( wildcard levels/*/geo.c)
C_FILES := $( foreach dir,$( SRC_DIRS) ,$( wildcard $( dir) /*.c) ) $( LEVEL_C_FILES)
CPP_FILES := $( foreach dir,$( SRC_DIRS) ,$( wildcard $( dir) /*.cpp) )
S_FILES := $( foreach dir,$( SRC_DIRS) ,$( wildcard $( dir) /*.s) )
ULTRA_C_FILES := $( foreach dir,$( ULTRA_SRC_DIRS) ,$( wildcard $( dir) /*.c) )
GODDARD_C_FILES := $( foreach dir,$( GODDARD_SRC_DIRS) ,$( wildcard $( dir) /*.c) )
ULTRA_S_FILES := $( foreach dir,$( ULTRA_SRC_DIRS) ,$( wildcard $( dir) /*.s) )
GENERATED_C_FILES := $( BUILD_DIR) /assets/mario_anim_data.c $( BUILD_DIR) /assets/demo_data.c
2024-03-23 20:11:30 +00:00
#ifeq ($(TARGET_N64),0)
# GENERATED_C_FILES += $(addprefix $(BUILD_DIR)/bin/,$(addsuffix _skybox.c,$(notdir $(basename $(wildcard textures/skyboxes/*.png)))))
#endif
2022-03-13 08:17:10 +00:00
# "If we're N64, use the above"
i f e q ( $( TARGET_N 64) , 0 )
ULTRA_C_FILES := \
alBnkfNew.c \
guLookAtRef.c \
guMtxF2L.c \
guNormalize.c \
guOrthoF.c \
guPerspectiveF.c \
guRotateF.c \
guScaleF.c \
guTranslateF.c \
ldiv.c
C_FILES := $( filter-out src/game/main.c,$( C_FILES) )
ULTRA_C_FILES := $( addprefix lib/src/,$( ULTRA_C_FILES) )
e n d i f
# Sound files
SOUND_BANK_FILES := $( wildcard sound/sound_banks/*.json)
SOUND_SAMPLE_DIRS := $( wildcard sound/samples/*)
SOUND_SAMPLE_AIFFS := $( foreach dir,$( SOUND_SAMPLE_DIRS) ,$( wildcard $( dir) /*.aiff) )
2019-08-25 04:46:40 +00:00
SOUND_SAMPLE_TABLES := $( foreach file,$( SOUND_SAMPLE_AIFFS) ,$( BUILD_DIR) /$( file:.aiff= .table) )
2022-03-13 08:17:10 +00:00
SOUND_SAMPLE_AIFCS := $( foreach file,$( SOUND_SAMPLE_AIFFS) ,$( BUILD_DIR) /$( file:.aiff= .aifc) )
SOUND_SEQUENCE_DIRS := sound/sequences sound/sequences/$( VERSION)
# all .m64 files in SOUND_SEQUENCE_DIRS, plus all .m64 files that are generated from .s files in SOUND_SEQUENCE_DIRS
SOUND_SEQUENCE_FILES := \
$( foreach dir,$( SOUND_SEQUENCE_DIRS) ,\
$( wildcard $( dir) /*.m64) \
$( foreach file,$( wildcard $( dir) /*.s) ,$( BUILD_DIR) /$( file:.s= .m64) ) \
)
2019-08-25 04:46:40 +00:00
# Object files
O_FILES := $( foreach file,$( C_FILES) ,$( BUILD_DIR) /$( file:.c= .o) ) \
2022-03-13 08:17:10 +00:00
$( foreach file,$( CPP_FILES) ,$( BUILD_DIR) /$( file:.cpp= .o) ) \
2019-08-25 04:46:40 +00:00
$( foreach file,$( S_FILES) ,$( BUILD_DIR) /$( file:.s= .o) ) \
2019-11-03 19:36:27 +00:00
$( foreach file,$( GENERATED_C_FILES) ,$( file:.c= .o) )
2019-08-25 04:46:40 +00:00
ULTRA_O_FILES := $( foreach file,$( ULTRA_S_FILES) ,$( BUILD_DIR) /$( file:.s= .o) ) \
$( foreach file,$( ULTRA_C_FILES) ,$( BUILD_DIR) /$( file:.c= .o) )
GODDARD_O_FILES := $( foreach file,$( GODDARD_C_FILES) ,$( BUILD_DIR) /$( file:.c= .o) )
2020-06-08 20:48:23 +00:00
RPC_LIBS :=
2020-09-13 04:16:10 +00:00
DISCORD_SDK_LIBS :=
2023-04-16 02:53:34 +00:00
2020-09-19 07:51:40 +00:00
i f e q ( $( DISCORD_SDK ) , 1 )
ifeq ( $( WINDOWS_BUILD) ,1)
2020-09-26 06:18:56 +00:00
ifeq ( $( TARGET_BITS) , 32)
DISCORD_SDK_LIBS := lib/discordsdk/x86/discord_game_sdk.dll
else
DISCORD_SDK_LIBS := lib/discordsdk/discord_game_sdk.dll
endif
2020-09-19 07:51:40 +00:00
else ifeq ( $( OSX_BUILD) ,1)
# needs testing
2021-08-02 09:59:45 +00:00
# HACKY! Instead of figuring out all of the dynamic library linking madness...
# I copied the library and gave it two names.
# This really shouldn't be required, but I got tired of trying to do it the "right way"
2024-01-06 14:48:58 +00:00
ifeq ( $( shell uname -m) ,arm64) # A hacky way of determining if the user is running on Apple Silicon hardware
DISCORD_SDK_LIBS := lib/discordsdk/aarch64/discord_game_sdk.dylib lib/discordsdk/aarch64/libdiscord_game_sdk.dylib
else
DISCORD_SDK_LIBS := lib/discordsdk/discord_game_sdk.dylib lib/discordsdk/libdiscord_game_sdk.dylib
endif
2020-09-19 07:51:40 +00:00
else
DISCORD_SDK_LIBS := lib/discordsdk/libdiscord_game_sdk.so
endif
2020-09-13 04:16:10 +00:00
e n d i f
2023-03-31 22:18:19 +00:00
LANG_DIR := lang
# Remove old lang dir
_ := $( shell rm -rf ./$( BUILD_DIR) /$( LANG_DIR) )
2022-01-17 02:07:45 +00:00
MOD_DIR := mods
2023-12-18 21:22:42 +00:00
# Remove old mod dir
2023-12-21 22:27:13 +00:00
_ := $( shell $( PYTHON) $( TOOLS_DIR) /remove_built_in_mods.py)
2023-12-18 21:22:42 +00:00
2024-05-19 13:38:22 +00:00
PALETTES_DIR := palettes
# Remove old palettes dir
_ := $( shell rm -rf ./$( BUILD_DIR) /$( PALETTES_DIR) )
2019-08-25 04:46:40 +00:00
# Automatic dependency files
DEP_FILES := $( O_FILES:.o= .d) $( ULTRA_O_FILES:.o= .d) $( GODDARD_O_FILES:.o= .d) $( BUILD_DIR) /$( LD_SCRIPT) .d
# Segment elf files
SEG_FILES := $( SEGMENT_ELF_FILES) $( ACTOR_ELF_FILES) $( LEVEL_ELF_FILES)
2022-03-13 08:17:10 +00:00
# Files with GLOBAL_ASM blocks
i f e q ( $( NON_MATCHING ) , 0 )
ifeq ( $( VERSION) ,sh)
GLOBAL_ASM_C_FILES != grep -rl 'GLOBAL_ASM(' $( wildcard src/**/*.c) $( wildcard lib/src/*.c)
else
GLOBAL_ASM_C_FILES != grep -rl 'GLOBAL_ASM(' $( wildcard src/**/*.c)
endif
GLOBAL_ASM_O_FILES = $( foreach file,$( GLOBAL_ASM_C_FILES) ,$( BUILD_DIR) /$( file:.c= .o) )
GLOBAL_ASM_DEP = $( BUILD_DIR) /src/audio/non_matching_dep
e n d i f
2020-05-07 18:21:22 +00:00
2022-01-16 16:51:29 +00:00
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Compiler Options #
#==============================================================================#
2020-05-07 18:21:22 +00:00
2022-03-13 08:17:10 +00:00
AS := $( CROSS) as
2020-05-10 08:11:27 +00:00
2020-05-16 19:30:27 +00:00
i f e q ( $( OSX_BUILD ) , 1 )
2022-03-13 08:17:10 +00:00
AS := i686-w64-mingw32-as
2020-05-16 19:30:27 +00:00
e n d i f
2022-03-22 00:02:24 +00:00
i f e q ( $( WINDOWS_AUTO_BUILDER ) , 1 )
CC := cc
CXX := g++
e l s e i f e q ( $( COMPILER ) , g c c )
2022-03-13 08:17:10 +00:00
CC := $( CROSS) gcc
CXX := $( CROSS) g++
2022-06-06 02:11:58 +00:00
ifeq ( $( OSX_BUILD) ,0)
EXTRA_CFLAGS += -Wno-unused-result -Wno-format-truncation
else
EXTRA_CFLAGS += -Wno-unused-result
endif
2022-03-28 00:26:39 +00:00
e l s e i f e q ( $( COMPILER ) , c l a n g )
CC := clang
CXX := clang++
CPP := clang++
2022-05-20 02:42:07 +00:00
EXTRA_CFLAGS += -Wno-unused-function -Wno-unused-variable -Wno-unknown-warning-option -Wno-self-assign -Wno-unknown-pragmas -Wno-unused-result
2020-05-07 18:21:22 +00:00
e l s e
2022-03-13 08:17:10 +00:00
ifeq ( $( USE_QEMU_IRIX) ,1)
IRIX_ROOT := $( TOOLS_DIR) /ido5.3_compiler
CC := $( QEMU_IRIX) -silent -L $( IRIX_ROOT) $( IRIX_ROOT) /usr/bin/cc
ACPP := $( QEMU_IRIX) -silent -L $( IRIX_ROOT) $( IRIX_ROOT) /usr/lib/acpp
COPT := $( QEMU_IRIX) -silent -L $( IRIX_ROOT) $( IRIX_ROOT) /usr/lib/copt
2020-09-19 07:51:40 +00:00
else
2022-03-13 08:17:10 +00:00
IDO_ROOT := $( TOOLS_DIR) /ido5.3_recomp
CC := $( IDO_ROOT) /cc
ACPP := $( IDO_ROOT) /acpp
COPT := $( IDO_ROOT) /copt
2020-09-19 07:51:40 +00:00
endif
e n d i f
2020-05-10 08:11:27 +00:00
2020-05-16 15:21:16 +00:00
i f e q ( $( WINDOWS_BUILD ) , 1 ) # fixes compilation in MXE on Linux and WSL
CPP := cpp -P
2020-05-16 15:56:58 +00:00
OBJCOPY := objcopy
2020-05-16 19:30:27 +00:00
OBJDUMP := $( CROSS) objdump
2020-05-19 19:22:52 +00:00
e l s e i f e q ( $( OSX_BUILD ) , 1 )
2024-07-02 18:26:00 +00:00
OSX_GCC_VER = $( shell find ` brew --prefix` /bin/gcc* | grep -oE '[[:digit:]]+' | sort -n | uniq | tail -1)
# if we couldn't find a gcc ver, default to 9
ifeq ( $( OSX_GCC_VER) ,)
OSX_GCC_VER = 9
endif
CPP := cpp-$( OSX_GCC_VER) -P
2020-05-19 19:22:52 +00:00
OBJDUMP := i686-w64-mingw32-objdump
OBJCOPY := i686-w64-mingw32-objcopy
2022-03-13 08:17:10 +00:00
e l s e i f e q ( $( TARGET_N 64) , 0 ) # Linux & other builds
2020-05-16 16:01:23 +00:00
CPP := $( CROSS) cpp -P
2020-05-16 15:56:58 +00:00
OBJCOPY := $( CROSS) objcopy
2020-05-16 19:30:27 +00:00
OBJDUMP := $( CROSS) objdump
2022-03-13 08:17:10 +00:00
e l s e
# Prefer gcc's cpp if installed on the system
ifneq ( ,$( call find-command,cpp-10) )
CPP := cpp-10
else
CPP := cpp
endif
OBJDUMP := $( CROSS) objdump
OBJCOPY := $( CROSS) objcopy
2020-05-16 19:30:27 +00:00
e n d i f
2022-03-13 08:17:10 +00:00
# thank you apple very cool
i f e q ( $( HOST_OS ) , D a r w i n )
CP := gcp
e l s e
CP := cp
e n d i f
2020-05-07 18:21:22 +00:00
2022-03-13 08:17:10 +00:00
i f e q ( $( DISCORD_SDK ) , 1 )
LD := $( CXX)
e l s e i f e q ( $( WINDOWS_BUILD ) , 1 )
ifeq ( $( CROSS) ,i686-w64-mingw32.static-) # fixes compilation in MXE on Linux and WSL
LD := $( CC)
else ifeq ( $( CROSS) ,x86_64-w64-mingw32.static-)
LD := $( CC)
else
LD := $( CXX)
endif
e l s e
2022-05-09 00:01:19 +00:00
LD := $( CXX)
2022-03-13 08:17:10 +00:00
e n d i f
AR := $( CROSS) ar
i f e q ( $( TARGET_N 64) , 1 )
TARGET_CFLAGS := -nostdinc -DTARGET_N64 -D_LANGUAGE_C
CC_CFLAGS := -fno-builtin
e l s e
TARGET_CFLAGS := -D_LANGUAGE_C
2022-03-28 00:26:39 +00:00
TARGET_CFLAGS += $( EXTRA_CFLAGS)
2022-03-13 08:17:10 +00:00
e n d i f
2022-03-28 00:26:39 +00:00
2022-03-13 08:17:10 +00:00
INCLUDE_DIRS := include $( BUILD_DIR) $( BUILD_DIR) /include src .
i f e q ( $( TARGET_N 64) , 1 )
INCLUDE_DIRS += include/libc
e l s e
2023-04-10 00:20:07 +00:00
INCLUDE_DIRS += sound lib/lua/include lib/coopnet/include $( EXTRA_INCLUDES)
2022-03-13 08:17:10 +00:00
e n d i f
# Connfigure backend flags
SDLCONFIG := $( CROSS) sdl2-config
2020-06-11 00:44:08 +00:00
BACKEND_CFLAGS := -DRAPI_$( RENDER_API) = 1 -DWAPI_$( WINDOW_API) = 1 -DAAPI_$( AUDIO_API) = 1
# can have multiple controller APIs
BACKEND_CFLAGS += $( foreach capi,$( CONTROLLER_API) ,-DCAPI_$( capi) = 1)
2020-08-15 04:15:28 +00:00
BACKEND_LDFLAG0S :=
SDL1_USED := 0
2020-06-11 00:44:08 +00:00
SDL2_USED := 0
# for now, it's either SDL+GL or DXGI+DirectX, so choose based on WAPI
i f e q ( $( WINDOW_API ) , D X G I )
DXBITS := ` cat $( ENDIAN_BITWIDTH) | tr ' ' '\n' | tail -1`
BACKEND_LDFLAGS += -ld3dcompiler -ldxgi -ldxguid
BACKEND_LDFLAGS += -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -static
2020-08-15 04:15:28 +00:00
e l s e i f e q ( $( findstring SDL ,$ ( WINDOW_API ) ) , S D L )
2020-06-11 00:44:08 +00:00
ifeq ( $( WINDOWS_BUILD) ,1)
BACKEND_LDFLAGS += -lglew32 -lglu32 -lopengl32
else ifeq ( $( TARGET_RPI) ,1)
BACKEND_LDFLAGS += -lGLESv2
else ifeq ( $( OSX_BUILD) ,1)
2023-12-27 02:44:05 +00:00
BACKEND_LDFLAGS += -framework OpenGL ` pkg-config --libs glew`
2024-07-02 18:26:00 +00:00
EXTRA_CPP_FLAGS += -stdlib= libc++ -std= c++17
2020-06-11 00:44:08 +00:00
else
BACKEND_LDFLAGS += -lGL
2022-03-13 08:17:10 +00:00
endif
2020-06-11 00:44:08 +00:00
e n d i f
2024-07-01 00:55:47 +00:00
i f e q ( $( WINDOW_API ) , D U M M Y )
ifeq ( $( WINDOWS_BUILD) ,1)
BACKEND_LDFLAGS += -lole32 -luuid -lshlwapi
endif
e n d i f
2020-08-15 04:15:28 +00:00
i f n e q ( , $( findstring SDL 2,$ ( AUDIO_API ) $ ( WINDOW_API ) $ ( CONTROLLER_API ) ) )
SDL2_USED := 1
e n d i f
i f n e q ( , $( findstring SDL 1,$ ( AUDIO_API ) $ ( WINDOW_API ) $ ( CONTROLLER_API ) ) )
SDL1_USED := 1
2020-06-11 00:44:08 +00:00
e n d i f
2020-08-15 04:15:28 +00:00
i f e q ( $( SDL 1_USED ) $( SDL 2_USED ) , 1 1 )
$( error Cannot link both SDL1 and SDL2 at the same time )
2020-06-11 00:44:08 +00:00
e n d i f
# SDL can be used by different systems, so we consolidate all of that shit into this
2022-08-26 00:30:19 +00:00
2020-08-15 04:15:28 +00:00
i f e q ( $( SDL 2_USED ) , 1 )
SDLCONFIG := $( CROSS) sdl2-config
BACKEND_CFLAGS += -DHAVE_SDL2= 1
e l s e i f e q ( $( SDL 1_USED ) , 1 )
SDLCONFIG := $( CROSS) sdl-config
BACKEND_CFLAGS += -DHAVE_SDL1= 1
e n d i f
i f n e q ( $( SDL 1_USED ) $( SDL 2_USED ) , 0 0 )
2022-02-11 02:06:59 +00:00
ifeq ( $( OSX_BUILD) ,1)
# on OSX at least the homebrew version of sdl-config gives include path as `.../include/SDL2` instead of `.../include`
OSX_PREFIX := $( shell $( SDLCONFIG) --prefix)
BACKEND_CFLAGS += -I$( OSX_PREFIX) /include $( shell $( SDLCONFIG) --cflags)
else
BACKEND_CFLAGS += ` $( SDLCONFIG) --cflags`
endif
2022-08-26 00:30:19 +00:00
2020-06-11 00:44:08 +00:00
ifeq ( $( WINDOWS_BUILD) ,1)
2024-06-23 22:38:32 +00:00
BACKEND_LDFLAGS += ` $( SDLCONFIG) --static-libs` -lsetupapi -luser32 -limm32 -lole32 -loleaut32 -lshell32 -lshlwapi -lwinmm -lversion
2020-06-11 00:44:08 +00:00
else
BACKEND_LDFLAGS += ` $( SDLCONFIG) --libs`
endif
e n d i f
2022-03-13 08:17:10 +00:00
C_DEFINES := $( foreach d,$( DEFINES) ,-D$( d) )
DEF_INC_CFLAGS := $( foreach i,$( INCLUDE_DIRS) ,-I$( i) ) $( C_DEFINES)
# Check code syntax with host compiler
CC_CHECK := $( CC)
2020-05-07 18:21:22 +00:00
i f e q ( $( WINDOWS_BUILD ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS := -fsyntax-only -fsigned-char $( BACKEND_CFLAGS) $( DEF_INC_CFLAGS) -Wall -Wextra $( TARGET_CFLAGS) -DWINSOCK
CFLAGS := $( OPT_FLAGS) $( DEF_INC_CFLAGS) $( BACKEND_CFLAGS) $( TARGET_CFLAGS) -fno-strict-aliasing -fwrapv -DWINSOCK
2022-02-12 20:27:20 +00:00
ifeq ( $( TARGET_BITS) , 32)
BACKEND_LDFLAGS += -ldbghelp
endif
2022-03-13 08:17:10 +00:00
e l s e i f e q ( $( TARGET_N 64) , 0 ) # Linux / Other builds below
CC_CHECK_CFLAGS := -fsyntax-only -fsigned-char $( BACKEND_CFLAGS) $( DEF_INC_CFLAGS) -Wall -Wextra $( TARGET_CFLAGS)
CFLAGS := $( OPT_FLAGS) $( DEF_INC_CFLAGS) $( BACKEND_CFLAGS) $( TARGET_CFLAGS) -fno-strict-aliasing -fwrapv
e l s e # C compiler options for N64
CC_CHECK_CFLAGS := -fsyntax-only -fsigned-char $( CC_CFLAGS) $( TARGET_CFLAGS) -std= gnu90 -Wall -Wextra -Wno-main -DNON_MATCHING -DAVOID_UB $( DEF_INC_CFLAGS)
CFLAGS = -G 0 $( OPT_FLAGS) $( TARGET_CFLAGS) $( MIPSISET) $( DEF_INC_CFLAGS)
ifeq ( $( COMPILER) ,gcc)
CFLAGS += -mno-shared -march= vr4300 -mfix4300 -mabi= 32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra
else
CFLAGS += -non_shared -Wab,-r4300_mul -Xcpluscomm -Xfullwarn -signed -32
endif
e n d i f
2020-05-10 08:11:27 +00:00
2022-03-13 08:17:10 +00:00
i f e q ( $( TARGET_N 64) , 1 )
ASFLAGS := -march= vr4300 -mabi= 32 $( foreach i,$( INCLUDE_DIRS) ,-I$( i) ) $( foreach d,$( DEFINES) ,--defsym $( d) )
RSPASMFLAGS := $( foreach d,$( DEFINES) ,-definelabel $( subst = , ,$( d) ) )
2020-05-07 18:21:22 +00:00
e l s e
2022-03-13 08:17:10 +00:00
ASFLAGS := $( foreach i,$( INCLUDE_DIRS) ,-I$( i) ) $( foreach d,$( DEFINES) ,--defsym $( d) )
2022-08-26 00:30:19 +00:00
RSPASMFLAGS :=
2022-03-13 08:17:10 +00:00
e n d i f
# C preprocessor flags
CPPFLAGS := -P -Wno-trigraphs $( DEF_INC_CFLAGS)
2020-06-11 00:44:08 +00:00
2022-03-13 08:17:10 +00:00
i f e q ( $( TARGET_N 64) , 1 )
ifeq ( $( shell getconf LONG_BIT) , 32)
# Work around memory allocation bug in QEMU
export QEMU_GUEST_BASE := 1
else
# Ensure that gcc treats the code as 32-bit
CC_CHECK_CFLAGS += -m32
endif
2020-05-07 18:21:22 +00:00
e n d i f
2022-08-26 00:32:20 +00:00
i f e q ( $( WINDOWS_BUILD ) , 1 )
2024-03-09 16:59:28 +00:00
LDFLAGS := $( BITS) -march= $( TARGET_ARCH) -Llib -lpthread $( BACKEND_LDFLAGS) -static -mconsole
2022-03-13 08:17:10 +00:00
ifeq ( $( CROSS) ,)
LDFLAGS += -no-pie
endif
e l s e i f e q ( $( TARGET_RPI ) , 1 )
LDFLAGS := $( OPT_FLAGS) -lm $( BACKEND_LDFLAGS) -no-pie
e l s e i f e q ( $( OSX_BUILD ) , 1 )
LDFLAGS := -lm $( BACKEND_LDFLAGS) -lpthread
e l s e
LDFLAGS := $( BITS) -march= $( TARGET_ARCH) -lm $( BACKEND_LDFLAGS) -no-pie -lpthread
e n d i f
2024-03-19 09:48:48 +00:00
# used by crash handler and loading screen on linux
2023-05-02 02:49:42 +00:00
i f e q ( $( WINDOWS_BUILD ) , 0 )
2024-03-19 09:48:48 +00:00
LDFLAGS += -rdynamic -ldl -pthread
2023-05-02 02:49:42 +00:00
e n d i f
2022-05-22 04:11:17 +00:00
# icon
2022-05-19 23:33:17 +00:00
i f e q ( $( WINDOWS_BUILD ) , 1 )
2022-05-29 11:00:09 +00:00
ifeq ( $( ICON) ,1)
Command := mkdir -p " $( BUILD_DIR) /res "
2022-05-22 04:11:17 +00:00
Resp := $( shell $( call Command) )
2022-05-30 10:08:30 +00:00
Command := windres -o " $( BUILD_DIR) /res/icon.o " -i "res/icon.rc" --preprocessor $( word 1, $( CC) ) --preprocessor-arg -E --preprocessor-arg -xc-header --preprocessor-arg -DRC_INVOKED
2022-05-22 04:11:17 +00:00
Resp := $( shell $( call Command) )
ifeq ( $( .SHELLSTATUS) ,0)
LDFLAGS += $( BUILD_DIR) /res/icon.o
2022-05-29 11:00:09 +00:00
endif
endif
2022-05-19 23:33:17 +00:00
e n d i f
2023-05-11 20:05:06 +00:00
i f e q ( $( ASAN ) , 1 )
2023-05-15 22:55:16 +00:00
ifeq ( $( COMPILER) ,gcc)
EXTRA_CFLAGS += -fsanitize= address -fsanitize= bounds-strict -fsanitize= undefined -ggdb
EXTRA_CPP_FLAGS += -fsanitize= address -fsanitize= bounds-strict -fsanitize= undefined -ggdb
LDFLAGS += -fsanitize= address -fsanitize= bounds-strict -fsanitize= undefined -static-libasan
else ifeq ( $( COMPILER) ,clang)
EXTRA_CFLAGS += -fsanitize= address -fsanitize= undefined -ggdb
EXTRA_CPP_FLAGS += -fsanitize= address -fsanitize= undefined -ggdb
LDFLAGS += -fsanitize= address -fsanitize= undefined
endif
2023-05-11 20:05:06 +00:00
e n d i f
2022-03-13 08:17:10 +00:00
# Coop specific libraries
2022-06-25 07:52:53 +00:00
# Zlib
LDFLAGS += -lz
2024-03-07 22:33:43 +00:00
# Update checker library
i f e q ( $( WINDOWS_BUILD ) , 1 )
LDFLAGS += -lwininet
e l s e
LDFLAGS += -lcurl
e n d i f
2022-03-13 08:17:10 +00:00
# Lua
i f e q ( $( WINDOWS_BUILD ) , 1 )
ifeq ( $( TARGET_BITS) , 32)
LDFLAGS += -Llib/lua/win32 -l:liblua53.a
else
LDFLAGS += -Llib/lua/win64 -l:liblua53.a
endif
e l s e i f e q ( $( OSX_BUILD ) , 1 )
2023-10-28 07:19:00 +00:00
ifeq ( $( shell uname -m) ,arm64)
LDFLAGS += -L./lib/lua/mac_arm/ -l lua53
else
LDFLAGS += -L./lib/lua/mac_intel/ -l lua53
endif
2022-06-06 02:40:21 +00:00
e l s e i f e q ( $( TARGET_RPI ) , 1 )
2022-09-13 03:00:51 +00:00
ifneq ( ,$( findstring aarch64,$( machine) ) )
LDFLAGS += -Llib/lua/linux -l:liblua53-arm64.a
else
LDFLAGS += -Llib/lua/linux -l:liblua53-arm.a
endif
2022-03-13 08:17:10 +00:00
e l s e
2023-03-26 21:53:01 +00:00
LDFLAGS += -Llib/lua/linux -l:liblua53.a -ldl
2022-03-13 08:17:10 +00:00
e n d i f
2024-03-07 22:33:43 +00:00
# CoopNet
2023-04-29 07:23:40 +00:00
COOPNET_LIBS :=
2023-04-10 06:45:52 +00:00
i f e q ( $( COOPNET ) , 1 )
2023-04-11 02:45:06 +00:00
ifeq ( $( WINDOWS_BUILD) ,1)
ifeq ( $( TARGET_BITS) , 32)
2023-06-14 08:38:19 +00:00
LDFLAGS += -Llib/coopnet/win32 -l:libcoopnet.a -l:libjuice.a -lbcrypt -lws2_32 -liphlpapi
2023-04-11 02:45:06 +00:00
else
2023-06-14 08:38:19 +00:00
LDFLAGS += -Llib/coopnet/win64 -l:libcoopnet.a -l:libjuice.a -lbcrypt -lws2_32 -liphlpapi
2023-04-11 02:45:06 +00:00
endif
else ifeq ( $( OSX_BUILD) ,1)
2023-10-28 07:19:00 +00:00
ifeq ( $( shell uname -m) ,arm64)
LDFLAGS += -Wl,-rpath,@loader_path -L./lib/coopnet/mac_arm/ -l coopnet
COOPNET_LIBS += ./lib/coopnet/mac_arm/libcoopnet.dylib
COOPNET_LIBS += ./lib/coopnet/mac_arm/libjuice.1.2.2.dylib
else
LDFLAGS += -Wl,-rpath,@loader_path -L./lib/coopnet/mac_intel/ -l coopnet
COOPNET_LIBS += ./lib/coopnet/mac_intel/libcoopnet.dylib
COOPNET_LIBS += ./lib/coopnet/mac_intel/libjuice.1.2.2.dylib
endif
2023-04-11 02:45:06 +00:00
else ifeq ( $( TARGET_RPI) ,1)
ifneq ( ,$( findstring aarch64,$( machine) ) )
2023-04-11 03:00:18 +00:00
LDFLAGS += -Llib/coopnet/linux -l:libcoopnet-arm64.a -l:libjuice.a
2023-04-11 02:45:06 +00:00
else
2023-04-11 03:00:18 +00:00
LDFLAGS += -Llib/coopnet/linux -l:libcoopnet-arm.a -l:libjuice.a
2023-04-11 02:45:06 +00:00
endif
else
LDFLAGS += -Llib/coopnet/linux -l:libcoopnet.a -l:libjuice.a
endif
2023-04-10 06:45:52 +00:00
e n d i f
2023-04-10 00:20:07 +00:00
2024-03-23 20:14:53 +00:00
# Network/Discord (ugh, needs cleanup)
2022-03-13 08:17:10 +00:00
i f e q ( $( WINDOWS_BUILD ) , 1 )
LDFLAGS += -L"ws2_32" -lwsock32
ifeq ( $( DISCORD_SDK) ,1)
2024-03-23 20:14:53 +00:00
LDFLAGS += -Wl,-Bdynamic -L./lib/discordsdk/ -ldiscord_game_sdk -Wl,-Bstatic
2022-03-13 08:17:10 +00:00
endif
e l s e
ifeq ( $( DISCORD_SDK) ,1)
2024-03-23 20:14:53 +00:00
LDFLAGS += -ldiscord_game_sdk -Wl,-rpath . -Wl,-rpath lib/discordsdk
2022-03-13 08:17:10 +00:00
endif
e n d i f
2022-05-09 00:01:19 +00:00
2022-03-13 08:17:10 +00:00
# Prevent a crash with -sopt
export LANG := C
2024-07-02 18:26:00 +00:00
i f e q ( $( OSX_BUILD ) , 0 )
LDFLAGS += -latomic
e n d i f
2024-03-23 20:11:30 +00:00
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Extra CC Flags #
#==============================================================================#
2020-09-04 09:04:37 +00:00
# Enforce -Werror in strict mode
i f e q ( $( STRICT ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -Werror
2021-08-20 01:16:16 +00:00
CFLAGS += -Werror
2020-09-04 08:55:54 +00:00
e n d i f
2020-05-13 21:33:12 +00:00
2020-09-02 05:06:36 +00:00
# Check for debug option
i f e q ( $( DEBUG ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -DDEBUG
2020-09-02 05:06:36 +00:00
CFLAGS += -DDEBUG
e n d i f
2020-09-04 08:55:54 +00:00
# Check for enhancement options
2020-09-05 00:02:09 +00:00
# Check for docker build workaround option
i f e q ( $( DOCKERBUILD ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -DDOCKERBUILD
2020-09-05 00:02:09 +00:00
CFLAGS += -DDOCKERBUILD
e n d i f
2020-09-19 07:51:40 +00:00
# Check for Discord SDK option
i f e q ( $( DISCORD_SDK ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -DDISCORD_SDK
2020-09-19 07:51:40 +00:00
CFLAGS += -DDISCORD_SDK
e n d i f
2023-04-10 08:10:24 +00:00
# Check for COOPNET option
i f e q ( $( COOPNET ) , 1 )
CC_CHECK_CFLAGS += -DCOOPNET
CFLAGS += -DCOOPNET
e n d i f
2020-09-19 09:12:49 +00:00
# Check for development option
i f e q ( $( DEVELOPMENT ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -DDEVELOPMENT
2020-09-19 09:12:49 +00:00
CFLAGS += -DDEVELOPMENT
e n d i f
2022-06-06 02:40:21 +00:00
# Check for rpi option
i f e q ( $( TARGET_RPI ) , 1 )
CC_CHECK_CFLAGS += -DTARGET_RPI
CFLAGS += -DTARGET_RPI
e n d i f
2020-05-16 12:41:57 +00:00
# Check for texture fix option
i f e q ( $( TEXTURE_FIX ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -DTEXTURE_FIX
2020-05-13 21:33:12 +00:00
CFLAGS += -DTEXTURE_FIX
e n d i f
2023-11-11 17:15:32 +00:00
# Check for enhance level textures option
i f e q ( $( ENHANCE_LEVEL_TEXTURES ) , 1 )
CC_CHECK_CFLAGS += -DENHANCE_LEVEL_TEXTURES
CFLAGS += -DENHANCE_LEVEL_TEXTURES
e n d i f
2024-07-01 16:28:42 +00:00
# Check for handheld option
i f e q ( $( HANDHELD ) , 1 )
CC_CHECK_CFLAGS += -DHANDHELD
CFLAGS += -DHANDHELD
e n d i f
2020-05-19 13:32:01 +00:00
# Check for no bzero/bcopy workaround option
i f e q ( $( NO_BZERO_BCOPY ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -DNO_BZERO_BCOPY
2020-05-19 13:32:01 +00:00
CFLAGS += -DNO_BZERO_BCOPY
e n d i f
2020-05-19 19:22:52 +00:00
# Use internal ldiv()/lldiv()
i f e q ( $( NO_LDIV ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -DNO_LDIV
2020-05-19 19:22:52 +00:00
CFLAGS += -DNO_LDIV
e n d i f
2020-05-20 03:58:35 +00:00
# Use OpenGL 1.3
i f e q ( $( LEGACY_GL ) , 1 )
2022-03-13 08:17:10 +00:00
CC_CHECK_CFLAGS += -DLEGACY_GL
2020-05-20 03:58:35 +00:00
CFLAGS += -DLEGACY_GL
e n d i f
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Miscellaneous Tools #
#==============================================================================#
# N64 tools
MIO0TOOL := $( TOOLS_DIR) /mio0
N64CKSUM := $( TOOLS_DIR) /n64cksum
N64GRAPHICS := $( TOOLS_DIR) /n64graphics
N64GRAPHICS_CI := $( TOOLS_DIR) /n64graphics_ci
TEXTCONV := $( TOOLS_DIR) /textconv
AIFF_EXTRACT_CODEBOOK := $( TOOLS_DIR) /aiff_extract_codebook
VADPCM_ENC := $( TOOLS_DIR) /vadpcm_enc
EXTRACT_DATA_FOR_MIO := $( TOOLS_DIR) /extract_data_for_mio
SKYCONV := $( TOOLS_DIR) /skyconv
2023-04-10 04:43:45 +00:00
2022-03-13 08:17:10 +00:00
# Use the system installed armips if available. Otherwise use the one provided with this repository.
i f n e q ( , $( call find -command ,armips ) )
RSPASM := armips
2020-05-16 19:30:27 +00:00
e l s e
2022-03-13 08:17:10 +00:00
RSPASM := $( TOOLS_DIR) /armips
2020-09-13 04:16:10 +00:00
e n d i f
2022-03-13 08:17:10 +00:00
ENDIAN_BITWIDTH := $( BUILD_DIR) /endian-and-bitwidth
2019-08-25 04:46:40 +00:00
EMULATOR = mupen64plus
EMU_FLAGS = --noosd
LOADER = loader64
LOADER_FLAGS = -vwf
SHA1SUM = sha1sum
2022-03-13 08:17:10 +00:00
PRINT = printf
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
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
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
# Use Objcopy instead of extract_data_for_mio
i f e q ( $( COMPILER ) , g c c )
EXTRACT_DATA_FOR_MIO := $( OBJCOPY) -O binary --only-section= .data
e n d i f
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
# 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
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Main Targets #
#==============================================================================#
2020-06-02 19:37:43 +00:00
2022-03-13 08:17:10 +00:00
#all: $(ROM)
all : $( EXE )
2022-03-19 04:31:04 +00:00
i f e q ( $( WINDOWS_BUILD ) , 1 )
exemap : $( EXE )
$( V) $( OBJDUMP) -t $( EXE) > $( BUILD_DIR) /coop.map
all : exemap
e n d i f
2019-08-25 04:46:40 +00:00
clean :
$( RM) -r $( BUILD_DIR_BASE)
2022-06-06 02:11:58 +00:00
2020-05-07 18:21:22 +00:00
cleantools :
2022-03-13 08:17:10 +00:00
$( MAKE) -s -C $( TOOLS_DIR) clean
2020-05-07 18:21:22 +00:00
2022-08-26 00:30:19 +00:00
distclean : clean cleantools
2022-03-13 08:17:10 +00:00
$( PYTHON) extract_assets.py --clean
2022-08-26 00:30:19 +00:00
2019-08-25 04:46:40 +00:00
test : $( ROM )
$( EMULATOR) $( EMU_FLAGS) $<
load : $( ROM )
$( LOADER) $( LOADER_FLAGS) $<
2022-03-13 08:17:10 +00:00
libultra : $( BUILD_DIR ) /libultra .a
2020-06-09 15:15:49 +00:00
$(BUILD_DIR)/$(RPC_LIBS) :
@$( CP) -f $( RPC_LIBS) $( BUILD_DIR)
2022-08-26 00:30:19 +00:00
2020-09-13 04:16:10 +00:00
$(BUILD_DIR)/$(DISCORD_SDK_LIBS) :
@$( CP) -f $( DISCORD_SDK_LIBS) $( BUILD_DIR)
2023-04-29 07:23:40 +00:00
$(BUILD_DIR)/$(COOPNET_LIBS) :
@$( CP) -f $( COOPNET_LIBS) $( BUILD_DIR)
2023-03-31 22:18:19 +00:00
$(BUILD_DIR)/$(LANG_DIR) :
@$( CP) -f -r $( LANG_DIR) $( BUILD_DIR)
2022-01-17 02:07:45 +00:00
$(BUILD_DIR)/$(MOD_DIR) :
2023-12-18 21:22:42 +00:00
$( CP) -f -r $( MOD_DIR) $( BUILD_DIR)
2022-01-17 02:07:45 +00:00
2024-05-19 13:38:22 +00:00
$(BUILD_DIR)/$(PALETTES_DIR) :
@$( CP) -f -r $( PALETTES_DIR) $( BUILD_DIR)
2022-03-13 08:17:10 +00:00
# Extra object file dependencies
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
i f e q ( $( TARGET_N 64) , 1 )
$( BUILD_DIR) /asm/boot.o: $( IPL3_RAW_FILES)
$( BUILD_DIR) /src/game/crash_screen.o: $( CRASH_TEXTURE_C_FILES)
$( BUILD_DIR) /lib/rsp.o: $( BUILD_DIR) /rsp/rspboot.bin $( BUILD_DIR) /rsp/fast3d.bin $( BUILD_DIR) /rsp/audio.bin
e n d i f
2019-08-25 04:46:40 +00:00
Fixed various audio bugs; DynOS can now detect texture duplicates to decrease generated bin files size (#110)
Fixed the following audio bugs:
Bug: Rom-hacks sequences don't seem to be affected by volume scaling and
muting
Fix: Force the BGM sequences to follow the vanilla behavior:
Volume can't go higher than default volume
Volume is reduced to 31% when the game is paused
Audio is stopped when the game is paused outside the Castle levels
Bug: (Pointed out by Draco) Mario's voice clips are not replaced by the
player's character's in the following instances: fall to death
barrier, "here we go" in the ending cutscene, "let's a go"
after selecting a star, "okey dokey" after starting the game.
Fix: The first two ones now call
play_character_sound(m, CHAR_SOUND_...) instead of
play_sound(SOUND_MARIO_..., pos). The last two ones couldn't be
fixed the same way for two reasons: First, the corresponding sounds
were not referenced in the sound table, second, the sound played is
always cut-off after a few frames (due to how sm64 resets the sound
banks after loading a level).
Added SOUND_*_LETS_A_GO and SOUND_*_OKEY_DOKEY sounds for each playable
character as Bass samples.
Character Bass sounds work the same way as vanilla sounds (i.e. can be
played with play_character_sound), but they cannot be prematurely stopped
by sm64 sound banks shenanigans.
This fixes the cut-off for both the star select and the castle grounds
entry, plays the sound corresponding to the player's character, and doesn't
need to extend or edit the sound table.
DynOS can detect texture duplicates when generating a bin or lvl file.
When a duplicate is detected, the name of the original texture node is
written instead of the whole PNG data, decreasing significantly the
resulting file size.
2022-05-19 23:40:45 +00:00
$(BUILD_DIR)/src/game/characters.o : $( SOUND_SAMPLE_TABLES )
2022-03-13 08:17:10 +00:00
$(SOUND_BIN_DIR)/sound_data.o : $( SOUND_BIN_DIR ) /sound_data .ctl .inc .c $( SOUND_BIN_DIR ) /sound_data .tbl .inc .c $( SOUND_BIN_DIR ) /sequences .bin .inc .c $( SOUND_BIN_DIR ) /bank_sets .inc .c
2024-03-23 20:11:30 +00:00
$(SOUND_BIN_DIR)/samples_assets.o : $( SOUND_BIN_DIR ) /samples_offsets .inc .c
$(SOUND_BIN_DIR)/sequences_assets.o : $( SOUND_BIN_DIR ) /sequences_offsets .inc .c
2022-03-13 08:17:10 +00:00
$(BUILD_DIR)/levels/scripts.o : $( BUILD_DIR ) /include /level_headers .h
2020-05-10 08:11:27 +00:00
2022-03-13 08:17:10 +00:00
i f e q ( $( VERSION ) , s h )
$( BUILD_DIR) /src/audio/load.o: $( SOUND_BIN_DIR) /bank_sets.inc.c $( SOUND_BIN_DIR) /sequences_header.inc.c $( SOUND_BIN_DIR) /ctl_header.inc.c $( SOUND_BIN_DIR) /tbl_header.inc.c
e n d i f
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
$(CRASH_TEXTURE_C_FILES) : TEXTURE_ENCODING := u 32
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
i f e q ( $( COMPILER ) , g c c )
$( BUILD_DIR) /lib/src/math/%.o: CFLAGS += -fno-builtin
e n d i f
2019-10-05 19:08:05 +00:00
2019-08-25 04:46:40 +00:00
i f e q ( $( VERSION ) , e u )
2022-03-13 08:17:10 +00:00
TEXT_DIRS := text/de text/us text/fr
# EU encoded text inserted into individual segment 0x19 files,
# and course data also duplicated in leveldata.c
$( BUILD_DIR) /bin/eu/translation_en.o: $( BUILD_DIR) /text/us/define_text.inc.c
$( BUILD_DIR) /bin/eu/translation_de.o: $( BUILD_DIR) /text/de/define_text.inc.c
$( BUILD_DIR) /bin/eu/translation_fr.o: $( BUILD_DIR) /text/fr/define_text.inc.c
$( BUILD_DIR) /levels/menu/leveldata.o: $( BUILD_DIR) /text/us/define_courses.inc.c
$( BUILD_DIR) /levels/menu/leveldata.o: $( BUILD_DIR) /text/de/define_courses.inc.c
$( BUILD_DIR) /levels/menu/leveldata.o: $( BUILD_DIR) /text/fr/define_courses.inc.c
2023-05-03 07:54:25 +00:00
$( BUILD_DIR) /src/game/level_info.o: $( BUILD_DIR) /text/us/define_courses.inc.c
$( BUILD_DIR) /src/game/level_info.o: $( BUILD_DIR) /text/de/define_courses.inc.c
$( BUILD_DIR) /src/game/level_info.o: $( BUILD_DIR) /text/fr/define_courses.inc.c
2023-11-27 02:04:10 +00:00
2023-05-03 07:54:25 +00:00
O_FILES += $( BUILD_DIR) /bin/eu/translation_en.o $( BUILD_DIR) /bin/eu/translation_de.o $( BUILD_DIR) /bin/eu/translation_fr.o
2020-03-02 03:42:52 +00:00
e l s e
2022-03-13 08:17:10 +00:00
ifeq ( $( VERSION) ,sh)
TEXT_DIRS := text/jp
$( BUILD_DIR) /bin/segment2.o: $( BUILD_DIR) /text/jp/define_text.inc.c
else
TEXT_DIRS := text/$( VERSION)
# non-EU encoded text inserted into segment 0x02
$( BUILD_DIR) /bin/segment2.o: $( BUILD_DIR) /text/$( VERSION) /define_text.inc.c
endif
2020-03-02 03:42:52 +00:00
e n d i f
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
ALL_DIRS := $( BUILD_DIR) $( addprefix $( BUILD_DIR) /,$( SRC_DIRS) $( GODDARD_SRC_DIRS) $( ULTRA_SRC_DIRS) $( ULTRA_BIN_DIRS) $( BIN_DIRS) $( TEXTURE_DIRS) $( TEXT_DIRS) $( SOUND_SAMPLE_DIRS) $( addprefix levels/,$( LEVEL_DIRS) ) rsp include) $( MIO0_DIR) $( addprefix $( MIO0_DIR) /,$( VERSION) ) $( SOUND_BIN_DIR) $( SOUND_BIN_DIR) /sequences/$( VERSION)
2019-08-25 04:46:40 +00:00
# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $( ALL_DIRS)
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Texture Generation #
#==============================================================================#
TEXTURE_ENCODING := u8
2020-06-02 16:44:34 +00:00
2023-11-02 00:17:55 +00:00
# Convert PNGs to RGBA32, RGBA16, IA16, IA8, IA4, IA1, I8, I4 binary files
$(BUILD_DIR)/% : %.png
2022-03-13 08:17:10 +00:00
$( call print,Converting:,$<,$@ )
$( V) $( N64GRAPHICS) -s raw -i $@ -g $< -f $( lastword $( subst ., ,$@ ) )
2022-08-26 00:30:19 +00:00
2023-11-02 00:17:55 +00:00
$(BUILD_DIR)/%.inc.c : %.png
2022-03-13 08:17:10 +00:00
$( call print,Converting:,$<,$@ )
$( V) $( N64GRAPHICS) -s $( TEXTURE_ENCODING) -i $@ -g $< -f $( lastword ,$( subst ., ,$( basename $<) ) )
2020-06-02 16:44:34 +00:00
2023-11-02 00:17:55 +00:00
# Color Index CI8
$(BUILD_DIR)/%.ci8 : %.ci 8.png
2022-03-13 08:17:10 +00:00
$( call print,Converting:,$<,$@ )
$( V) $( N64GRAPHICS_CI) -i $@ -g $< -f ci8
2020-06-02 16:44:34 +00:00
2023-11-02 00:17:55 +00:00
# Color Index CI4
$(BUILD_DIR)/%.ci4 : %.ci 4.png
2022-03-13 08:17:10 +00:00
$( call print,Converting:,$<,$@ )
$( V) $( N64GRAPHICS_CI) -i $@ -g $< -f ci4
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Compressed Segment Generation #
#==============================================================================#
2019-11-03 19:36:27 +00:00
2022-03-13 08:17:10 +00:00
i f e q ( $( TARGET_N 64) , 1 )
# Link segment file to resolve external labels
# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address
$(BUILD_DIR)/%.elf : $( BUILD_DIR ) /%.o
$( call print,Linking ELF file:,$<,$@ )
2022-04-20 01:18:15 +00:00
$( V) $( LD) $( PROF_FLAGS) -e 0 -Ttext= $( SEGMENT_ADDRESS) -Map $@ .map -o $@ $<
2022-03-13 08:17:10 +00:00
# Override for leveldata.elf, which otherwise matches the above pattern
.SECONDEXPANSION :
$(BUILD_DIR)/levels/%/leveldata.elf : $( BUILD_DIR ) /levels /%/leveldata .o $( BUILD_DIR ) /bin /$$( TEXTURE_BIN ) .elf
$( call print,Linking ELF file:,$<,$@ )
2022-04-20 01:18:15 +00:00
$( V) $( LD) $( PROF_FLAGS) -e 0 -Ttext= $( SEGMENT_ADDRESS) -Map $@ .map --just-symbols= $( BUILD_DIR) /bin/$( TEXTURE_BIN) .elf -o $@ $<
2020-06-02 16:44:34 +00:00
2022-03-13 08:17:10 +00:00
$(BUILD_DIR)/%.bin : $( BUILD_DIR ) /%.elf
$( call print,Extracting compressionable data from:,$<,$@ )
$( V) $( EXTRACT_DATA_FOR_MIO) $< $@
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
$(BUILD_DIR)/levels/%/leveldata.bin : $( BUILD_DIR ) /levels /%/leveldata .elf
$( call print,Extracting compressionable data from:,$<,$@ )
$( V) $( EXTRACT_DATA_FOR_MIO) $< $@
2020-06-02 16:44:34 +00:00
2022-03-13 08:17:10 +00:00
# Compress binary file
$(BUILD_DIR)/%.mio0 : $( BUILD_DIR ) /%.bin
$( call print,Compressing:,$<,$@ )
$( V) $( MIO0TOOL) $< $@
# convert binary mio0 to object file
$(BUILD_DIR)/%.mio0.o : $( BUILD_DIR ) /%.mio 0
$( call print,Converting MIO0 to ELF:,$<,$@ )
$( V) printf " .section .data\n\n.incbin \" $<\"\n " | $( AS) $( ASFLAGS) -o $@
2022-08-26 00:30:19 +00:00
2020-05-25 01:21:36 +00:00
e n d i f
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Sound File Generation #
#==============================================================================#
2019-08-25 04:46:40 +00:00
$(BUILD_DIR)/%.table : %.aiff
2022-03-13 08:17:10 +00:00
$( call print,Extracting codebook:,$<,$@ )
2023-04-10 01:35:13 +00:00
$( V) $( AIFF_EXTRACT_CODEBOOK) $< >$@
Fixed various audio bugs; DynOS can now detect texture duplicates to decrease generated bin files size (#110)
Fixed the following audio bugs:
Bug: Rom-hacks sequences don't seem to be affected by volume scaling and
muting
Fix: Force the BGM sequences to follow the vanilla behavior:
Volume can't go higher than default volume
Volume is reduced to 31% when the game is paused
Audio is stopped when the game is paused outside the Castle levels
Bug: (Pointed out by Draco) Mario's voice clips are not replaced by the
player's character's in the following instances: fall to death
barrier, "here we go" in the ending cutscene, "let's a go"
after selecting a star, "okey dokey" after starting the game.
Fix: The first two ones now call
play_character_sound(m, CHAR_SOUND_...) instead of
play_sound(SOUND_MARIO_..., pos). The last two ones couldn't be
fixed the same way for two reasons: First, the corresponding sounds
were not referenced in the sound table, second, the sound played is
always cut-off after a few frames (due to how sm64 resets the sound
banks after loading a level).
Added SOUND_*_LETS_A_GO and SOUND_*_OKEY_DOKEY sounds for each playable
character as Bass samples.
Character Bass sounds work the same way as vanilla sounds (i.e. can be
played with play_character_sound), but they cannot be prematurely stopped
by sm64 sound banks shenanigans.
This fixes the cut-off for both the star select and the castle grounds
entry, plays the sound corresponding to the player's character, and doesn't
need to extend or edit the sound table.
DynOS can detect texture duplicates when generating a bin or lvl file.
When a duplicate is detected, the name of the original texture node is
written instead of the whole PNG data, decreasing significantly the
resulting file size.
2022-05-19 23:40:45 +00:00
$( call print,Piping:,$<,$@ .inc.c)
2019-08-25 04:46:40 +00:00
$(BUILD_DIR)/%.aifc : $( BUILD_DIR ) /%.table %.aiff
2022-03-13 08:17:10 +00:00
$( call print,Encoding VADPCM:,$<,$@ )
$( V) $( VADPCM_ENC) -c $^ $@
2020-06-02 16:44:34 +00:00
2022-03-13 08:17:10 +00:00
$(ENDIAN_BITWIDTH) : $( TOOLS_DIR ) /determine -endian -bitwidth .c
@$( PRINT) " $( GREEN) Generating endian-bitwidth $( NO_COL) \n "
2022-04-20 04:20:08 +00:00
$( V) $( CC) $( PROF_FLAGS) -c $( CFLAGS) -o $@ .dummy2 $< 2>$@ .dummy1; true
2022-03-13 08:17:10 +00:00
$( V) grep -o 'msgbegin --endian .* --bitwidth .* msgend' $@ .dummy1 > $@ .dummy2
$( V) head -n1 <$@ .dummy2 | cut -d' ' -f2-5 > $@
@$( RM) $@ .dummy1
@$( RM) $@ .dummy2
2019-12-02 02:52:53 +00:00
$(SOUND_BIN_DIR)/sound_data.ctl : sound /sound_banks / $( SOUND_BANK_FILES ) $( SOUND_SAMPLE_AIFCS ) $( ENDIAN_BITWIDTH )
2022-03-13 08:17:10 +00:00
@$( PRINT) " $( GREEN) Generating: $( BLUE) $@ $( NO_COL) \n "
$( V) $( PYTHON) $( TOOLS_DIR) /assemble_sound.py $( BUILD_DIR) /sound/samples/ sound/sound_banks/ $( SOUND_BIN_DIR) /sound_data.ctl $( SOUND_BIN_DIR) /ctl_header $( SOUND_BIN_DIR) /sound_data.tbl $( SOUND_BIN_DIR) /tbl_header $( C_DEFINES) $$ ( cat $( ENDIAN_BITWIDTH) )
2019-08-25 04:46:40 +00:00
$(SOUND_BIN_DIR)/sound_data.tbl : $( SOUND_BIN_DIR ) /sound_data .ctl
2019-12-02 02:52:53 +00:00
@true
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
$(SOUND_BIN_DIR)/ctl_header : $( SOUND_BIN_DIR ) /sound_data .ctl
@true
2019-09-01 19:50:50 +00:00
2022-03-13 08:17:10 +00:00
$(SOUND_BIN_DIR)/tbl_header : $( SOUND_BIN_DIR ) /sound_data .ctl
2019-12-02 02:52:53 +00:00
@true
2019-08-25 04:46:40 +00:00
2024-03-23 20:11:30 +00:00
$(SOUND_BIN_DIR)/samples_offsets.inc.c : $( SOUND_BIN_DIR ) /sound_data .ctl
@true
$(SOUND_BIN_DIR)/sequences_offsets.inc.c : $( SOUND_BIN_DIR ) /sound_data .ctl
@true
2022-03-13 08:17:10 +00:00
$(SOUND_BIN_DIR)/sequences.bin : $( SOUND_BANK_FILES ) sound /sequences .json $( SOUND_SEQUENCE_DIRS ) $( SOUND_SEQUENCE_FILES ) $( ENDIAN_BITWIDTH )
@$( PRINT) " $( GREEN) Generating: $( BLUE) $@ $( NO_COL) \n "
$( V) $( PYTHON) $( TOOLS_DIR) /assemble_sound.py --sequences $@ $( SOUND_BIN_DIR) /sequences_header $( SOUND_BIN_DIR) /bank_sets sound/sound_banks/ sound/sequences.json $( SOUND_SEQUENCE_FILES) $( C_DEFINES) $$ ( cat $( ENDIAN_BITWIDTH) )
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
$(SOUND_BIN_DIR)/bank_sets : $( SOUND_BIN_DIR ) /sequences .bin
@true
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
$(SOUND_BIN_DIR)/sequences_header : $( SOUND_BIN_DIR ) /sequences .bin
@true
2020-06-01 09:13:05 +00:00
2022-03-13 08:17:10 +00:00
$(SOUND_BIN_DIR)/%.m64 : $( SOUND_BIN_DIR ) /%.o
$( call print,Converting to M64:,$<,$@ )
$( V) $( OBJCOPY) -j .rodata $< -O binary $@
2020-06-01 09:13:05 +00:00
2020-05-10 08:11:27 +00:00
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Generated Source Code Files #
#==============================================================================#
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
# Convert binary file to a comma-separated list of byte values for inclusion in C code
$(BUILD_DIR)/%.inc.c : $( BUILD_DIR ) /%
$( call print,Piping:,$<,$@ )
$( V) hexdump -v -e '1/1 "0x%X,"' $< > $@
$( V) echo >> $@
2019-12-02 02:52:53 +00:00
2022-03-13 08:17:10 +00:00
# Generate animation data
2019-11-03 19:36:27 +00:00
$(BUILD_DIR)/assets/mario_anim_data.c : $( wildcard assets /anims /*.inc .c )
2022-03-13 08:17:10 +00:00
@$( PRINT) " $( GREEN) Generating animation data $( NO_COL) \n "
$( V) $( PYTHON) $( TOOLS_DIR) /mario_anims_converter.py > $@
2019-11-03 19:36:27 +00:00
2022-03-13 08:17:10 +00:00
# Generate demo input data
2019-11-03 19:36:27 +00:00
$(BUILD_DIR)/assets/demo_data.c : assets /demo_data .json $( wildcard assets /demos /*.bin )
2022-03-13 08:17:10 +00:00
@$( PRINT) " $( GREEN) Generating demo data $( NO_COL) \n "
$( V) $( PYTHON) $( TOOLS_DIR) /demo_data_converter.py assets/demo_data.json $( DEF_INC_CFLAGS) > $@
2020-06-02 16:44:34 +00:00
2022-03-13 08:17:10 +00:00
# Encode in-game text strings
$(BUILD_DIR)/text/%/define_courses.inc.c : text /define_courses .inc .c text /%/courses .h
@$( PRINT) " $( GREEN) Preprocessing: $( BLUE) $@ $( NO_COL) \n "
2022-04-20 01:18:15 +00:00
$( V) $( CPP) $( PROF_FLAGS) $( CPPFLAGS) $< -o - -I text/$* / | $( TEXTCONV) charmap.txt - $@
2022-03-13 08:17:10 +00:00
$(BUILD_DIR)/text/%/define_text.inc.c : text /define_text .inc .c text /%/courses .h text /%/dialogs .h
@$( PRINT) " $( GREEN) Preprocessing: $( BLUE) $@ $( NO_COL) \n "
2022-04-20 01:18:15 +00:00
$( V) $( CPP) $( PROF_FLAGS) $( CPPFLAGS) $< -o - -I text/$* / | $( TEXTCONV) charmap.txt - $@
2020-06-02 16:44:34 +00:00
2022-03-13 08:17:10 +00:00
# Level headers
$(BUILD_DIR)/include/level_headers.h : levels /level_headers .h .in
$( call print,Preprocessing level headers:,$<,$@ )
2022-04-20 01:18:15 +00:00
$( V) $( CPP) $( PROF_FLAGS) $( CPPFLAGS) -I . levels/level_headers.h.in | $( PYTHON) $( TOOLS_DIR) /output_level_headers.py > $( BUILD_DIR) /include/level_headers.h
2020-06-02 16:44:34 +00:00
2022-03-13 08:17:10 +00:00
# Run asm_processor on files that have NON_MATCHING code
i f e q ( $( NON_MATCHING ) , 0 )
$(GLOBAL_ASM_O_FILES) : CC := $( V ) $( PYTHON ) $( TOOLS_DIR ) /asm_processor /build .py $( CC ) -- $( AS ) $( ASFLAGS ) --
2019-08-25 04:46:40 +00:00
e n d i f
2019-12-02 02:52:53 +00:00
# Rebuild files with 'GLOBAL_ASM' if the NON_MATCHING flag changes.
$(GLOBAL_ASM_O_FILES) : $( GLOBAL_ASM_DEP ) .$( NON_MATCHING )
$(GLOBAL_ASM_DEP).$(NON_MATCHING) :
2022-03-13 08:17:10 +00:00
@$( RM) $( GLOBAL_ASM_DEP) .*
$( V) touch $@
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
#==============================================================================#
# Compilation Recipes #
#==============================================================================#
# Compile C++ code
2020-05-07 18:21:22 +00:00
$(BUILD_DIR)/%.o : %.cpp
2022-03-13 08:17:10 +00:00
$( call print,Compiling:,$<,$@ )
2023-04-30 01:14:44 +00:00
$( V) $( CXX) $( PROF_FLAGS) -fsyntax-only $( EXTRA_CPP_FLAGS) $( EXTRA_CPP_INCLUDES) $( CFLAGS) -MMD -MP -MT $@ -MF $( BUILD_DIR) /$* .d $<
2022-04-20 01:18:15 +00:00
$( V) $( CXX) $( PROF_FLAGS) -c $( EXTRA_CPP_FLAGS) $( EXTRA_CPP_INCLUDES) $( CFLAGS) -o $@ $<
2020-05-07 18:21:22 +00:00
2022-03-13 08:17:10 +00:00
# Compile C code
2019-08-25 04:46:40 +00:00
$(BUILD_DIR)/%.o : %.c
2022-03-13 08:17:10 +00:00
$( call print,Compiling:,$<,$@ )
2023-04-30 01:14:44 +00:00
$( V) $( CC_CHECK) $( PROF_FLAGS) $( CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $( BUILD_DIR) /$* .d $<
2022-04-20 04:20:08 +00:00
$( V) $( CC) $( PROF_FLAGS) -c $( CFLAGS) -o $@ $<
2019-11-03 19:36:27 +00:00
$(BUILD_DIR)/%.o : $( BUILD_DIR ) /%.c
2022-03-13 08:17:10 +00:00
$( call print,Compiling:,$<,$@ )
2023-04-30 01:14:44 +00:00
$( V) $( CC_CHECK) $( PROF_FLAGS) $( CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $( BUILD_DIR) /$* .d $<
2022-04-20 04:20:08 +00:00
$( V) $( CC) $( PROF_FLAGS) -c $( CFLAGS) -o $@ $<
2022-03-13 08:17:10 +00:00
# Alternate compiler flags needed for matching
i f e q ( $( COMPILER ) , i d o )
$( BUILD_DIR) /levels/%/leveldata.o: OPT_FLAGS := -g
$( BUILD_DIR) /actors/%.o: OPT_FLAGS := -g
$( BUILD_DIR) /bin/%.o: OPT_FLAGS := -g
$( BUILD_DIR) /src/goddard/%.o: OPT_FLAGS := -g
$( BUILD_DIR) /src/goddard/%.o: MIPSISET := -mips1
$( BUILD_DIR) /lib/src/%.o: OPT_FLAGS :=
$( BUILD_DIR) /lib/src/math/%.o: OPT_FLAGS := -O2
$( BUILD_DIR) /lib/src/math/ll%.o: OPT_FLAGS :=
$( BUILD_DIR) /lib/src/math/ll%.o: MIPSISET := -mips3 -32
$( BUILD_DIR) /lib/src/ldiv.o: OPT_FLAGS := -O2
$( BUILD_DIR) /lib/src/string.o: OPT_FLAGS := -O2
$( BUILD_DIR) /lib/src/gu%.o: OPT_FLAGS := -O3
$( BUILD_DIR) /lib/src/al%.o: OPT_FLAGS := -O3
# For the asm-processor, since it doesn't support -O3. Probably not actually compiled with these flags.
ifeq ( $( VERSION) ,sh)
$( BUILD_DIR) /lib/src/unk_shindou_file.o: OPT_FLAGS := -O1
$( BUILD_DIR) /lib/src/func_sh_80304D20.o: OPT_FLAGS := -O1
$( BUILD_DIR) /lib/src/_Printf.o: OPT_FLAGS := -O3
$( BUILD_DIR) /lib/src/contramread.o: OPT_FLAGS := -O1
$( BUILD_DIR) /lib/src/osPfsIsPlug.o: OPT_FLAGS := -O1
$( BUILD_DIR) /lib/src/osAiSetFrequency.o: OPT_FLAGS := -O1
$( BUILD_DIR) /lib/src/contramwrite.o: OPT_FLAGS := -O1
$( BUILD_DIR) /lib/src/sprintf.o: OPT_FLAGS := -O3
$( BUILD_DIR) /lib/src/_Litob.o: OPT_FLAGS := -O3
$( BUILD_DIR) /lib/src/_Ldtob.o: OPT_FLAGS := -O3
$( BUILD_DIR) /lib/src/osDriveRomInit.o: OPT_FLAGS := -g
endif
ifeq ( $( VERSION) ,eu)
$( BUILD_DIR) /lib/src/_Litob.o: OPT_FLAGS := -O3
$( BUILD_DIR) /lib/src/_Ldtob.o: OPT_FLAGS := -O3
$( BUILD_DIR) /lib/src/_Printf.o: OPT_FLAGS := -O3
$( BUILD_DIR) /lib/src/sprintf.o: OPT_FLAGS := -O3
# Enable loop unrolling except for external.c (external.c might also have used
# unrolling, but it makes one loop harder to match).
# For all audio files other than external.c and port_eu.c, put string literals
# in .data. (In Shindou, the port_eu.c string literals also moved to .data.)
$( BUILD_DIR) /src/audio/%.o: OPT_FLAGS := -O2 -use_readwrite_const
$( BUILD_DIR) /src/audio/port_eu.o: OPT_FLAGS := -O2
$( BUILD_DIR) /src/audio/external.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
endif
ifeq ( $( VERSION_JP_US) ,true)
$( BUILD_DIR) /src/audio/%.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
$( BUILD_DIR) /src/audio/load.o: OPT_FLAGS := -O2 -framepointer -Wo,-loopunroll,0
endif
ifeq ( $( VERSION_JP_US) ,true)
# The source-to-source optimizer copt is enabled for audio. This makes it use
# acpp, which needs -Wp,-+ to handle C++-style comments.
# All other files than external.c should really use copt, but only a few have
# been matched so far.
$( BUILD_DIR) /src/audio/effects.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0 -sopt,-inline= sequence_channel_process_sound,-scalaroptimize= 1 -Wp,-+
$( BUILD_DIR) /src/audio/synthesis.o: OPT_FLAGS := -O2 -sopt,-scalaroptimize= 1 -Wp,-+
endif
2019-11-03 19:36:27 +00:00
2022-03-13 08:17:10 +00:00
# Add a target for build/eu/src/audio/*.copt to make it easier to see debug
$(BUILD_DIR)/src/audio/%.acpp : src /audio /%.c
$( ACPP) $( TARGET_CFLAGS) $( DEF_INC_CFLAGS) -D__sgi -+ $< > $@
$(BUILD_DIR)/src/audio/%.copt : $( BUILD_DIR ) /src /audio /%.acpp
$( COPT) -signed -I= $< -CMP= $@ -cp= i -scalaroptimize= 1 $( COPTFLAGS)
$(BUILD_DIR)/src/audio/seqplayer.copt : COPTFLAGS := -inline_manual
2019-08-25 04:46:40 +00:00
2022-02-12 20:27:20 +00:00
e n d i f
2019-08-25 04:46:40 +00:00
2022-03-13 08:17:10 +00:00
# Run linker script through the C preprocessor
$(BUILD_DIR)/$(LD_SCRIPT) : $( LD_SCRIPT )
$( call print,Preprocessing linker script:,$<,$@ )
2022-04-20 01:18:15 +00:00
$( V) $( CPP) $( PROF_FLAGS) $( CPPFLAGS) -DBUILD_DIR= $( BUILD_DIR) -MMD -MP -MT $@ -MF $@ .d -o $@ $<
2022-08-26 00:30:19 +00:00
2022-03-13 08:17:10 +00:00
# Assemble assembly code
$(BUILD_DIR)/%.o : %.s
$( call print,Assembling:,$<,$@ )
$( V) $( AS) $( ASFLAGS) -MD $( BUILD_DIR) /$* .d -o $@ $<
i f e q ( $( TARGET_N 64) , 1 )
# Assemble RSP assembly code
$( BUILD_DIR) /rsp/%.bin $( BUILD_DIR) /rsp/%_data.bin: rsp/%.s
$( call print,Assembling:,$<,$@ )
$( V) $( RSPASM) -sym $@ .sym $( RSPASMFLAGS) -strequ CODE_FILE $( BUILD_DIR) /rsp/$* .bin -strequ DATA_FILE $( BUILD_DIR) /rsp/$* _data.bin $<
2022-08-26 00:30:19 +00:00
2022-03-13 08:17:10 +00:00
# Link libultra
$( BUILD_DIR) /libultra.a: $( ULTRA_O_FILES)
@$( PRINT) " $( GREEN) Linking libultra: $( BLUE) $@ $( NO_COL) \n "
$( V) $( AR) rcs -o $@ $( ULTRA_O_FILES)
$( V) $( TOOLS_DIR) /patch_libultra_math $@
# Link libgoddard
$( BUILD_DIR) /libgoddard.a: $( GODDARD_O_FILES)
@$( PRINT) " $( GREEN) Linking libgoddard: $( BLUE) $@ $( NO_COL) \n "
$( V) $( AR) rcs -o $@ $( GODDARD_O_FILES)
2022-08-26 00:30:19 +00:00
2022-03-13 08:17:10 +00:00
# Link SM64 ELF file
$( ELF) : $( O_FILES) $( MIO0_OBJ_FILES) $( SEG_FILES) $( BUILD_DIR) /$( LD_SCRIPT) undefined_syms.txt $( BUILD_DIR) /libultra.a $( BUILD_DIR) /libgoddard.a
@$( PRINT) " $( GREEN) Linking ELF file: $( BLUE) $@ $( NO_COL) \n "
2022-04-20 01:18:15 +00:00
$( V) $( LD) $( PROF_FLAGS) -L $( BUILD_DIR) -T undefined_syms.txt -T $( BUILD_DIR) /$( LD_SCRIPT) -Map $( BUILD_DIR) /sm64.$( VERSION) .map --no-check-sections $( addprefix -R ,$( SEG_FILES) ) -o $@ $( O_FILES) -lultra -lgoddard
2022-03-13 08:17:10 +00:00
# Build ROM
$( ROM) : $( ELF)
$( call print,Building ROM:,$<,$@ )
$( V) $( OBJCOPY) --pad-to= 0x800000 --gap-fill= 0xFF $< $( @:.z64= .bin) -O binary
$( V) $( N64CKSUM) $( @:.z64= .bin) $@
2022-08-26 00:30:19 +00:00
2022-03-13 08:17:10 +00:00
$( BUILD_DIR) /$( TARGET) .objdump: $( ELF)
$( OBJDUMP) -D $< > $@
e l s e
2024-05-19 13:38:22 +00:00
$( EXE) : $( O_FILES) $( MIO0_FILES:.mio0= .o) $( ULTRA_O_FILES) $( GODDARD_O_FILES) $( BUILD_DIR) /$( RPC_LIBS) $( BUILD_DIR) /$( DISCORD_SDK_LIBS) $( BUILD_DIR) /$( COOPNET_LIBS) $( BUILD_DIR) /$( LANG_DIR) $( BUILD_DIR) /$( MOD_DIR) $( BUILD_DIR) /$( PALETTES_DIR)
2022-04-20 18:18:17 +00:00
@$( PRINT) " $( GREEN) Linking executable: $( BLUE) $@ $( NO_COL) \n "
2023-05-04 08:03:18 +00:00
$( V) $( LD) $( PROF_FLAGS) -L $( BUILD_DIR) -o $@ $( O_FILES) $( ULTRA_O_FILES) $( GODDARD_O_FILES) $( LDFLAGS)
2022-03-13 08:17:10 +00:00
e n d i f
2020-05-25 01:21:36 +00:00
.PHONY : all clean distclean default diff test load libultra res
2019-12-02 02:52:53 +00:00
.PRECIOUS : $( BUILD_DIR ) /bin /%.elf $( SOUND_BIN_DIR ) /%.ctl $( SOUND_BIN_DIR ) /%.tbl $( SOUND_SAMPLE_TABLES ) $( SOUND_BIN_DIR ) /%.s $( BUILD_DIR ) /%
2022-03-13 08:17:10 +00:00
# with no prerequisites, .SECONDARY causes no intermediate target to be removed
.SECONDARY :
2019-08-25 04:46:40 +00:00
2023-10-30 05:03:36 +00:00
APP_DIR = ./sm64coopdx.app
2023-09-13 10:08:52 +00:00
APP_CONTENTS_DIR = $( APP_DIR) /Contents
APP_MACOS_DIR = $( APP_CONTENTS_DIR) /MacOS
all :
@if [ " $( USE_APP) " = "0" ] ; then \
2023-10-30 05:03:36 +00:00
rm -rf build/us_pc/sm64coopdx.app; \
else \
$( PRINT) " $( GREEN) Creating App Bundle: $( BLUE) build/us_pc/sm64coopdx.app\n " ; \
2023-09-13 10:08:52 +00:00
rm -rf $( APP_DIR) ; \
2023-10-30 05:03:36 +00:00
rm -rf build/us_pc/sm64coopdx.app; \
2023-09-13 10:08:52 +00:00
mkdir -p $( APP_MACOS_DIR) ; \
mkdir -p $( APP_CONTENTS_DIR) /Resources; \
2023-11-26 05:29:59 +00:00
mv build/us_pc/sm64coopdx $( APP_MACOS_DIR) /sm64coopdx; \
2023-09-13 10:08:52 +00:00
cp -r build/us_pc/* $( APP_MACOS_DIR) ; \
cp res/icon.icns $( APP_CONTENTS_DIR) /Resources/icon.icns; \
echo "APPL????" > $( APP_CONTENTS_DIR) /PkgInfo; \
echo '<?xml version="1.0" encoding="UTF-8"?>' > $( APP_CONTENTS_DIR) /Info.plist; \
echo '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo '<plist version="1.0">' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo '<dict>' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo ' <key>CFBundleExecutable</key>' >> $( APP_CONTENTS_DIR) /Info.plist; \
2023-10-30 05:03:36 +00:00
echo ' <string>sm64coopdx</string>' >> $( APP_CONTENTS_DIR) /Info.plist; \
2023-09-13 10:08:52 +00:00
echo ' <key>CFBundleIconFile</key>' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo ' <string>icon</string>' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo ' <key>CFBundleIconName</key>' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo ' <string>AppIcon</string>' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo ' <key>CFBundleDisplayName</key>' >> $( APP_CONTENTS_DIR) /Info.plist; \
2023-10-30 05:03:36 +00:00
echo ' <string>sm64coopdx</string>' >> $( APP_CONTENTS_DIR) /Info.plist; \
2023-09-13 10:08:52 +00:00
echo ' <!-- Add other keys and values here -->' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo '</dict>' >> $( APP_CONTENTS_DIR) /Info.plist; \
echo '</plist>' >> $( APP_CONTENTS_DIR) /Info.plist; \
2023-10-30 05:03:36 +00:00
chmod +x $( APP_MACOS_DIR) /sm64coopdx; \
2023-09-13 10:08:52 +00:00
mv $( APP_DIR) build/us_pc/; \
2023-10-30 05:03:36 +00:00
fi
2023-09-13 10:08:52 +00:00
2019-08-25 04:46:40 +00:00
# Remove built-in rules, to improve performance
MAKEFLAGS += --no-builtin-rules
- i n c l u d e $( DEP_FILES )
2022-05-19 23:33:17 +00:00
print-% : ; $( info $ * is a $ ( flavor $ *) variable set to [$ ( $ *) ]) @true