2019-09-05 22:09:40 +00:00
|
|
|
# User configurable
|
|
|
|
|
2020-04-14 07:12:59 +00:00
|
|
|
ROMID ?= ntsc-final
|
|
|
|
PIRACYCHECKS ?= 1
|
|
|
|
|
2021-10-15 13:44:10 +00:00
|
|
|
# In PD, some code is compiled with IDO 5.3 and some is IDO 7.1.
|
|
|
|
# The project provides both versions of the IDO compiler so that the project can
|
|
|
|
# be compiled out of the box by running these compilers using qemu-irix.
|
|
|
|
# Recomp can be used for almost all files, but some must be compiled with qemu.
|
2019-09-05 22:09:40 +00:00
|
|
|
|
2021-10-15 13:44:10 +00:00
|
|
|
# These are the qemu-irix versions. These variables are constant.
|
|
|
|
CCQEMU53 = tools/irix/qemu-irix -silent -L tools/irix/root53 tools/irix/root53/usr/bin/cc
|
|
|
|
CCQEMU71 = tools/irix/qemu-irix -silent -L tools/irix/root71 tools/irix/root71/usr/bin/cc
|
2021-01-16 13:46:33 +00:00
|
|
|
|
2021-10-15 13:44:10 +00:00
|
|
|
# The user can use recomp by setting $CC53 and $CC71 in their environment.
|
|
|
|
# If not set, fall back to using the qemu-irix compilers.
|
|
|
|
CC53 ?= $(CCQEMU53)
|
|
|
|
CC71 ?= $(CCQEMU71)
|
|
|
|
|
|
|
|
# By default we'll compile everything using 5.3,
|
|
|
|
# as this is what most of the project uses.
|
|
|
|
CC := $(CC53)
|
2019-09-05 22:09:40 +00:00
|
|
|
|
2021-10-15 13:44:10 +00:00
|
|
|
################################################################################
|
2021-04-25 06:48:18 +00:00
|
|
|
|
2020-04-14 07:12:59 +00:00
|
|
|
export ROMID
|
|
|
|
|
|
|
|
NTSC=0
|
|
|
|
PAL=0
|
2021-01-03 22:23:02 +00:00
|
|
|
JPN=0
|
2021-10-23 01:27:59 +00:00
|
|
|
ZIPMAGIC=0x0000
|
2020-04-14 07:12:59 +00:00
|
|
|
|
|
|
|
ifeq ($(ROMID),ntsc-beta)
|
|
|
|
NTSC=1
|
|
|
|
VERSION=0
|
2021-03-19 12:15:48 +00:00
|
|
|
PIRACYCHECKS=0
|
2020-04-14 07:12:59 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(ROMID),ntsc-1.0)
|
|
|
|
NTSC=1
|
|
|
|
VERSION=1
|
2021-10-23 01:27:59 +00:00
|
|
|
ZIPMAGIC=0xffff
|
2020-04-14 07:12:59 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(ROMID),ntsc-final)
|
|
|
|
NTSC=1
|
|
|
|
VERSION=2
|
2021-10-23 01:27:59 +00:00
|
|
|
ZIPMAGIC=0xffff
|
2020-04-14 07:12:59 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(ROMID),pal-beta)
|
|
|
|
PAL=1
|
|
|
|
VERSION=3
|
2021-10-23 01:27:59 +00:00
|
|
|
ZIPMAGIC=0x0c00
|
2020-04-14 07:12:59 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(ROMID),pal-final)
|
|
|
|
PAL=1
|
|
|
|
VERSION=4
|
2021-10-23 01:27:59 +00:00
|
|
|
ZIPMAGIC=0xaf00
|
2020-04-14 07:12:59 +00:00
|
|
|
endif
|
2021-01-03 22:23:02 +00:00
|
|
|
ifeq ($(ROMID),jpn-final)
|
|
|
|
JPN=1
|
2020-04-14 07:12:59 +00:00
|
|
|
VERSION=5
|
2021-10-23 01:27:59 +00:00
|
|
|
ZIPMAGIC=0x0002
|
2020-04-14 07:12:59 +00:00
|
|
|
endif
|
|
|
|
|
2021-10-14 07:52:32 +00:00
|
|
|
DEFINES := VERSION=$(VERSION) NTSC=$(NTSC) PAL=$(PAL) JPN=$(JPN) PIRACYCHECKS=$(PIRACYCHECKS) _FINALROM=1
|
2021-10-05 10:51:32 +00:00
|
|
|
|
|
|
|
C_DEFINES := $(foreach d,$(DEFINES),-D$(d))
|
|
|
|
AS_DEFINES := $(foreach d,$(DEFINES),--defsym $(d)) --defsym _LANGUAGE_ASSEMBLY=1
|
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
A_DIR := src/assets/$(ROMID)
|
2019-09-05 22:09:40 +00:00
|
|
|
B_DIR := build/$(ROMID)
|
2021-03-26 07:46:16 +00:00
|
|
|
E_DIR := extracted/$(ROMID)
|
2019-09-07 06:12:32 +00:00
|
|
|
|
2020-11-02 08:05:10 +00:00
|
|
|
ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
|
|
|
# Debian, Ubuntu and Arch AUR
|
2019-09-07 06:12:32 +00:00
|
|
|
TOOLCHAIN := mips-linux-gnu
|
2020-11-02 08:05:10 +00:00
|
|
|
else ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
|
|
|
# Arch AUR
|
|
|
|
TOOLCHAIN := mips64-elf
|
2019-12-08 07:50:05 +00:00
|
|
|
else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
|
|
|
TOOLCHAIN := mips64-linux-gnu
|
2019-09-07 06:12:32 +00:00
|
|
|
else
|
2019-12-08 09:59:44 +00:00
|
|
|
TOOLCHAIN := mips-elf
|
2019-09-07 06:12:32 +00:00
|
|
|
endif
|
|
|
|
|
2021-10-05 10:51:32 +00:00
|
|
|
AS := $(TOOLCHAIN)-as
|
|
|
|
|
2021-10-12 07:47:45 +00:00
|
|
|
LOOPUNROLL_C_FILES := \
|
|
|
|
src/lib/ultra/gu/frustum.c \
|
|
|
|
src/lib/ultra/gu/mtxutil.c \
|
|
|
|
src/lib/ultra/gu/ortho.c \
|
|
|
|
src/lib/ultra/io/conteepread.c \
|
|
|
|
src/lib/ultra/io/conteepwrite.c \
|
|
|
|
src/lib/ultra/io/contpfs.c \
|
|
|
|
src/lib/ultra/io/contramread.c \
|
|
|
|
src/lib/ultra/io/contramwrite.c \
|
|
|
|
src/lib/ultra/io/gbpakgetstatus.c \
|
|
|
|
src/lib/ultra/io/gbpakreadid.c \
|
|
|
|
src/lib/ultra/io/motor.c \
|
|
|
|
src/lib/ultra/io/pfschecker.c \
|
|
|
|
src/lib/ultra/io/pfsfreeblocks.c \
|
|
|
|
src/lib/ultra/io/pfsgetstatus.c \
|
|
|
|
src/lib/ultra/io/pfsinitpak2.c
|
|
|
|
|
|
|
|
MIPS3_C_FILES := \
|
|
|
|
src/lib/ultra/libc/ll.c \
|
|
|
|
src/lib/ultra/libc/llcvt.c
|
|
|
|
|
|
|
|
G_C_FILES := \
|
|
|
|
$(shell find src/lib/ultra/audio -name '*.c') \
|
2021-10-14 07:52:32 +00:00
|
|
|
$(shell find src/lib/naudio -name '*.c') \
|
2021-11-19 12:50:16 +00:00
|
|
|
$(shell find src/lib/mp3 -name '*.c') \
|
2021-11-01 08:24:38 +00:00
|
|
|
src/lib/lib_2fc60.c \
|
2021-10-17 05:31:00 +00:00
|
|
|
src/lib/lib_317f0.c \
|
2021-10-31 13:05:37 +00:00
|
|
|
src/lib/lib_39c80.c \
|
2021-11-01 07:54:16 +00:00
|
|
|
src/lib/lib_3e3e0.c \
|
2021-10-12 07:47:45 +00:00
|
|
|
src/lib/mp3.c \
|
|
|
|
src/lib/speaker.c
|
|
|
|
|
|
|
|
O1_C_FILES := \
|
2021-11-01 08:09:10 +00:00
|
|
|
src/lib/lib_04f60nb.c \
|
2021-10-12 07:47:45 +00:00
|
|
|
src/lib/ultra/io/ai.c \
|
|
|
|
src/lib/ultra/io/aisetnextbuf.c \
|
|
|
|
src/lib/ultra/io/conteeplongread.c \
|
|
|
|
src/lib/ultra/io/contquery.c \
|
|
|
|
src/lib/ultra/io/controller.c \
|
|
|
|
src/lib/ultra/io/dpctr.c \
|
|
|
|
src/lib/ultra/io/pigetcmdq.c \
|
|
|
|
src/lib/ultra/io/pidma.c \
|
|
|
|
src/lib/ultra/io/si.c \
|
|
|
|
src/lib/ultra/io/sp.c \
|
|
|
|
src/lib/ultra/io/spsetpc.c \
|
|
|
|
src/lib/ultra/io/sptaskyielded.c \
|
|
|
|
src/lib/ultra/io/vi.c \
|
|
|
|
src/lib/ultra/io/viblack.c \
|
|
|
|
src/lib/ultra/io/vigetcurrframebuf.c \
|
|
|
|
src/lib/ultra/io/vigetnextframebuf.c \
|
|
|
|
src/lib/ultra/io/visetevent.c \
|
|
|
|
src/lib/ultra/io/visetmode.c \
|
|
|
|
src/lib/ultra/io/visetxscale.c \
|
|
|
|
src/lib/ultra/io/visetyscale.c \
|
|
|
|
src/lib/ultra/io/viswapbuf.c \
|
|
|
|
src/lib/ultra/libc/ll.c \
|
|
|
|
src/lib/ultra/libc/llcvt.c \
|
|
|
|
src/lib/ultra/os/atomic.c \
|
|
|
|
src/lib/ultra/os/createmesgqueue.c \
|
|
|
|
src/lib/ultra/os/destroythread.c \
|
|
|
|
src/lib/ultra/os/gettime.c \
|
2021-11-02 12:21:23 +00:00
|
|
|
src/lib/ultra/os/initialize2.c \
|
2021-10-12 07:47:45 +00:00
|
|
|
src/lib/ultra/os/jammesg.c \
|
|
|
|
src/lib/ultra/os/recvmesg.c \
|
|
|
|
src/lib/ultra/os/resetglobalintmask.c \
|
|
|
|
src/lib/ultra/os/sendmesg.c \
|
|
|
|
src/lib/ultra/os/seteventmesg.c \
|
|
|
|
src/lib/ultra/os/setglobalintmask.c \
|
|
|
|
src/lib/ultra/os/setthreadpri.c \
|
|
|
|
src/lib/ultra/os/settimer.c \
|
|
|
|
src/lib/ultra/os/startthread.c \
|
|
|
|
src/lib/ultra/os/stopthread.c \
|
|
|
|
src/lib/ultra/os/stoptimer.c \
|
|
|
|
src/lib/ultra/os/thread.c \
|
|
|
|
src/lib/ultra/os/timerintr.c \
|
|
|
|
src/lib/ultra/os/virtualtophysical.c \
|
|
|
|
src/lib/ultra/os/yieldthread.c
|
2021-01-25 07:38:12 +00:00
|
|
|
|
2021-03-19 12:15:48 +00:00
|
|
|
ifeq ($(ROMID), ntsc-beta)
|
2021-10-12 07:47:45 +00:00
|
|
|
O1_C_FILES := $(O1_C_FILES) src/lib/ultra/io/pfsisplug.c
|
2021-03-19 12:15:48 +00:00
|
|
|
endif
|
|
|
|
|
2021-10-12 07:47:45 +00:00
|
|
|
O3_C_FILES := \
|
|
|
|
src/lib/ultra/gu/align.c \
|
|
|
|
src/lib/ultra/gu/frustum.c \
|
|
|
|
src/lib/ultra/gu/ortho.c \
|
2021-11-02 11:00:00 +00:00
|
|
|
src/lib/ultra/gu/scale.c \
|
|
|
|
src/lib/ultra/libc/xprintf.c
|
2021-10-12 07:47:45 +00:00
|
|
|
|
2021-10-15 13:44:10 +00:00
|
|
|
IDO71_C_FILES := \
|
2021-10-17 05:44:37 +00:00
|
|
|
$(shell find src/lib/ultra/audio -name '*.c') \
|
2021-10-15 15:07:37 +00:00
|
|
|
$(shell find src/lib/naudio -name '*.c') \
|
2021-11-19 12:50:16 +00:00
|
|
|
$(shell find src/lib/mp3 -name '*.c') \
|
2021-11-01 09:17:21 +00:00
|
|
|
src/lib/lib_2fc60.c \
|
2021-11-19 12:50:16 +00:00
|
|
|
src/lib/lib_39c80.c
|
2021-10-15 13:44:10 +00:00
|
|
|
|
2021-10-12 07:47:45 +00:00
|
|
|
LOOPUNROLL_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(LOOPUNROLL_C_FILES))
|
|
|
|
MIPS3_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(MIPS3_C_FILES))
|
|
|
|
G_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(G_C_FILES))
|
|
|
|
O1_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(O1_C_FILES))
|
|
|
|
O3_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(O3_C_FILES))
|
2021-10-15 13:44:10 +00:00
|
|
|
IDO71_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(IDO71_C_FILES))
|
2021-10-12 07:47:45 +00:00
|
|
|
|
|
|
|
LOOPUNROLL := -Wo,-loopunroll,0
|
|
|
|
MIPSISET := -mips2 -32
|
|
|
|
OPT_LVL := -O2
|
|
|
|
|
|
|
|
$(LOOPUNROLL_O_FILES): LOOPUNROLL :=
|
|
|
|
$(MIPS3_O_FILES): MIPSISET := -mips3 -32
|
|
|
|
$(G_O_FILES): OPT_LVL := -g
|
|
|
|
$(O1_O_FILES): OPT_LVL := -O1
|
|
|
|
$(O3_O_FILES): OPT_LVL := -O3
|
2021-10-15 13:44:10 +00:00
|
|
|
$(IDO71_O_FILES): CC := $(CC71)
|
2021-10-12 07:47:45 +00:00
|
|
|
|
2021-10-05 10:51:32 +00:00
|
|
|
CFLAGS = $(C_DEFINES) \
|
2021-01-28 22:24:42 +00:00
|
|
|
$(LOOPUNROLL) \
|
2020-04-14 07:12:59 +00:00
|
|
|
-Wab,-r4300_mul \
|
|
|
|
-non_shared \
|
2021-04-24 01:23:05 +00:00
|
|
|
-Olimit 1000 \
|
2020-04-14 07:12:59 +00:00
|
|
|
-G 0 \
|
|
|
|
-Xcpluscomm \
|
2021-11-18 10:57:34 +00:00
|
|
|
-w2 \
|
|
|
|
-Wab,-w \
|
2020-04-14 09:42:57 +00:00
|
|
|
-woff 581,649,819,820,821,838,852 \
|
2021-10-14 07:52:32 +00:00
|
|
|
-I include \
|
|
|
|
-I include/PR \
|
2020-04-14 07:12:59 +00:00
|
|
|
-I src/include \
|
2021-06-11 08:36:29 +00:00
|
|
|
-I src/generated/$(ROMID) \
|
2021-10-14 07:52:32 +00:00
|
|
|
-I src/lib/ultra/audio \
|
2021-01-30 07:28:30 +00:00
|
|
|
$(OPT_LVL) \
|
2021-01-25 07:38:12 +00:00
|
|
|
$(MIPSISET)
|
2019-10-07 07:50:26 +00:00
|
|
|
|
2021-10-14 07:52:32 +00:00
|
|
|
ASFLAGS = -march=vr4300 -mabi=32 -Iinclude -Iinclude/PR -Isrc/include -Isrc/lib/ultra/audio $(AS_DEFINES)
|
2021-10-05 10:51:32 +00:00
|
|
|
|
2021-03-15 13:28:01 +00:00
|
|
|
C_FILES := $(shell find src/lib src/game src/inflate -name '*.c')
|
2021-10-05 13:24:25 +00:00
|
|
|
S_FILES := $(shell find src/lib src/game src/preamble -name '*.s')
|
2021-01-26 07:14:42 +00:00
|
|
|
|
2021-10-12 07:47:45 +00:00
|
|
|
# Files containing GLOBAL_ASM must be built with the asm_processor
|
|
|
|
GLOBALASM_C_FILES != grep -rl 'GLOBAL_ASM(' $(C_FILES)
|
|
|
|
GLOBALASM_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(GLOBALASM_C_FILES))
|
|
|
|
|
2021-10-15 13:44:10 +00:00
|
|
|
$(GLOBALASM_O_FILES): CC := /usr/bin/env python3 tools/asm_processor/build.py $(CC) -- $(TOOLCHAIN)-as $(ASFLAGS) --
|
2021-10-12 07:47:45 +00:00
|
|
|
|
2021-11-07 00:51:02 +00:00
|
|
|
# Asset files are files which are included in the "files" segment of the ROM.
|
|
|
|
# This excludes animations, fonts, SFX, MIDI and textures.
|
|
|
|
# And because setup files are part of the files segment they are included here,
|
|
|
|
# despite them being written in C.
|
|
|
|
#
|
2021-03-26 07:46:16 +00:00
|
|
|
# Create names such as $(B_DIR)/assets/files/PfooZ.
|
|
|
|
# These names (with .o added) will be dependenices for ld.
|
2021-02-12 07:07:02 +00:00
|
|
|
ASSET_FILES := \
|
2021-11-07 00:51:02 +00:00
|
|
|
$(patsubst $(A_DIR)/files/audio/%.mp3, $(B_DIR)/assets/files/A%M, $(shell find $(A_DIR)/files/audio -name '*.mp3')) \
|
|
|
|
$(patsubst $(A_DIR)/files/chrs/%.bin, $(B_DIR)/assets/files/C%Z, $(shell find $(A_DIR)/files/chrs -name '*.bin')) \
|
|
|
|
$(patsubst $(A_DIR)/files/guns/%.bin, $(B_DIR)/assets/files/G%Z, $(shell find $(A_DIR)/files/guns -name '*.bin')) \
|
|
|
|
$(patsubst $(A_DIR)/files/props/%.bin, $(B_DIR)/assets/files/P%Z, $(shell find $(A_DIR)/files/props -name '*.bin')) \
|
|
|
|
$(patsubst src/files/setup/%.c, $(B_DIR)/assets/files/U%Z, $(shell find src/files/setup -name '*.c')) \
|
|
|
|
$(patsubst $(A_DIR)/files/bgdata/%.seg, $(B_DIR)/assets/files/bgdata/%.seg, $(shell find $(A_DIR)/files/bgdata -name '*.seg')) \
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/files/ob/ob_mid.seg.o
|
|
|
|
|
2021-11-07 00:51:02 +00:00
|
|
|
LANG_JSON_FILES := $(shell find $(A_DIR) -path '*/lang/*.json')
|
|
|
|
PADS_JSON_FILES := $(shell find $(A_DIR) -path '*/pads/*.json')
|
|
|
|
TILES_JSON_FILES := $(shell find $(A_DIR) -path '*/tiles/*.json')
|
2021-06-11 08:36:29 +00:00
|
|
|
|
|
|
|
LANG_O_FILES := $(patsubst $(A_DIR)/lang/%.json, $(B_DIR)/assets/files/L%.o, $(LANG_JSON_FILES))
|
|
|
|
PADS_O_FILES := $(patsubst $(A_DIR)/pads/%.json, $(B_DIR)/assets/files/bgdata/bg_%_padsZ.o, $(PADS_JSON_FILES))
|
2021-11-07 00:51:02 +00:00
|
|
|
TILES_O_FILES := $(patsubst $(A_DIR)/tiles/%.json, $(B_DIR)/assets/files/bgdata/bg_%_tilesZ.o, $(TILES_JSON_FILES))
|
2021-06-11 08:36:29 +00:00
|
|
|
|
2021-02-12 07:07:02 +00:00
|
|
|
O_FILES := \
|
|
|
|
$(patsubst src/%.c, $(B_DIR)/%.o, $(C_FILES)) \
|
|
|
|
$(patsubst src/%.s, $(B_DIR)/%.o, $(S_FILES)) \
|
|
|
|
$(patsubst %, %.o, $(ASSET_FILES)) \
|
2021-06-11 08:36:29 +00:00
|
|
|
$(LANG_O_FILES) \
|
|
|
|
$(PADS_O_FILES) \
|
2021-11-07 00:51:02 +00:00
|
|
|
$(TILES_O_FILES) \
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/bootloader.o \
|
2021-06-11 08:36:29 +00:00
|
|
|
$(B_DIR)/assets/animations.o \
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/copyrightZ.o \
|
|
|
|
$(B_DIR)/assets/files/list.o \
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/firingrange.o \
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/fonts/bankgothic.o \
|
|
|
|
$(B_DIR)/assets/fonts/handelgothiclg.o \
|
|
|
|
$(B_DIR)/assets/fonts/handelgothicmd.o \
|
|
|
|
$(B_DIR)/assets/fonts/handelgothicsm.o \
|
|
|
|
$(B_DIR)/assets/fonts/handelgothicxs.o \
|
|
|
|
$(B_DIR)/assets/fonts/numeric.o \
|
|
|
|
$(B_DIR)/assets/fonts/ocralg.o \
|
|
|
|
$(B_DIR)/assets/fonts/ocramd.o \
|
|
|
|
$(B_DIR)/assets/fonts/tahoma.o \
|
|
|
|
$(B_DIR)/assets/fonts/zurich.o \
|
2021-10-23 01:27:59 +00:00
|
|
|
$(B_DIR)/garbage.o \
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/getitle.o \
|
|
|
|
$(B_DIR)/mpconfigs.o \
|
|
|
|
$(B_DIR)/assets/mpstrings/mpstringsE.o \
|
|
|
|
$(B_DIR)/assets/mpstrings/mpstringsF.o \
|
|
|
|
$(B_DIR)/assets/mpstrings/mpstringsG.o \
|
|
|
|
$(B_DIR)/assets/mpstrings/mpstringsI.o \
|
|
|
|
$(B_DIR)/assets/mpstrings/mpstringsJ.o \
|
|
|
|
$(B_DIR)/assets/mpstrings/mpstringsP.o \
|
|
|
|
$(B_DIR)/assets/mpstrings/mpstringsS.o \
|
|
|
|
$(B_DIR)/rsp/rspboot.text.o \
|
|
|
|
$(B_DIR)/rsp/asp.data.o \
|
|
|
|
$(B_DIR)/rsp/asp.text.o \
|
|
|
|
$(B_DIR)/rsp/gsp.data.o \
|
|
|
|
$(B_DIR)/rsp/gsp.text.o \
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/seq.ctl.o \
|
|
|
|
$(B_DIR)/assets/seq.tbl.o \
|
|
|
|
$(B_DIR)/assets/sequences.o \
|
|
|
|
$(B_DIR)/assets/sfx.ctl.o \
|
|
|
|
$(B_DIR)/assets/sfx.tbl.o \
|
2021-02-12 14:01:41 +00:00
|
|
|
$(B_DIR)/assets/textureslist.o \
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/textures/config.o \
|
2021-02-17 02:22:23 +00:00
|
|
|
$(B_DIR)/romheader.o
|
2020-12-20 12:06:23 +00:00
|
|
|
|
2021-03-19 12:15:48 +00:00
|
|
|
# ntsc-beta doesn't have this segment
|
|
|
|
ifneq ($(ROMID), ntsc-beta)
|
|
|
|
O_FILES := $(O_FILES) $(B_DIR)/assets/accessingpakZ.o
|
|
|
|
endif
|
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
default: rom
|
2019-09-05 22:09:40 +00:00
|
|
|
|
|
|
|
################################################################################
|
2020-08-25 10:40:35 +00:00
|
|
|
# ROM Finalisation Stages
|
2019-09-05 22:09:40 +00:00
|
|
|
|
2021-02-12 07:07:02 +00:00
|
|
|
# Link all objects together with ld to make stage1.elf. In this stage, the game,
|
|
|
|
# lib and data segments are uncompressed and placed past the end of the ROM.
|
|
|
|
$(B_DIR)/stage1.elf: $(O_FILES) ld/pd.ld
|
|
|
|
cpp -DROMID=$(ROMID) -DVERSION=$(VERSION) -P ld/pd.ld -o $(B_DIR)/pd.ld
|
|
|
|
$(TOOLCHAIN)-ld --no-check-sections -T $(B_DIR)/pd.ld --print-map -o $@ > $(B_DIR)/pd.map
|
2020-08-25 10:40:35 +00:00
|
|
|
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/stage1.bin: $(B_DIR)/stage1.elf
|
|
|
|
$(TOOLCHAIN)-objcopy $< $@ -O binary
|
2020-08-25 10:40:35 +00:00
|
|
|
|
2021-10-23 01:27:59 +00:00
|
|
|
# Build the final ROM from stage1.bin using mkrom
|
|
|
|
# mkrom handles calculating the piracy checksums, zipping segments and
|
|
|
|
# calculating the ROM checksum.
|
|
|
|
$(B_DIR)/pd.z64: $(B_DIR)/stage1.bin tools/mkrom/mkrom
|
|
|
|
tools/mkrom/mkrom $(B_DIR)/stage1.bin $(B_DIR)/pd.map $(PIRACYCHECKS) $(ZIPMAGIC) $@
|
2020-08-25 10:40:35 +00:00
|
|
|
|
2021-10-23 01:27:59 +00:00
|
|
|
tools/mkrom/mkrom:
|
|
|
|
$(MAKE) -C tools/mkrom
|
2021-02-12 07:07:02 +00:00
|
|
|
|
2019-09-05 22:09:40 +00:00
|
|
|
################################################################################
|
2020-08-25 10:40:35 +00:00
|
|
|
# Testing Related
|
|
|
|
# ---------------------
|
|
|
|
# This works a little backwards, in that the ROM has to be built to at least
|
|
|
|
# stage 2, then extract-segment is used to slice out the segments.
|
|
|
|
|
2021-06-11 08:36:29 +00:00
|
|
|
CHECK_FILES := $(shell awk '{print $$2}' checksums.$(ROMID).md5)
|
|
|
|
|
|
|
|
test: $(CHECK_FILES)
|
2020-08-25 10:40:35 +00:00
|
|
|
@md5sum --quiet -c checksums.$(ROMID).md5
|
2019-09-05 22:09:40 +00:00
|
|
|
|
2021-10-23 01:27:59 +00:00
|
|
|
$(B_DIR)/segments/%.bin: $(B_DIR)/pd.z64
|
2020-08-25 10:40:35 +00:00
|
|
|
@B_DIR=$(B_DIR) tools/extract-segment $*
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Raw data segments
|
2019-09-05 22:09:40 +00:00
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/fonts/%.o: $(A_DIR)/fonts/%.bin
|
2021-02-12 07:07:02 +00:00
|
|
|
mkdir -p $(B_DIR)/assets/fonts
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
2021-10-23 01:27:59 +00:00
|
|
|
|
|
|
|
$(B_DIR)/garbage.o: $(E_DIR)/garbage.bin
|
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
2020-08-25 10:40:35 +00:00
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/getitle.o: $(E_DIR)/getitle.bin
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/seq.ctl.o: $(A_DIR)/seq.ctl
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/seq.tbl.o: $(A_DIR)/seq.tbl
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/sfx.ctl.o: $(A_DIR)/sfx.ctl
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/sfx.tbl.o: $(A_DIR)/sfx.tbl
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
2021-06-11 08:36:29 +00:00
|
|
|
################################################################################
|
|
|
|
# Asset Manager
|
|
|
|
|
|
|
|
ASSETMGR_O_FILES := \
|
|
|
|
$(B_DIR)/assets/animations.o \
|
|
|
|
$(LANG_O_FILES) \
|
|
|
|
$(PADS_O_FILES) \
|
2021-11-07 00:51:02 +00:00
|
|
|
$(TILES_O_FILES) \
|
2021-06-11 08:36:29 +00:00
|
|
|
$(B_DIR)/assets/sequences.o \
|
|
|
|
$(B_DIR)/assets/textureslist.o \
|
|
|
|
|
|
|
|
# Anims
|
|
|
|
$(B_DIR)/assets/animations.o: $(A_DIR)/animations.json
|
|
|
|
tools/assetmgr/mkanims
|
|
|
|
|
|
|
|
# Lang
|
|
|
|
$(B_DIR)/assets/files/L%.o: $(A_DIR)/lang/%.json
|
|
|
|
tools/assetmgr/mklang $<
|
|
|
|
|
|
|
|
# Lang - but this is the zipped non-obj, for make test
|
|
|
|
$(B_DIR)/assets/files/L%: $(A_DIR)/lang/%.json
|
|
|
|
tools/assetmgr/mklang $<
|
|
|
|
|
|
|
|
# Pads
|
|
|
|
$(B_DIR)/assets/files/bgdata/bg_%_padsZ.o: $(A_DIR)/pads/%.json
|
|
|
|
tools/assetmgr/mkpads $<
|
|
|
|
|
|
|
|
# Pads - but this is the zipped non-obj, for make test
|
|
|
|
$(B_DIR)/assets/files/bgdata/bg_%_padsZ: $(A_DIR)/pads/%.json
|
|
|
|
tools/assetmgr/mkpads $<
|
|
|
|
|
|
|
|
# Sequences
|
|
|
|
$(B_DIR)/assets/sequences.o: $(A_DIR)/sequences.json
|
|
|
|
tools/assetmgr/mksequences
|
|
|
|
|
|
|
|
# Textures
|
|
|
|
$(B_DIR)/assets/textureslist.o: $(A_DIR)/textures.json
|
|
|
|
tools/assetmgr/mktextures
|
2019-09-07 12:07:13 +00:00
|
|
|
|
2021-11-07 00:51:02 +00:00
|
|
|
# Tiles
|
|
|
|
$(B_DIR)/assets/files/bgdata/bg_%_tilesZ.o: $(A_DIR)/tiles/%.json
|
|
|
|
tools/assetmgr/mktiles $<
|
|
|
|
|
|
|
|
# Tiles - but this is the zipped non-obj, for make test
|
|
|
|
$(B_DIR)/assets/files/bgdata/bg_%_tilesZ: $(A_DIR)/tiles/%.json
|
|
|
|
tools/assetmgr/mktiles $<
|
|
|
|
|
2019-12-07 14:19:45 +00:00
|
|
|
################################################################################
|
2020-08-25 10:40:35 +00:00
|
|
|
# Files
|
2019-09-05 22:09:40 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
# Audio
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/files/A%M: $(A_DIR)/files/audio/%.mp3
|
2021-02-12 07:07:02 +00:00
|
|
|
@mkdir -p $(B_DIR)/assets/files
|
2019-12-07 14:19:45 +00:00
|
|
|
cp $< $@
|
2019-09-07 12:07:13 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
# BG segs
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/files/bgdata/bg_%.seg: $(A_DIR)/files/bgdata/bg_%.seg
|
2021-02-12 07:07:02 +00:00
|
|
|
@mkdir -p $(B_DIR)/assets/files/bgdata
|
2020-08-25 10:40:35 +00:00
|
|
|
cp $< $@
|
2019-10-07 07:50:26 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
# Chrs
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/files/C%Z: $(A_DIR)/files/chrs/%.bin
|
2021-02-12 07:07:02 +00:00
|
|
|
@mkdir -p $(B_DIR)/assets/files
|
|
|
|
tools/rarezip $< > $@
|
2019-12-07 14:19:45 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
# Guns
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/files/G%Z: $(A_DIR)/files/guns/%.bin
|
2021-02-12 07:07:02 +00:00
|
|
|
@mkdir -p $(B_DIR)/assets/files
|
|
|
|
tools/rarezip $< > $@
|
2019-12-07 14:19:45 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
# OB seg
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/files/ob/ob_mid.seg.o: $(B_DIR)/assets/files/ob/ob_mid.seg
|
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
|
|
|
$(B_DIR)/assets/files/ob/ob_mid.seg:
|
|
|
|
@mkdir -p $(B_DIR)/assets/files/ob
|
2019-12-07 14:19:45 +00:00
|
|
|
> $@
|
2019-09-05 22:09:40 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
# Props
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/files/P%Z: $(A_DIR)/files/props/%.bin
|
2021-02-12 07:07:02 +00:00
|
|
|
tools/rarezip $< > $@
|
2019-12-07 14:19:45 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
# Stage setups
|
2021-03-26 07:46:16 +00:00
|
|
|
# $(A_DIR)/files/setup/foo.c
|
|
|
|
# -> B_DIR/assets/files/setup/foo.o (done here)
|
2021-02-12 07:07:02 +00:00
|
|
|
# -> B_DIR/assets/files/setup/foo.elf (done here)
|
2021-11-07 00:51:02 +00:00
|
|
|
# -> B_DIR/assets/files/setup/foo.bin (done here)
|
2021-02-12 07:07:02 +00:00
|
|
|
# -> B_DIR/assets/files/UsetupfooZ (done here)
|
2021-03-26 07:46:16 +00:00
|
|
|
# -> B_DIR/assets/files/UsetupfooZ.o (done elsewhere)
|
2021-06-14 12:09:08 +00:00
|
|
|
$(B_DIR)/assets/files/setup/%.o: src/files/setup/%.c $(ASSETMGR_O_FILES)
|
2021-03-26 07:46:16 +00:00
|
|
|
@mkdir -p $(dir $@)
|
2021-10-15 13:44:10 +00:00
|
|
|
$(CC) -c $(CFLAGS) -o $@ $<
|
2021-03-26 07:46:16 +00:00
|
|
|
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/files/setup/%.elf: $(B_DIR)/assets/files/setup/%.o
|
2020-12-12 11:54:19 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) tools/mksimpleelf $< $@
|
2019-12-07 14:19:45 +00:00
|
|
|
|
2021-11-07 00:51:02 +00:00
|
|
|
$(B_DIR)/files/setup/%.bin: $(B_DIR)/assets/files/setup/%.elf
|
2021-03-26 07:46:16 +00:00
|
|
|
@mkdir -p $(dir $@)
|
2021-02-12 07:07:02 +00:00
|
|
|
$(TOOLCHAIN)-objcopy $< $@ -O binary
|
|
|
|
|
2021-11-07 00:51:02 +00:00
|
|
|
$(B_DIR)/assets/files/U%Z: $(B_DIR)/files/setup/%.bin
|
2021-02-12 07:07:02 +00:00
|
|
|
tools/rarezip $< > $@
|
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
# General target to convert any finalised file into a raw object for ld
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/files/%.o: $(B_DIR)/assets/files/%
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
2020-04-26 11:48:17 +00:00
|
|
|
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/files/%.bin: $(B_DIR)/assets/files/%.elf
|
2020-08-25 10:40:35 +00:00
|
|
|
$(TOOLCHAIN)-objcopy $< $@ -O binary
|
2020-04-27 07:42:02 +00:00
|
|
|
|
2019-12-07 08:03:53 +00:00
|
|
|
################################################################################
|
2019-12-07 14:19:45 +00:00
|
|
|
# Miscellaneous
|
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/bootloader.o: $(E_DIR)/bootloader.bin
|
2021-02-17 02:22:23 +00:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
$(B_DIR)/romheader.o: src/romheader/romheader.s
|
|
|
|
$(TOOLCHAIN)-as --defsym VERSION=$(VERSION) -march=vr4300 -mabi=32 -I src/include -EB -o $@ $<
|
2019-12-07 08:03:53 +00:00
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/accessingpakZ: $(A_DIR)/accessingpak.bin
|
2020-08-25 10:40:35 +00:00
|
|
|
tools/rarezip $< > $@
|
2019-12-07 08:03:53 +00:00
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/copyrightZ: $(A_DIR)/copyright.bin
|
2020-08-25 10:40:35 +00:00
|
|
|
tools/rarezip $< > $@
|
2019-09-07 12:07:13 +00:00
|
|
|
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/accessingpakZ.o: $(B_DIR)/assets/accessingpakZ
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
2021-02-12 07:07:02 +00:00
|
|
|
$(B_DIR)/assets/copyrightZ.o: $(B_DIR)/assets/copyrightZ
|
2020-08-25 10:40:35 +00:00
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
2019-09-05 22:09:40 +00:00
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/rsp/%.o: $(E_DIR)/rsp/%.bin
|
2021-02-17 02:22:23 +00:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
|
|
|
|
|
2021-06-14 12:09:08 +00:00
|
|
|
$(B_DIR)/lib/ultra/libc/llcvt.o: src/lib/ultra/libc/llcvt.c $(ASSETMGR_O_FILES)
|
2021-01-25 07:43:41 +00:00
|
|
|
@mkdir -p $(dir $@)
|
2021-10-15 13:44:10 +00:00
|
|
|
$(CC) -c $(CFLAGS) -o $@ $<
|
2021-01-25 07:43:41 +00:00
|
|
|
tools/patchmips3 $@ || rm $@
|
|
|
|
|
2021-06-14 12:09:08 +00:00
|
|
|
$(B_DIR)/lib/ultra/libc/ll.o: src/lib/ultra/libc/ll.c $(ASSETMGR_O_FILES)
|
2021-01-25 07:38:12 +00:00
|
|
|
@mkdir -p $(dir $@)
|
2021-10-15 13:44:10 +00:00
|
|
|
$(CC) -c $(CFLAGS) $< -o $@
|
2021-01-25 07:38:12 +00:00
|
|
|
tools/patchmips3 $@ || rm $@
|
|
|
|
|
2021-06-11 08:36:29 +00:00
|
|
|
$(B_DIR)/%.o: src/%.c $(ASSETMGR_O_FILES)
|
2021-01-16 13:46:33 +00:00
|
|
|
@mkdir -p $(dir $@)
|
2021-10-15 13:44:10 +00:00
|
|
|
$(CC) -c $(CFLAGS) -o $@ $<
|
2021-01-16 13:46:33 +00:00
|
|
|
|
2021-01-26 07:14:42 +00:00
|
|
|
$(B_DIR)/%.o: src/%.s
|
|
|
|
@mkdir -p $(dir $@)
|
2021-10-14 07:52:32 +00:00
|
|
|
cpp -P -Wno-trigraphs -I include -I include/PR -I src/include $(C_DEFINES) -D_LANGUAGE_ASSEMBLY -D_MIPSEB $< | $(AS) $(ASFLAGS) -o $@
|
2021-01-26 07:14:42 +00:00
|
|
|
|
2021-03-26 07:46:16 +00:00
|
|
|
$(B_DIR)/assets/%.o: $(A_DIR)/%.c
|
|
|
|
@mkdir -p $(dir $@)
|
2021-10-15 13:44:10 +00:00
|
|
|
$(CC) -c $(CFLAGS) -o $@ $<
|
2021-03-26 07:46:16 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
extract:
|
|
|
|
ROMID=$(ROMID) tools/extract
|
2019-12-07 08:03:53 +00:00
|
|
|
|
2020-08-25 10:40:35 +00:00
|
|
|
rom: $(B_DIR)/pd.z64
|
2019-09-05 22:09:40 +00:00
|
|
|
|
|
|
|
clean:
|
2020-04-19 13:53:08 +00:00
|
|
|
rm -rf build/$(ROMID)
|
|
|
|
|
|
|
|
allclean:
|
2019-09-05 22:09:40 +00:00
|
|
|
rm -rf build/*
|
|
|
|
|
2020-04-19 13:53:08 +00:00
|
|
|
codeclean:
|
2021-03-15 13:28:01 +00:00
|
|
|
find $(B_DIR)/{game,inflate,lib} -name '*.o' -delete
|