2019-08-25 00:46:40 -04:00
# Makefile to rebuild SM64 split image
### Default target ###
default : all
### Build Options ###
2019-12-01 21:52:53 -05:00
# These options can either be changed by modifying the makefile, or
# by building with 'make SETTING=value'. 'make clean' may be required.
2019-08-25 00:46:40 -04:00
# Version of the game to build
VERSION ?= us
# Graphics microcode used
GRUCODE ?= f3d_old
# If COMPARE is 1, check the output sha1sum when building 'all'
COMPARE ?= 1
2019-12-01 21:52:53 -05:00
# If NON_MATCHING is 1, define the NON_MATCHING and AVOID_UB macros when building (recommended)
2019-08-25 00:46:40 -04:00
NON_MATCHING ?= 0
2019-12-01 21:52:53 -05:00
# Build for the N64 (turn this off for ports)
2020-06-18 11:58:18 +02:00
TARGET_N64 ?= 0
# Build for Emscripten/WebGL
TARGET_WEB ?= 0
2020-04-03 14:57:26 -04:00
# Compiler to use (ido or gcc)
COMPILER ?= ido
2020-06-18 11:58:18 +02:00
# Automatic settings only for ports
i f e q ( $( TARGET_N 64) , 0 )
NON_MATCHING := 1
GRUCODE := f3dex2e
TARGET_WINDOWS := 0
ifeq ( $( TARGET_WEB) ,0)
ifeq ( $( OS) ,Windows_NT)
TARGET_WINDOWS := 1
else
# TODO: Detect Mac OS X, BSD, etc. For now, assume Linux
TARGET_LINUX := 1
endif
endif
ifeq ( $( TARGET_WINDOWS) ,1)
# On Windows, default to DirectX 11
ifneq ( $( ENABLE_OPENGL) ,1)
ifneq ( $( ENABLE_DX12) ,1)
ENABLE_DX11 ?= 1
endif
endif
else
# On others, default to OpenGL
ENABLE_OPENGL ?= 1
endif
# Sanity checks
ifeq ( $( ENABLE_DX11) ,1)
ifneq ( $( TARGET_WINDOWS) ,1)
$( error The DirectX 11 backend is only supported on Windows)
endif
ifeq ( $( ENABLE_OPENGL) ,1)
$( error Cannot specify multiple graphics backends)
endif
ifeq ( $( ENABLE_DX12) ,1)
$( error Cannot specify multiple graphics backends)
endif
endif
ifeq ( $( ENABLE_DX12) ,1)
ifneq ( $( TARGET_WINDOWS) ,1)
$( error The DirectX 12 backend is only supported on Windows)
endif
ifeq ( $( ENABLE_OPENGL) ,1)
$( error Cannot specify multiple graphics backends)
endif
ifeq ( $( ENABLE_DX11) ,1)
$( error Cannot specify multiple graphics backends)
endif
endif
e n d i f
2020-04-03 14:57:26 -04:00
i f e q ( $( COMPILER ) , g c c )
NON_MATCHING := 1
e n d i f
2019-08-25 00:46:40 -04:00
# Release
i f e q ( $( VERSION ) , j p )
2020-06-02 12:44:34 -04:00
VERSION_DEF := VERSION_JP
GRUCODE_DEF := F3D_OLD
2019-08-25 00:46:40 -04:00
e l s e
i f e q ( $( VERSION ) , u s )
2020-06-02 12:44:34 -04:00
VERSION_DEF := VERSION_US
GRUCODE_DEF := F3D_OLD
2019-08-25 00:46:40 -04:00
e l s e
i f e q ( $( VERSION ) , e u )
2020-06-02 12:44:34 -04:00
VERSION_DEF := VERSION_EU
GRUCODE_DEF := F3D_NEW
2020-03-01 22:42:52 -05:00
e l s e
i f e q ( $( VERSION ) , s h )
$( warning Building SH is experimental and is prone to breaking. Try at your own risk.)
2020-06-02 12:44:34 -04:00
VERSION_DEF := VERSION_SH
GRUCODE_DEF := F3D_NEW
2020-03-01 22:42:52 -05:00
# TODO: GET RID OF THIS!!! We should mandate assets for Shindou like EU but we dont have the addresses extracted yet so we'll just pretend you have everything extracted for now.
2020-04-03 14:57:26 -04:00
NOEXTRACT := 1
2019-08-25 00:46:40 -04:00
e l s e
$( error unknown version " $( VERSION) " )
e n d i f
e n d i f
e n d i f
2020-03-01 22:42:52 -05:00
e n d i f
2019-08-25 00:46:40 -04:00
2020-06-02 12:44:34 -04:00
TARGET := sm64.$( VERSION)
VERSION_CFLAGS := -D$( VERSION_DEF)
VERSION_ASFLAGS := --defsym $( VERSION_DEF) = 1
2019-08-25 00:46:40 -04:00
# Microcode
i f e q ( $( GRUCODE ) , f 3 d e x ) # Fast3DEX
2020-06-02 12:44:34 -04:00
GRUCODE_DEF := F3DEX_GBI
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED = 1
2019-08-25 00:46:40 -04:00
TARGET := $( TARGET) .f3dex
COMPARE := 0
e l s e
i f e q ( $( GRUCODE ) , f 3 d e x 2 ) # Fast3DEX2
2020-06-02 12:44:34 -04:00
GRUCODE_DEF := F3DEX_GBI_2
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED = 1
2019-08-25 00:46:40 -04:00
TARGET := $( TARGET) .f3dex2
COMPARE := 0
e l s e
2020-06-18 11:58:18 +02:00
i f e q ( $( GRUCODE ) , f 3 d e x 2 e ) # Fast3DEX2 Extended (for PC)
GRUCODE_DEF := F3DEX_GBI_2E
TARGET := $( TARGET) .f3dex2e
COMPARE := 0
e l s e
2019-08-25 00:46:40 -04:00
i f e q ( $( GRUCODE ) , f 3 d _ n e w ) # Fast3D 2.0H (Shindou)
2020-06-02 12:44:34 -04:00
GRUCODE_DEF := F3D_NEW
2019-08-25 00:46:40 -04:00
TARGET := $( TARGET) .f3d_new
COMPARE := 0
e l s e
i f e q ( $( GRUCODE ) , f 3 d z e x ) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori)
$( warning Fast3DZEX is experimental. Try at your own risk.)
2020-06-02 12:44:34 -04:00
GRUCODE_DEF := F3DEX_GBI_2
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED = 1
2019-08-25 00:46:40 -04:00
TARGET := $( TARGET) .f3dzex
COMPARE := 0
e n d i f
e n d i f
e n d i f
e n d i f
2020-06-18 11:58:18 +02:00
e n d i f
2019-08-25 00:46:40 -04:00
2020-06-02 12:44:34 -04:00
GRUCODE_CFLAGS := -D$( GRUCODE_DEF)
GRUCODE_ASFLAGS := $( GRUCODE_ASFLAGS) --defsym $( GRUCODE_DEF) = 1
2019-12-01 21:52:53 -05:00
i f e q ( $( NON_MATCHING ) , 1 )
2020-06-02 12:44:34 -04:00
MATCH_CFLAGS := -DNON_MATCHING -DAVOID_UB
MATCH_ASFLAGS := --defsym AVOID_UB = 1
2019-08-25 00:46:40 -04:00
COMPARE := 0
e n d i f
################### Universal Dependencies ###################
# (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.)
i f n e q ( $( MAKECMDGOALS ) , c l e a n )
i f n e q ( $( MAKECMDGOALS ) , d i s t c l e a n )
# Make sure assets exist
NOEXTRACT ?= 0
i f e q ( $( NOEXTRACT ) , 0 )
DUMMY != ./extract_assets.py $( VERSION) >& 2 || echo FAIL
i f e q ( $( DUMMY ) , F A I L )
$( error Failed to extract assets)
e n d i f
e n d i f
# Make tools if out of date
DUMMY != make -s -C tools >& 2 || echo FAIL
i f e q ( $( DUMMY ) , F A I L )
$( error Failed to build tools)
e n d i f
e n d i f
e n d i f
################ Target Executable and Sources ###############
# BUILD_DIR is location where all build artifacts are placed
BUILD_DIR_BASE := build
2020-06-18 11:58:18 +02:00
i f e q ( $( TARGET_N 64) , 1 )
BUILD_DIR := $( BUILD_DIR_BASE) /$( VERSION)
e l s e
i f e q ( $( TARGET_WEB ) , 1 )
BUILD_DIR := $( BUILD_DIR_BASE) /$( VERSION) _web
e l s e
BUILD_DIR := $( BUILD_DIR_BASE) /$( VERSION) _pc
e n d i f
e n d i f
2019-08-25 00:46:40 -04:00
LIBULTRA := $( BUILD_DIR) /libultra.a
2020-06-18 11:58:18 +02:00
i f e q ( $( TARGET_WEB ) , 1 )
EXE := $( BUILD_DIR) /$( TARGET) .html
e l s e
i f e q ( $( TARGET_WINDOWS ) , 1 )
EXE := $( BUILD_DIR) /$( TARGET) .exe
e l s e
EXE := $( BUILD_DIR) /$( TARGET)
e n d i f
e n d i f
2019-08-25 00:46:40 -04:00
ROM := $( BUILD_DIR) /$( TARGET) .z64
ELF := $( BUILD_DIR) /$( TARGET) .elf
LD_SCRIPT := sm64.ld
2019-11-03 14:36:27 -05:00
MIO0_DIR := $( BUILD_DIR) /bin
2019-08-25 00:46:40 -04:00
SOUND_BIN_DIR := $( BUILD_DIR) /sound
TEXTURE_DIR := textures
ACTOR_DIR := actors
2019-11-03 14:36:27 -05:00
LEVEL_DIRS := $( patsubst levels/%,%,$( dir $( wildcard levels/*/header.h) ) )
2019-08-25 00:46:40 -04:00
# Directories containing source files
2020-06-18 11:58:18 +02:00
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin bin/$( VERSION) data assets
ASM_DIRS := lib
i f e q ( $( TARGET_N 64) , 1 )
ASM_DIRS := asm $( ASM_DIRS)
e l s e
SRC_DIRS := $( SRC_DIRS) src/pc src/pc/gfx src/pc/audio src/pc/controller
ASM_DIRS :=
e n d i f
2019-08-25 00:46:40 -04:00
BIN_DIRS := bin bin/$( VERSION)
ULTRA_SRC_DIRS := lib/src lib/src/math
ULTRA_ASM_DIRS := lib/asm lib/data
ULTRA_BIN_DIRS := lib/bin
GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists
2020-04-03 14:57:26 -04:00
MIPSISET := -mips2
MIPSBIT := -32
2019-08-25 00:46:40 -04:00
2020-04-03 14:57:26 -04:00
i f e q ( $( COMPILER ) , g c c )
MIPSISET := -mips3
e n d i f
2019-08-25 00:46:40 -04:00
2020-06-18 11:58:18 +02:00
i f e q ( $( TARGET_N 64) , 1 )
2019-08-25 00:46:40 -04:00
i f e q ( $( VERSION ) , e u )
OPT_FLAGS := -O2
2020-03-01 22:42:52 -05:00
e l s e
i f e q ( $( VERSION ) , s h )
OPT_FLAGS := -O2
2019-08-25 00:46:40 -04:00
e l s e
OPT_FLAGS := -g
e n d i f
2020-03-01 22:42:52 -05:00
e n d i f
2019-08-25 00:46:40 -04:00
2020-06-18 11:58:18 +02:00
# Use a default opt flag for gcc
ifeq ( $( COMPILER) ,gcc)
OPT_FLAGS := -O2
endif
e l s e
i f e q ( $( TARGET_WEB ) , 1 )
OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/
e l s e
2020-04-03 14:57:26 -04:00
OPT_FLAGS := -O2
e n d i f
2020-06-18 11:58:18 +02:00
e n d i f
2020-04-03 14:57:26 -04:00
2019-08-25 00:46:40 -04:00
# 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
# Source code files
2019-11-03 14:36:27 -05: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)
2020-06-18 11:58:18 +02:00
CXX_FILES := $( foreach dir,$( SRC_DIRS) ,$( wildcard $( dir) /*.cpp) )
2019-08-25 00:46:40 -04:00
S_FILES := $( foreach dir,$( ASM_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) )
2020-06-18 11:58:18 +02:00
i f e q ( $( TARGET_N 64) , 1 )
ULTRA_S_FILES := $( foreach dir,$( ULTRA_ASM_DIRS) ,$( wildcard $( dir) /*.s) )
e n d i f
GENERATED_C_FILES := $( BUILD_DIR) /assets/mario_anim_data.c $( BUILD_DIR) /assets/demo_data.c \
$( addprefix $( BUILD_DIR) /bin/,$( addsuffix _skybox.c,$( notdir $( basename $( wildcard textures/skyboxes/*.png) ) ) ) )
i f e q ( $( TARGET_WINDOWS ) , 0 )
CXX_FILES :=
e n d i f
i f n e q ( $( TARGET_N 64) , 1 )
ULTRA_C_FILES := \
alBnkfNew.c \
guLookAtRef.c \
guMtxF2L.c \
guNormalize.c \
guOrthoF.c \
guPerspectiveF.c \
guRotateF.c \
guScaleF.c \
guTranslateF.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
2019-08-25 00:46:40 -04:00
2020-03-01 22:42:52 -05:00
i f e q ( $( VERSION ) , s h )
SOUND_BANK_FILES := $( wildcard sound/sound_banks/*.json)
SOUND_SEQUENCE_FILES := $( wildcard sound/sequences/jp/*.m64) \
$( wildcard sound/sequences/*.m64) \
$( foreach file,$( wildcard sound/sequences/jp/*.s) ,$( BUILD_DIR) /$( file:.s= .m64) ) \
$( foreach file,$( wildcard sound/sequences/*.s) ,$( BUILD_DIR) /$( file:.s= .m64) )
e l s e
2019-08-25 00:46:40 -04:00
SOUND_BANK_FILES := $( wildcard sound/sound_banks/*.json)
SOUND_SEQUENCE_FILES := $( wildcard sound/sequences/$( VERSION) /*.m64) \
$( wildcard sound/sequences/*.m64) \
$( foreach file,$( wildcard sound/sequences/$( VERSION) /*.s) ,$( BUILD_DIR) /$( file:.s= .m64) ) \
$( foreach file,$( wildcard sound/sequences/*.s) ,$( BUILD_DIR) /$( file:.s= .m64) )
2020-03-01 22:42:52 -05:00
e n d i f
2019-08-25 00:46:40 -04:00
SOUND_SAMPLE_DIRS := $( wildcard sound/samples/*)
SOUND_SAMPLE_AIFFS := $( foreach dir,$( SOUND_SAMPLE_DIRS) ,$( wildcard $( dir) /*.aiff) )
SOUND_SAMPLE_TABLES := $( foreach file,$( SOUND_SAMPLE_AIFFS) ,$( BUILD_DIR) /$( file:.aiff= .table) )
SOUND_SAMPLE_AIFCS := $( foreach file,$( SOUND_SAMPLE_AIFFS) ,$( BUILD_DIR) /$( file:.aiff= .aifc) )
2020-06-02 12:44:34 -04:00
SOUND_OBJ_FILES := $( SOUND_BIN_DIR) /sound_data.o
2019-08-25 00:46:40 -04:00
# Object files
O_FILES := $( foreach file,$( C_FILES) ,$( BUILD_DIR) /$( file:.c= .o) ) \
2020-06-18 11:58:18 +02:00
$( foreach file,$( CXX_FILES) ,$( BUILD_DIR) /$( file:.cpp= .o) ) \
2019-08-25 00:46:40 -04:00
$( foreach file,$( S_FILES) ,$( BUILD_DIR) /$( file:.s= .o) ) \
2019-11-03 14:36:27 -05:00
$( foreach file,$( GENERATED_C_FILES) ,$( file:.c= .o) )
2019-08-25 00:46:40 -04: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) )
# Automatic dependency files
DEP_FILES := $( O_FILES:.o= .d) $( ULTRA_O_FILES:.o= .d) $( GODDARD_O_FILES:.o= .d) $( BUILD_DIR) /$( LD_SCRIPT) .d
2019-12-01 21:52:53 -05:00
# Files with GLOBAL_ASM blocks
2020-06-02 12:44:34 -04:00
i f e q ( $( NON_MATCHING ) , 0 )
2020-02-03 00:51:26 -05:00
GLOBAL_ASM_C_FILES != grep -rl 'GLOBAL_ASM(' $( wildcard src/**/*.c)
2019-12-01 21:52:53 -05:00
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
2020-06-02 12:44:34 -04:00
e n d i f
2019-08-25 00:46:40 -04:00
# Segment elf files
SEG_FILES := $( SEGMENT_ELF_FILES) $( ACTOR_ELF_FILES) $( LEVEL_ELF_FILES)
##################### Compiler Options #######################
2020-06-18 11:58:18 +02:00
INCLUDE_CFLAGS := -I include -I $( BUILD_DIR) -I $( BUILD_DIR) /include -I src -I .
ENDIAN_BITWIDTH := $( BUILD_DIR) /endian-and-bitwidth
i f e q ( $( TARGET_N 64) , 1 )
2019-08-25 00:46:40 -04:00
IRIX_ROOT := tools/ido5.3_compiler
i f e q ( $( shell type mips -linux -gnu -ld >/dev /null 2>/dev /null ; echo $ $ ?) , 0 )
CROSS := mips-linux-gnu-
2020-04-03 14:57:26 -04:00
e l s e i f e q ( $( shell type mips 64-linux -gnu -ld >/dev /null 2>/dev /null ; echo $ $ ?) , 0 )
CROSS := mips64-linux-gnu-
2019-08-25 00:46:40 -04:00
e l s e
CROSS := mips64-elf-
e n d i f
2019-10-05 15:08:05 -04:00
# check that either QEMU_IRIX is set or qemu-irix package installed
2020-06-02 12:44:34 -04:00
i f e q ( $( COMPILER ) , i d o )
ifndef QEMU_IRIX
QEMU_IRIX := $( shell which qemu-irix 2>/dev/null)
ifeq ( , $( QEMU_IRIX) )
$( error Please install qemu-irix package or set QEMU_IRIX env var to the full qemu-irix binary path)
endif
2019-10-05 15:08:05 -04:00
endif
e n d i f
2019-08-25 00:46:40 -04:00
AS := $( CROSS) as
CC := $( QEMU_IRIX) -silent -L $( IRIX_ROOT) $( IRIX_ROOT) /usr/bin/cc
2019-12-01 21:52:53 -05:00
CPP := cpp -P -Wno-trigraphs
2019-08-25 00:46:40 -04:00
LD := $( CROSS) ld
AR := $( CROSS) ar
OBJDUMP := $( CROSS) objdump
OBJCOPY := $( CROSS) objcopy
PYTHON := python3
2020-04-03 14:57:26 -04:00
# change the compiler to gcc, to use the default, install the gcc-mips-linux-gnu package
i f e q ( $( COMPILER ) , g c c )
CC := $( CROSS) gcc
e n d i f
2019-12-01 21:52:53 -05:00
i f e q ( $( TARGET_N 64) , 1 )
2020-06-02 12:44:34 -04:00
TARGET_CFLAGS := -nostdinc -I include/libc -DTARGET_N64 -D_LANGUAGE_C
2019-12-01 21:52:53 -05:00
CC_CFLAGS := -fno-builtin
e n d i f
INCLUDE_CFLAGS := -I include -I $( BUILD_DIR) -I $( BUILD_DIR) /include -I src -I .
2019-11-03 14:36:27 -05:00
2019-08-25 00:46:40 -04:00
# Check code syntax with host compiler
2020-06-02 12:44:34 -04:00
CC_CHECK := gcc
CC_CHECK_CFLAGS := -fsyntax-only -fsigned-char $( CC_CFLAGS) $( TARGET_CFLAGS) $( INCLUDE_CFLAGS) -std= gnu90 -Wall -Wextra -Wno-format-security -Wno-main -DNON_MATCHING -DAVOID_UB $( VERSION_CFLAGS) $( GRUCODE_CFLAGS)
2019-08-25 00:46:40 -04:00
2020-06-02 12:44:34 -04:00
COMMON_CFLAGS = $( OPT_FLAGS) $( TARGET_CFLAGS) $( INCLUDE_CFLAGS) $( VERSION_CFLAGS) $( MATCH_CFLAGS) $( MIPSISET) $( GRUCODE_CFLAGS)
2020-04-03 14:57:26 -04:00
2020-06-02 12:44:34 -04:00
ASFLAGS := -march= vr4300 -mabi= 32 -I include -I $( BUILD_DIR) $( VERSION_ASFLAGS) $( MATCH_ASFLAGS) $( GRUCODE_ASFLAGS)
2020-04-03 14:57:26 -04:00
CFLAGS = -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn -signed $( COMMON_CFLAGS) $( MIPSBIT)
2019-08-25 00:46:40 -04:00
OBJCOPYFLAGS := --pad-to= 0x800000 --gap-fill= 0xFF
SYMBOL_LINKING_FLAGS := $( addprefix -R ,$( SEG_FILES) )
2019-09-01 15:50:50 -04:00
LDFLAGS := -T undefined_syms.txt -T $( BUILD_DIR) /$( LD_SCRIPT) -Map $( BUILD_DIR) /sm64.$( VERSION) .map --no-check-sections $( SYMBOL_LINKING_FLAGS)
2019-12-01 21:52:53 -05:00
ENDIAN_BITWIDTH := $( BUILD_DIR) /endian-and-bitwidth
2019-08-25 00:46:40 -04:00
2020-04-03 14:57:26 -04:00
i f e q ( $( COMPILER ) , g c c )
2020-06-02 12:44:34 -04:00
CFLAGS := -march= vr4300 -mfix4300 -mabi= 32 -mno-shared -G 0 -mhard-float -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -I include -I src/ -I $( BUILD_DIR) /include -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra $( COMMON_CFLAGS)
2020-04-03 14:57:26 -04:00
e n d i f
2019-08-25 00:46:40 -04:00
i f e q ( $( shell getconf LONG_BIT ) , 3 2 )
# Work around memory allocation bug in QEMU
export QEMU_GUEST_BASE := 1
e l s e
# Ensure that gcc treats the code as 32-bit
2020-06-02 12:44:34 -04:00
CC_CHECK_CFLAGS += -m32
2019-08-25 00:46:40 -04:00
e n d i f
2020-03-01 22:42:52 -05:00
# Prevent a crash with -sopt
export LANG := C
2020-06-18 11:58:18 +02:00
e l s e # TARGET_N64
AS := as
i f n e q ( $( TARGET_WEB ) , 1 )
CC := gcc
CXX := g++
e l s e
CC := emcc
e n d i f
i f e q ( $( TARGET_WINDOWS ) , 1 )
LD := $( CXX)
e l s e
LD := $( CC)
e n d i f
CPP := cpp -P
OBJDUMP := objdump
OBJCOPY := objcopy
PYTHON := python3
# Platform-specific compiler and linker flags
i f e q ( $( TARGET_WINDOWS ) , 1 )
PLATFORM_CFLAGS := -DTARGET_WINDOWS
PLATFORM_LDFLAGS := -lm -lxinput9_1_0 -lole32 -no-pie -mwindows
e n d i f
i f e q ( $( TARGET_LINUX ) , 1 )
PLATFORM_CFLAGS := -DTARGET_LINUX ` pkg-config --cflags libusb-1.0`
PLATFORM_LDFLAGS := -lm -lpthread ` pkg-config --libs libusb-1.0` -lasound -lpulse -no-pie
e n d i f
i f e q ( $( TARGET_WEB ) , 1 )
PLATFORM_CFLAGS := -DTARGET_WEB
PLATFORM_LDFLAGS := -lm -no-pie -s TOTAL_MEMORY = 20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']"
e n d i f
PLATFORM_CFLAGS += -DNO_SEGMENTED_MEMORY
# Compiler and linker flags for graphics backend
i f e q ( $( ENABLE_OPENGL ) , 1 )
GFX_CFLAGS := -DENABLE_OPENGL
GFX_LDFLAGS :=
ifeq ( $( TARGET_WINDOWS) ,1)
GFX_CFLAGS += $( shell sdl2-config --cflags) -DGLEW_STATIC
GFX_LDFLAGS += $( shell sdl2-config --libs) -lglew32 -lopengl32 -lwinmm -limm32 -lversion -loleaut32 -lsetupapi
endif
ifeq ( $( TARGET_LINUX) ,1)
GFX_CFLAGS += $( shell sdl2-config --cflags)
GFX_LDFLAGS += -lGL $( shell sdl2-config --libs) -lX11 -lXrandr
endif
ifeq ( $( TARGET_WEB) ,1)
GFX_CFLAGS += -s USE_SDL = 2
GFX_LDFLAGS += -lGL -lSDL2
endif
e n d i f
i f e q ( $( ENABLE_DX 11) , 1 )
GFX_CFLAGS := -DENABLE_DX11
PLATFORM_LDFLAGS += -lgdi32 -static
e n d i f
i f e q ( $( ENABLE_DX 12) , 1 )
GFX_CFLAGS := -DENABLE_DX12
PLATFORM_LDFLAGS += -lgdi32 -static
e n d i f
GFX_CFLAGS += -DWIDESCREEN
CC_CHECK := $( CC) -fsyntax-only -fsigned-char $( INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security -D_LANGUAGE_C $( VERSION_CFLAGS) $( MATCH_CFLAGS) $( PLATFORM_CFLAGS) $( GFX_CFLAGS) $( GRUCODE_CFLAGS)
CFLAGS := $( OPT_FLAGS) $( INCLUDE_CFLAGS) -D_LANGUAGE_C $( VERSION_CFLAGS) $( MATCH_CFLAGS) $( PLATFORM_CFLAGS) $( GFX_CFLAGS) $( GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv -march= native
ASFLAGS := -I include -I $( BUILD_DIR) $( VERSION_ASFLAGS)
LDFLAGS := $( PLATFORM_LDFLAGS) $( GFX_LDFLAGS)
e n d i f
2019-08-25 00:46:40 -04:00
####################### Other Tools #########################
# N64 tools
TOOLS_DIR = 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
2019-11-03 14:36:27 -05:00
EXTRACT_DATA_FOR_MIO = $( TOOLS_DIR) /extract_data_for_mio
SKYCONV = $( TOOLS_DIR) /skyconv
2019-08-25 00:46:40 -04:00
EMULATOR = mupen64plus
EMU_FLAGS = --noosd
LOADER = loader64
LOADER_FLAGS = -vwf
SHA1SUM = sha1sum
2020-06-02 12:44:34 -04:00
i f e q ( , $( shell which armips 2>/dev /null ) )
RSPASM := $( TOOLS_DIR) /armips
e l s e
RSPASM = armips
e n d i f
2020-04-03 14:57:26 -04: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 00:46:40 -04:00
######################## Targets #############################
2020-06-18 11:58:18 +02:00
i f e q ( $( TARGET_N 64) , 1 )
2019-08-25 00:46:40 -04:00
all : $( ROM )
i f e q ( $( COMPARE ) , 1 )
2019-10-05 15:08:05 -04:00
@$( SHA1SUM) -c $( TARGET) .sha1 || ( echo 'The build succeeded, but did not match the official ROM. This is expected if you are making changes to the game.\nTo silence this message, use "make COMPARE=0"' . && false )
2019-08-25 00:46:40 -04:00
e n d i f
2020-06-18 11:58:18 +02:00
e l s e
all : $( EXE )
e n d i f
2019-08-25 00:46:40 -04:00
clean :
$( RM) -r $( BUILD_DIR_BASE)
distclean :
$( RM) -r $( BUILD_DIR_BASE)
./extract_assets.py --clean
test : $( ROM )
$( EMULATOR) $( EMU_FLAGS) $<
load : $( ROM )
$( LOADER) $( LOADER_FLAGS) $<
libultra : $( BUILD_DIR ) /libultra .a
2020-06-02 12:44:34 -04:00
$(BUILD_DIR)/asm/boot.o : $( IPL 3_RAW_FILES )
$(BUILD_DIR)/src/game/crash_screen.o : $( CRASH_TEXTURE_C_FILES )
2019-08-25 00:46:40 -04:00
2020-06-02 12:44:34 -04:00
$(BUILD_DIR)/lib/rsp.o : $( BUILD_DIR ) /rsp /rspboot .bin $( BUILD_DIR ) /rsp /fast 3d .bin $( BUILD_DIR ) /rsp /audio .bin
2019-08-25 00:46:40 -04:00
2019-10-05 15:08:05 -04:00
$(BUILD_DIR)/include/text_strings.h : include /text_strings .h .in
2019-08-25 00:46:40 -04:00
$( TEXTCONV) charmap.txt $< $@
2019-10-05 15:08:05 -04:00
$(BUILD_DIR)/include/text_menu_strings.h : include /text_menu_strings .h .in
$( TEXTCONV) charmap_menu.txt $< $@
2020-04-03 14:57:26 -04:00
i f e q ( $( COMPILER ) , g c c )
$(BUILD_DIR)/lib/src/math/%.o : CFLAGS += -fno -builtin
e n d i f
2019-08-25 00:46:40 -04:00
i f e q ( $( VERSION ) , e u )
2019-12-01 21:52:53 -05:00
TEXT_DIRS := text/de text/us text/fr
2020-02-03 00:51:26 -05:00
# EU encoded text inserted into individual segment 0x19 files,
# and course data also duplicated in leveldata.c
2019-12-01 21:52:53 -05:00
$(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
2020-02-03 00:51:26 -05:00
$(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
2019-12-01 21:52:53 -05:00
2020-03-01 22:42:52 -05:00
e l s e
i f e q ( $( VERSION ) , s h )
TEXT_DIRS := text/jp
$(BUILD_DIR)/bin/segment2.o : $( BUILD_DIR ) /text /jp /define_text .inc .c
2019-08-25 00:46:40 -04:00
e l s e
2019-12-01 21:52:53 -05:00
TEXT_DIRS := text/$( VERSION)
2019-08-25 00:46:40 -04:00
# non-EU encoded text inserted into segment 0x02
2019-12-01 21:52:53 -05:00
$(BUILD_DIR)/bin/segment2.o : $( BUILD_DIR ) /text /$( VERSION ) /define_text .inc .c
2019-08-25 00:46:40 -04:00
e n d i f
2020-03-01 22:42:52 -05:00
e n d i f
2019-08-25 00:46:40 -04:00
2020-02-03 00:51:26 -05:00
$(BUILD_DIR)/text/%/define_courses.inc.c : text /define_courses .inc .c text /%/courses .h
$( CPP) $( VERSION_CFLAGS) $< -o $@ -I text/$* /
$( TEXTCONV) charmap.txt $@ $@
2019-12-01 21:52:53 -05:00
$(BUILD_DIR)/text/%/define_text.inc.c : text /define_text .inc .c text /%/courses .h text /%/dialogs .h
$( CPP) $( VERSION_CFLAGS) $< -o $@ -I text/$* /
$( TEXTCONV) charmap.txt $@ $@
2020-06-02 12:44:34 -04:00
RSP_DIRS := $( BUILD_DIR) /rsp
ALL_DIRS := $( BUILD_DIR) $( addprefix $( BUILD_DIR) /,$( SRC_DIRS) $( ASM_DIRS) $( GODDARD_SRC_DIRS) $( ULTRA_SRC_DIRS) $( ULTRA_ASM_DIRS) $( ULTRA_BIN_DIRS) $( BIN_DIRS) $( TEXTURE_DIRS) $( TEXT_DIRS) $( SOUND_SAMPLE_DIRS) $( addprefix levels/,$( LEVEL_DIRS) ) include) $( MIO0_DIR) $( addprefix $( MIO0_DIR) /,$( VERSION) ) $( SOUND_BIN_DIR) $( SOUND_BIN_DIR) /sequences/$( VERSION) $( RSP_DIRS)
2019-08-25 00:46:40 -04:00
# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $( ALL_DIRS)
2019-10-05 19:40:22 -04:00
$(BUILD_DIR)/include/text_strings.h : $( BUILD_DIR ) /include /text_menu_strings .h
$(BUILD_DIR)/src/menu/file_select.o : $( BUILD_DIR ) /include /text_strings .h
$(BUILD_DIR)/src/menu/star_select.o : $( BUILD_DIR ) /include /text_strings .h
2019-08-25 00:46:40 -04:00
$(BUILD_DIR)/src/game/ingame_menu.o : $( BUILD_DIR ) /include /text_strings .h
################################################################
# TEXTURE GENERATION #
################################################################
# RGBA32, RGBA16, IA16, IA8, IA4, IA1, I8, I4
$(BUILD_DIR)/% : %.png
$( N64GRAPHICS) -i $@ -g $< -f $( lastword $( subst ., ,$@ ) )
2019-11-03 14:36:27 -05:00
$(BUILD_DIR)/%.inc.c : $( BUILD_DIR ) /% %.png
hexdump -v -e '1/1 "0x%X,"' $< > $@
echo >> $@
2019-08-25 00:46:40 -04:00
# Color Index CI8
$(BUILD_DIR)/%.ci8 : %.ci 8.png
$( N64GRAPHICS_CI) -i $@ -g $< -f ci8
# Color Index CI4
$(BUILD_DIR)/%.ci4 : %.ci 4.png
$( N64GRAPHICS_CI) -i $@ -g $< -f ci4
################################################################
# compressed segment generation
2020-06-18 11:58:18 +02:00
i f e q ( $( TARGET_N 64) , 1 )
2019-08-25 00:46:40 -04:00
# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address
2019-11-03 14:36:27 -05:00
2019-08-25 00:46:40 -04:00
$(BUILD_DIR)/bin/%.elf : $( BUILD_DIR ) /bin /%.o
$( LD) -e 0 -Ttext= $( SEGMENT_ADDRESS) -Map $@ .map -o $@ $<
2019-11-03 14:36:27 -05:00
$(BUILD_DIR)/actors/%.elf : $( BUILD_DIR ) /actors /%.o
$( LD) -e 0 -Ttext= $( SEGMENT_ADDRESS) -Map $@ .map -o $@ $<
2019-08-25 00:46:40 -04:00
# Override for level.elf, which otherwise matches the above pattern
.SECONDEXPANSION :
2019-11-03 14:36:27 -05:00
$(BUILD_DIR)/levels/%/leveldata.elf : $( BUILD_DIR ) /levels /%/leveldata .o $( BUILD_DIR ) /bin /$$( TEXTURE_BIN ) .elf
2019-08-25 00:46:40 -04:00
$( LD) -e 0 -Ttext= $( SEGMENT_ADDRESS) -Map $@ .map --just-symbols= $( BUILD_DIR) /bin/$( TEXTURE_BIN) .elf -o $@ $<
$(BUILD_DIR)/bin/%.bin : $( BUILD_DIR ) /bin /%.elf
2019-11-03 14:36:27 -05:00
$( EXTRACT_DATA_FOR_MIO) $< $@
2019-08-25 00:46:40 -04:00
2019-11-03 14:36:27 -05:00
$(BUILD_DIR)/actors/%.bin : $( BUILD_DIR ) /actors /%.elf
$( EXTRACT_DATA_FOR_MIO) $< $@
$(BUILD_DIR)/levels/%/leveldata.bin : $( BUILD_DIR ) /levels /%/leveldata .elf
$( EXTRACT_DATA_FOR_MIO) $< $@
$(BUILD_DIR)/%.mio0 : $( BUILD_DIR ) /%.bin
2019-08-25 00:46:40 -04:00
$( MIO0TOOL) $< $@
2019-11-03 14:36:27 -05:00
$(BUILD_DIR)/%.mio0.o : $( BUILD_DIR ) /%.mio 0.s
2019-08-25 00:46:40 -04:00
$( AS) $( ASFLAGS) -o $@ $<
2019-11-03 14:36:27 -05:00
$(BUILD_DIR)/%.mio0.s : $( BUILD_DIR ) /%.mio 0
2019-08-25 00:46:40 -04:00
printf " .section .data\n\n.incbin \" $<\"\n " > $@
2020-06-18 11:58:18 +02:00
e n d i f
2019-08-25 00:46:40 -04:00
$(BUILD_DIR)/%.table : %.aiff
$( AIFF_EXTRACT_CODEBOOK) $< >$@
$(BUILD_DIR)/%.aifc : $( BUILD_DIR ) /%.table %.aiff
$( VADPCM_ENC) -c $^ $@
2020-06-02 12:44:34 -04:00
$(BUILD_DIR)/rsp/%.bin $(BUILD_DIR)/rsp/%_data.bin : rsp /%.s
$( RSPASM) -sym $@ .sym -definelabel $( VERSION_DEF) 1 -definelabel $( GRUCODE_DEF) 1 -strequ CODE_FILE $( BUILD_DIR) /rsp/$* .bin -strequ DATA_FILE $( BUILD_DIR) /rsp/$* _data.bin $<
2019-12-01 21:52:53 -05:00
$(ENDIAN_BITWIDTH) : tools /determine -endian -bitwidth .c
$( CC) -c $( CFLAGS) -o $@ .dummy2 $< 2>$@ .dummy1; true
grep -o 'msgbegin --endian .* --bitwidth .* msgend' $@ .dummy1 > $@ .dummy2
head -n1 <$@ .dummy2 | cut -d' ' -f2-5 > $@
@rm $@ .dummy1
@rm $@ .dummy2
$(SOUND_BIN_DIR)/sound_data.ctl : sound /sound_banks / $( SOUND_BANK_FILES ) $( SOUND_SAMPLE_AIFCS ) $( ENDIAN_BITWIDTH )
$( PYTHON) tools/assemble_sound.py $( BUILD_DIR) /sound/samples/ sound/sound_banks/ $( SOUND_BIN_DIR) /sound_data.ctl $( SOUND_BIN_DIR) /sound_data.tbl $( VERSION_CFLAGS) $$ ( cat $( ENDIAN_BITWIDTH) )
2019-08-25 00:46:40 -04:00
$(SOUND_BIN_DIR)/sound_data.tbl : $( SOUND_BIN_DIR ) /sound_data .ctl
2019-12-01 21:52:53 -05:00
@true
2019-08-25 00:46:40 -04:00
2020-03-01 22:42:52 -05:00
i f e q ( $( VERSION ) , s h )
$(SOUND_BIN_DIR)/sequences.bin : $( SOUND_BANK_FILES ) sound /sequences .json sound /sequences / sound /sequences /jp / $( SOUND_SEQUENCE_FILES ) $( ENDIAN_BITWIDTH )
$( PYTHON) tools/assemble_sound.py --sequences $@ $( SOUND_BIN_DIR) /bank_sets sound/sound_banks/ sound/sequences.json $( SOUND_SEQUENCE_FILES) $( VERSION_CFLAGS) $$ ( cat $( ENDIAN_BITWIDTH) )
e l s e
2019-12-01 21:52:53 -05:00
$(SOUND_BIN_DIR)/sequences.bin : $( SOUND_BANK_FILES ) sound /sequences .json sound /sequences / sound /sequences /$( VERSION ) / $( SOUND_SEQUENCE_FILES ) $( ENDIAN_BITWIDTH )
$( PYTHON) tools/assemble_sound.py --sequences $@ $( SOUND_BIN_DIR) /bank_sets sound/sound_banks/ sound/sequences.json $( SOUND_SEQUENCE_FILES) $( VERSION_CFLAGS) $$ ( cat $( ENDIAN_BITWIDTH) )
2020-03-01 22:42:52 -05:00
e n d i f
2019-09-01 15:50:50 -04:00
$(SOUND_BIN_DIR)/bank_sets : $( SOUND_BIN_DIR ) /sequences .bin
2019-12-01 21:52:53 -05:00
@true
2019-08-25 00:46:40 -04:00
$(SOUND_BIN_DIR)/%.m64 : $( SOUND_BIN_DIR ) /%.o
$( OBJCOPY) -j .rodata $< -O binary $@
$(SOUND_BIN_DIR)/%.o : $( SOUND_BIN_DIR ) /%.s
$( AS) $( ASFLAGS) -o $@ $<
2020-06-02 12:44:34 -04:00
$(SOUND_BIN_DIR)/%.inc.c : $( SOUND_BIN_DIR ) /%
hexdump -v -e '1/1 "0x%X,"' $< > $@
echo >> $@
$(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
2019-08-25 00:46:40 -04:00
2019-12-01 21:52:53 -05:00
$(BUILD_DIR)/levels/scripts.o : $( BUILD_DIR ) /include /level_headers .h
$(BUILD_DIR)/include/level_headers.h : levels /level_headers .h .in
$( CPP) -I . levels/level_headers.h.in | $( PYTHON) tools/output_level_headers.py > $( BUILD_DIR) /include/level_headers.h
2019-11-03 14:36:27 -05:00
$(BUILD_DIR)/assets/mario_anim_data.c : $( wildcard assets /anims /*.inc .c )
$( PYTHON) tools/mario_anims_converter.py > $@
$(BUILD_DIR)/assets/demo_data.c : assets /demo_data .json $( wildcard assets /demos /*.bin )
$( PYTHON) tools/demo_data_converter.py assets/demo_data.json $( VERSION_CFLAGS) > $@
2020-04-03 14:57:26 -04:00
i f e q ( $( COMPILER ) , i d o )
2019-08-25 00:46:40 -04:00
# Source code
2020-02-03 00:51:26 -05:00
$(BUILD_DIR)/levels/%/leveldata.o : OPT_FLAGS := -g
$(BUILD_DIR)/actors/%.o : OPT_FLAGS := -g
$(BUILD_DIR)/bin/%.o : OPT_FLAGS := -g
2019-08-25 00:46:40 -04:00
$(BUILD_DIR)/src/goddard/%.o : OPT_FLAGS := -g
$(BUILD_DIR)/src/goddard/%.o : MIPSISET := -mips 1
$(BUILD_DIR)/src/audio/%.o : OPT_FLAGS := -O 2 -Wo , -loopunroll , 0
$(BUILD_DIR)/src/audio/load.o : OPT_FLAGS := -O 2 -framepointer -Wo , -loopunroll , 0
$(BUILD_DIR)/lib/src/%.o : OPT_FLAGS :=
$(BUILD_DIR)/lib/src/math/ll%.o : MIPSISET := -mips 3 -32
$(BUILD_DIR)/lib/src/math/%.o : OPT_FLAGS := -O 2
$(BUILD_DIR)/lib/src/math/ll%.o : OPT_FLAGS :=
$(BUILD_DIR)/lib/src/ldiv.o : OPT_FLAGS := -O 2
$(BUILD_DIR)/lib/src/string.o : OPT_FLAGS := -O 2
$(BUILD_DIR)/lib/src/gu%.o : OPT_FLAGS := -O 3
$(BUILD_DIR)/lib/src/al%.o : OPT_FLAGS := -O 3
i f e q ( $( VERSION ) , e u )
$(BUILD_DIR)/lib/src/_Litob.o : OPT_FLAGS := -O 3
$(BUILD_DIR)/lib/src/_Ldtob.o : OPT_FLAGS := -O 3
$(BUILD_DIR)/lib/src/_Printf.o : OPT_FLAGS := -O 3
2020-02-03 00:51:26 -05:00
$(BUILD_DIR)/lib/src/sprintf.o : OPT_FLAGS := -O 3
# enable loop unrolling except for external.c (external.c might also have used
# unrolling, but it makes one loop harder to match)
$(BUILD_DIR)/src/audio/%.o : OPT_FLAGS := -O 2
$(BUILD_DIR)/src/audio/load.o : OPT_FLAGS := -O 2
$(BUILD_DIR)/src/audio/external.o : OPT_FLAGS := -O 2 -Wo , -loopunroll , 0
2020-03-01 22:42:52 -05:00
e l s e
# The source-to-source optimizer copt is enabled for audio. This makes it use
# acpp, which needs -Wp,-+ to handle C++-style comments.
$(BUILD_DIR)/src/audio/effects.o : OPT_FLAGS := -O 2 -Wo , -loopunroll , 0 -sopt , -inline =sequence_channel_process_sound , -scalaroptimize =1 -Wp , -+
2020-04-03 14:57:26 -04:00
$(BUILD_DIR)/src/audio/synthesis.o : OPT_FLAGS := -O 2 -sopt , -scalaroptimize =1 -Wp , -+
2020-06-02 12:44:34 -04:00
#$(BUILD_DIR)/src/audio/seqplayer.o: OPT_FLAGS := -O2 -sopt,-inline_manual,-scalaroptimize=1 -Wp,-+ #-Wo,-v,-bb,-l,seqplayer_list.txt
2020-03-01 22:42:52 -05: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
2020-06-02 12:44:34 -04:00
$( QEMU_IRIX) -silent -L $( IRIX_ROOT) $( IRIX_ROOT) /usr/lib/acpp $( TARGET_CFLAGS) $( INCLUDE_CFLAGS) $( VERSION_CFLAGS) $( MATCH_CFLAGS) $( GRUCODE_CFLAGS) -D__sgi -+ $< > $@
$(BUILD_DIR)/src/audio/seqplayer.copt : $( BUILD_DIR ) /src /audio /seqplayer .acpp
$( QEMU_IRIX) -silent -L $( IRIX_ROOT) $( IRIX_ROOT) /usr/lib/copt -signed -I= $< -CMP= $@ -cp= i -scalaroptimize= 1 -inline_manual
2020-03-01 22:42:52 -05:00
$(BUILD_DIR)/src/audio/%.copt : $( BUILD_DIR ) /src /audio /%.acpp
$( QEMU_IRIX) -silent -L $( IRIX_ROOT) $( IRIX_ROOT) /usr/lib/copt -signed -I= $< -CMP= $@ -cp= i -scalaroptimize= 1
2020-06-02 12:44:34 -04:00
2019-08-25 00:46:40 -04:00
e n d i f
2020-04-03 14:57:26 -04:00
e n d i f
2019-08-25 00:46:40 -04:00
2019-12-01 21:52:53 -05:00
i f e q ( $( NON_MATCHING ) , 0 )
$(GLOBAL_ASM_O_FILES) : CC := $( PYTHON ) tools /asm_processor /build .py $( CC ) -- $( AS ) $( ASFLAGS ) --
e n d i f
# 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) :
@rm -f $( GLOBAL_ASM_DEP) .*
2019-08-25 00:46:40 -04:00
touch $@
2020-06-18 11:58:18 +02:00
$(BUILD_DIR)/%.o : %.cpp
@$( CXX) -fsyntax-only $( CFLAGS) -MMD -MP -MT $@ -MF $( BUILD_DIR) /$* .d $<
$( CXX) -c $( CFLAGS) -o $@ $<
2019-08-25 00:46:40 -04:00
$(BUILD_DIR)/%.o : %.c
2020-06-02 12:44:34 -04:00
@$( CC_CHECK) $( CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $( BUILD_DIR) /$* .d $<
2019-08-25 00:46:40 -04:00
$( CC) -c $( CFLAGS) -o $@ $<
2019-11-03 14:36:27 -05:00
$(BUILD_DIR)/%.o : $( BUILD_DIR ) /%.c
2020-06-02 12:44:34 -04:00
@$( CC_CHECK) $( CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $( BUILD_DIR) /$* .d $<
2019-11-03 14:36:27 -05:00
$( CC) -c $( CFLAGS) -o $@ $<
$(BUILD_DIR)/%.o : %.s
2019-08-25 00:46:40 -04:00
$( AS) $( ASFLAGS) -MD $( BUILD_DIR) /$* .d -o $@ $<
2020-06-18 11:58:18 +02:00
i f e q ( $( TARGET_N 64) , 1 )
2019-08-25 00:46:40 -04:00
$(BUILD_DIR)/$(LD_SCRIPT) : $( LD_SCRIPT )
2019-12-01 21:52:53 -05:00
$( CPP) $( VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@ .d -I include/ -I . -DBUILD_DIR= $( BUILD_DIR) -o $@ $<
2019-08-25 00:46:40 -04:00
$(BUILD_DIR)/libultra.a : $( ULTRA_O_FILES )
$( AR) rcs -o $@ $( ULTRA_O_FILES)
2020-01-03 10:38:57 -05:00
tools/patch_libultra_math $@
2019-08-25 00:46:40 -04:00
$(BUILD_DIR)/libgoddard.a : $( GODDARD_O_FILES )
$( AR) rcs -o $@ $( GODDARD_O_FILES)
$(ELF) : $( O_FILES ) $( MIO 0_OBJ_FILES ) $( SOUND_OBJ_FILES ) $( SEG_FILES ) $( BUILD_DIR ) /$( LD_SCRIPT ) undefined_syms .txt $( BUILD_DIR ) /libultra .a $( BUILD_DIR ) /libgoddard .a
$( LD) -L $( BUILD_DIR) $( LDFLAGS) -o $@ $( O_FILES) $( LIBS) -lultra -lgoddard
$(ROM) : $( ELF )
$( OBJCOPY) $( OBJCOPYFLAGS) $< $( @:.z64= .bin) -O binary
$( N64CKSUM) $( @:.z64= .bin) $@
$(BUILD_DIR)/$(TARGET).objdump : $( ELF )
$( OBJDUMP) -D $< > $@
2020-06-18 11:58:18 +02:00
e l s e
$(EXE) : $( O_FILES ) $( MIO 0_FILES :.mio 0=.o ) $( SOUND_OBJ_FILES ) $( ULTRA_O_FILES ) $( GODDARD_O_FILES )
$( LD) -L $( BUILD_DIR) -o $@ $( O_FILES) $( SOUND_OBJ_FILES) $( ULTRA_O_FILES) $( GODDARD_O_FILES) $( LDFLAGS)
e n d i f
2019-08-25 00:46:40 -04:00
.PHONY : all clean distclean default diff test load libultra
2020-06-02 12:44:34 -04:00
# with no prerequisites, .SECONDARY causes no intermediate target to be removed
.SECONDARY :
2019-08-25 00:46:40 -04:00
# Remove built-in rules, to improve performance
MAKEFLAGS += --no-builtin-rules
- i n c l u d e $( DEP_FILES )
print-% : ; $( info $ * is a $ ( flavor $ *) variable set to [$ ( $ *) ]) @true