perfect_dark/Makefile

540 lines
20 KiB
Makefile
Raw Normal View History

2019-09-05 22:09:40 +00:00
# User configurable
2020-04-14 07:12:59 +00:00
ROMID ?= ntsc-final
PIRACYCHECKS ?= 1
QEMU_IRIX ?= tools/irix/qemu-irix
IRIX_ROOT ?= tools/irix/root
2019-09-05 22:09:40 +00:00
IDOCC ?= $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
2021-01-26 07:14:42 +00:00
IDOAS ?= $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/as
2019-09-05 22:09:40 +00:00
################################################################################
2021-04-25 06:48:18 +00:00
QEMUCC = $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
QEMUAS = $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/as
2020-04-14 07:12:59 +00:00
export ROMID
NTSC=0
PAL=0
2021-01-03 22:23:02 +00:00
JPN=0
2020-04-14 07:12:59 +00:00
ifeq ($(ROMID),ntsc-beta)
NTSC=1
VERSION=0
PIRACYCHECKS=0
2020-04-14 07:12:59 +00:00
endif
ifeq ($(ROMID),ntsc-1.0)
NTSC=1
VERSION=1
endif
ifeq ($(ROMID),ntsc-final)
NTSC=1
VERSION=2
endif
ifeq ($(ROMID),pal-beta)
PAL=1
VERSION=3
endif
ifeq ($(ROMID),pal-final)
PAL=1
VERSION=4
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
endif
A_DIR := src/assets/$(ROMID)
2019-09-05 22:09:40 +00:00
B_DIR := build/$(ROMID)
E_DIR := extracted/$(ROMID)
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
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
else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
TOOLCHAIN := mips64-linux-gnu
else
2019-12-08 09:59:44 +00:00
TOOLCHAIN := mips-elf
endif
2021-01-25 07:38:12 +00:00
MIPSISET := -mips2 -32
2021-01-26 09:31:50 +00:00
OPT_LVL := -O2
2021-01-28 22:24:42 +00:00
LOOPUNROLL := -Wo,-loopunroll,0
2021-01-29 13:29:37 +00:00
$(B_DIR)/lib/ultra/gu/frustum.o: LOOPUNROLL :=
2021-01-29 15:02:51 +00:00
$(B_DIR)/lib/ultra/gu/mtxutil.o: LOOPUNROLL :=
$(B_DIR)/lib/ultra/gu/ortho.o: LOOPUNROLL :=
2021-03-17 07:31:37 +00:00
$(B_DIR)/lib/ultra/io/conteepread.o: LOOPUNROLL :=
2021-03-17 08:19:42 +00:00
$(B_DIR)/lib/ultra/io/conteepwrite.o: LOOPUNROLL :=
2021-03-25 00:22:42 +00:00
$(B_DIR)/lib/ultra/io/contpfs.o: LOOPUNROLL :=
2021-03-25 02:51:21 +00:00
$(B_DIR)/lib/ultra/io/contramread.o: LOOPUNROLL :=
2021-03-25 02:55:55 +00:00
$(B_DIR)/lib/ultra/io/contramwrite.o: LOOPUNROLL :=
2021-10-03 13:30:18 +00:00
$(B_DIR)/lib/ultra/io/gbpakgetstatus.o: LOOPUNROLL :=
2021-10-04 08:35:06 +00:00
$(B_DIR)/lib/ultra/io/gbpakreadid.o: LOOPUNROLL :=
2021-03-25 09:11:08 +00:00
$(B_DIR)/lib/ultra/io/motor.o: LOOPUNROLL :=
2021-03-25 01:30:07 +00:00
$(B_DIR)/lib/ultra/io/pfschecker.o: LOOPUNROLL :=
2021-03-25 04:13:34 +00:00
$(B_DIR)/lib/ultra/io/pfsfreeblocks.o: LOOPUNROLL :=
2021-03-25 01:30:07 +00:00
$(B_DIR)/lib/ultra/io/pfsgetstatus.o: LOOPUNROLL :=
2021-01-25 07:38:12 +00:00
2021-01-29 13:29:37 +00:00
$(B_DIR)/lib/ultra/libc/ll.o: MIPSISET := -mips3 -o32
2021-03-17 12:07:47 +00:00
$(B_DIR)/lib/ultra/libc/llcvt.o: MIPSISET := -mips3 -32
2021-01-26 09:31:50 +00:00
2021-03-27 03:31:52 +00:00
# Note: Files that use -O3 must be compiled without the ASM processor, otherwise
# it introduces a race condition when using make -j because they create a
# temporary include-stdin.u file during compilation.
# For these files, see their explicit targets towards the end of this file.
2021-03-28 13:31:52 +00:00
$(B_DIR)/lib/lib_2fba0.o: OPT_LVL := -g
2021-03-27 13:14:43 +00:00
$(B_DIR)/lib/lib_30ce0.o: OPT_LVL := -g
2021-03-29 22:04:50 +00:00
$(B_DIR)/lib/lib_37b00.o: OPT_LVL := -g
2021-03-27 10:48:07 +00:00
$(B_DIR)/lib/lib_3a100.o: OPT_LVL := -g
2021-03-27 11:52:34 +00:00
$(B_DIR)/lib/lib_3d280.o: OPT_LVL := -g
2021-03-28 07:02:43 +00:00
$(B_DIR)/lib/lib_3e730.o: OPT_LVL := -g
2021-03-28 22:18:32 +00:00
$(B_DIR)/lib/lib_3e8c0.o: OPT_LVL := -g
2021-03-27 08:42:27 +00:00
$(B_DIR)/lib/ultra/audio/bnkf.o: OPT_LVL := -g
2021-03-27 10:40:10 +00:00
$(B_DIR)/lib/ultra/audio/cseq.o: OPT_LVL := -g
2021-03-27 06:54:12 +00:00
$(B_DIR)/lib/ultra/audio/csplayer.o: OPT_LVL := -g
2021-03-27 11:48:16 +00:00
$(B_DIR)/lib/ultra/audio/event.o: OPT_LVL := -g
2021-03-27 03:31:52 +00:00
$(B_DIR)/lib/ultra/audio/heap.o: OPT_LVL := -g
2021-03-28 13:47:08 +00:00
$(B_DIR)/lib/ultra/audio/syndelete.o: OPT_LVL := -g
2021-03-27 13:03:04 +00:00
$(B_DIR)/lib/ultra/audio/synsetpriority.o: OPT_LVL := -g
2021-03-25 10:14:04 +00:00
$(B_DIR)/lib/ultra/gu/align.o: OPT_LVL := -O3
2021-01-30 07:34:42 +00:00
$(B_DIR)/lib/ultra/gu/frustum.o: OPT_LVL := -O3
2021-01-30 07:33:34 +00:00
$(B_DIR)/lib/ultra/gu/ortho.o: OPT_LVL := -O3
2021-01-30 07:34:17 +00:00
$(B_DIR)/lib/ultra/gu/scale.o: OPT_LVL := -O3
2021-01-30 00:33:14 +00:00
$(B_DIR)/lib/ultra/io/ai.o: OPT_LVL := -O1
2021-01-30 00:26:33 +00:00
$(B_DIR)/lib/ultra/io/aisetnextbuf.o: OPT_LVL := -O1
2021-01-30 14:32:39 +00:00
$(B_DIR)/lib/ultra/io/conteeplongread.o: OPT_LVL := -O1
2021-01-30 14:26:36 +00:00
$(B_DIR)/lib/ultra/io/contquery.o: OPT_LVL := -O1
2021-03-16 22:15:02 +00:00
$(B_DIR)/lib/ultra/io/controller.o: OPT_LVL := -O1
2021-01-26 09:54:48 +00:00
$(B_DIR)/lib/ultra/io/dpctr.o: OPT_LVL := -O1
2021-01-26 13:30:20 +00:00
$(B_DIR)/lib/ultra/io/pigetcmdq.o: OPT_LVL := -O1
2021-03-16 13:38:52 +00:00
$(B_DIR)/lib/ultra/io/pidma.o: OPT_LVL := -O1
2021-01-29 15:15:07 +00:00
$(B_DIR)/lib/ultra/io/si.o: OPT_LVL := -O1
2021-01-26 09:52:30 +00:00
$(B_DIR)/lib/ultra/io/sp.o: OPT_LVL := -O1
2021-01-26 09:46:42 +00:00
$(B_DIR)/lib/ultra/io/spsetpc.o: OPT_LVL := -O1
2021-01-26 09:58:32 +00:00
$(B_DIR)/lib/ultra/io/sptaskyielded.o: OPT_LVL := -O1
2021-01-26 10:53:56 +00:00
$(B_DIR)/lib/ultra/io/vi.o: OPT_LVL := -O1
2021-01-29 14:14:34 +00:00
$(B_DIR)/lib/ultra/io/viblack.o: OPT_LVL := -O1
2021-01-26 09:37:26 +00:00
$(B_DIR)/lib/ultra/io/vigetcurrframebuf.o: OPT_LVL := -O1
2021-01-26 09:31:50 +00:00
$(B_DIR)/lib/ultra/io/vigetnextframebuf.o: OPT_LVL := -O1
2021-01-26 10:07:38 +00:00
$(B_DIR)/lib/ultra/io/visetevent.o: OPT_LVL := -O1
2021-01-29 14:11:28 +00:00
$(B_DIR)/lib/ultra/io/visetmode.o: OPT_LVL := -O1
2021-01-29 14:03:37 +00:00
$(B_DIR)/lib/ultra/io/visetxscale.o: OPT_LVL := -O1
2021-01-29 13:46:41 +00:00
$(B_DIR)/lib/ultra/io/visetyscale.o: OPT_LVL := -O1
2021-01-29 14:20:14 +00:00
$(B_DIR)/lib/ultra/io/viswapbuf.o: OPT_LVL := -O1
2021-01-29 14:46:18 +00:00
$(B_DIR)/lib/ultra/libc/ll.o: OPT_LVL := -O1
$(B_DIR)/lib/ultra/libc/llcvt.o: OPT_LVL := -O1
2021-03-19 12:19:24 +00:00
$(B_DIR)/lib/ultra/os/atomic.o: OPT_LVL := -O1
2021-01-29 11:02:37 +00:00
$(B_DIR)/lib/ultra/os/createmesgqueue.o: OPT_LVL := -O1
2021-01-26 12:44:10 +00:00
$(B_DIR)/lib/ultra/os/destroythread.o: OPT_LVL := -O1
2021-01-29 14:46:18 +00:00
$(B_DIR)/lib/ultra/os/gettime.o: OPT_LVL := -O1
2021-01-29 08:45:18 +00:00
$(B_DIR)/lib/ultra/os/jammesg.o: OPT_LVL := -O1
2021-01-29 08:48:01 +00:00
$(B_DIR)/lib/ultra/os/recvmesg.o: OPT_LVL := -O1
2021-01-26 12:50:15 +00:00
$(B_DIR)/lib/ultra/os/resetglobalintmask.o: OPT_LVL := -O1
2021-01-29 08:46:46 +00:00
$(B_DIR)/lib/ultra/os/sendmesg.o: OPT_LVL := -O1
2021-01-29 11:00:33 +00:00
$(B_DIR)/lib/ultra/os/seteventmesg.o: OPT_LVL := -O1
2021-03-16 11:23:58 +00:00
$(B_DIR)/lib/ultra/os/setglobalintmask.o: OPT_LVL := -O1
2021-01-26 13:24:12 +00:00
$(B_DIR)/lib/ultra/os/setthreadpri.o: OPT_LVL := -O1
2021-01-31 02:47:42 +00:00
$(B_DIR)/lib/ultra/os/settimer.o: OPT_LVL := -O1
2021-01-26 13:26:29 +00:00
$(B_DIR)/lib/ultra/os/startthread.o: OPT_LVL := -O1
2021-01-26 13:22:30 +00:00
$(B_DIR)/lib/ultra/os/stopthread.o: OPT_LVL := -O1
2021-01-29 08:43:06 +00:00
$(B_DIR)/lib/ultra/os/stoptimer.o: OPT_LVL := -O1
2021-01-26 12:54:56 +00:00
$(B_DIR)/lib/ultra/os/thread.o: OPT_LVL := -O1
2021-01-31 02:49:52 +00:00
$(B_DIR)/lib/ultra/os/timerintr.o: OPT_LVL := -O1
2021-01-29 15:31:52 +00:00
$(B_DIR)/lib/ultra/os/virtualtophysical.o: OPT_LVL := -O1
2021-01-26 12:57:31 +00:00
$(B_DIR)/lib/ultra/os/yieldthread.o: OPT_LVL := -O1
2021-01-25 07:38:12 +00:00
ifeq ($(ROMID), ntsc-beta)
$(B_DIR)/lib/ultra/io/pfsisplug.o: OPT_LVL := -O1
endif
2021-01-25 07:38:12 +00:00
CFLAGS = -DVERSION=$(VERSION) \
2020-04-14 07:12:59 +00:00
-DNTSC=$(NTSC) \
-DPAL=$(PAL) \
2021-01-03 22:23:02 +00:00
-DJPN=$(JPN) \
2020-04-14 07:12:59 +00:00
-DPIRACYCHECKS=$(PIRACYCHECKS) \
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 \
-woff 581,649,819,820,821,838,852 \
2020-04-14 07:12:59 +00:00
-w2 \
-I src/include \
2021-06-11 08:36:29 +00:00
-I src/generated/$(ROMID) \
2021-01-30 07:28:30 +00:00
$(OPT_LVL) \
2021-01-25 07:38:12 +00:00
$(MIPSISET)
2021-03-15 13:28:01 +00:00
C_FILES := $(shell find src/lib src/game src/inflate -name '*.c')
2021-03-08 02:18:53 +00:00
S_FILES := $(shell find src/lib src/game -name '*.s')
2021-01-26 07:14:42 +00:00
# Create names such as $(B_DIR)/assets/files/PfooZ.
# These names (with .o added) will be dependenices for ld.
#
# There are two types of assets: Those which are generated for all versions from
# a single location in src, and those which are copied into each ROM version
# folder at src/assets/$(ROMID) folder. Currently the former is just setup and
# tile files.
ASSET_FILES := \
2021-06-11 08:36:29 +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/setup/%.bin, $(B_DIR)/assets/files/U%Z, $(shell find $(A_DIR)/files/setup -name '*.bin')) \
$(patsubst $(A_DIR)/files/bgdata/%.seg, $(B_DIR)/assets/files/bgdata/%.seg, $(shell find $(A_DIR)/files/bgdata -name '*.seg')) \
$(patsubst src/files/bgdata/%_tiles.s, $(B_DIR)/assets/files/bgdata/%_tilesZ, $(shell find src/files/bgdata -name 'bg_*_tiles.s')) \
$(patsubst $(A_DIR)/files/bgdata/%_tiles.bin, $(B_DIR)/assets/files/bgdata/%_tilesZ, $(shell find $(A_DIR)/files/bgdata -name 'bg_*_tiles.bin')) \
$(B_DIR)/assets/files/ob/ob_mid.seg.o
2021-06-11 08:36:29 +00:00
LANG_JSON_FILES := $(shell find $(A_DIR)/lang -name '*.json')
PADS_JSON_FILES := $(shell find $(A_DIR)/pads -name '*.json')
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))
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) \
$(B_DIR)/bootloader.o \
2021-06-11 08:36:29 +00:00
$(B_DIR)/assets/animations.o \
$(B_DIR)/assets/copyrightZ.o \
$(B_DIR)/assets/files/list.o \
$(B_DIR)/firingrange.o \
$(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 \
$(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 \
$(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 \
$(B_DIR)/assets/textures/config.o \
2021-02-17 02:22:23 +00:00
$(B_DIR)/romheader.o
# ntsc-beta doesn't have this segment
ifneq ($(ROMID), ntsc-beta)
O_FILES := $(O_FILES) $(B_DIR)/assets/accessingpakZ.o
endif
default: rom
2019-09-05 22:09:40 +00:00
################################################################################
# ROM Finalisation Stages
2019-09-05 22:09:40 +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
$(B_DIR)/stage1.bin: $(B_DIR)/stage1.elf
$(TOOLCHAIN)-objcopy $< $@ -O binary
# Stage2 takes stage1 and patches the piracy checksums.
$(B_DIR)/stage2.bin: $(B_DIR)/stage1.bin
@cp $< $@.tmp
ROMID=$(ROMID) PIRACYCHECKS=$(PIRACYCHECKS) tools/patchpiracysums $@.tmp $(B_DIR)/pd.map && mv $@.tmp $@
# Stage3 takes stage2, compresses the game/lib/data segments,
# inserts them and truncates the ROM to 32MB.
$(B_DIR)/stage3.bin: $(B_DIR)/stage2.bin $(B_DIR)/segments/gamezips.bin
@cp $< $@.tmp
tools/packrom $@.tmp && mv $@.tmp $@
2019-12-07 14:19:45 +00:00
$(B_DIR)/segments/gamezips.bin: $(B_DIR)/segments/game.bin
ROMID=$(ROMID) tools/mkgamezips
2019-09-05 22:09:40 +00:00
# The final ROM image takes stage3 and calculates the ROM CRC.
$(B_DIR)/pd.z64: $(B_DIR)/stage3.bin
@cp $< $@.tmp
tools/patchromcrc $@.tmp --write && mv $@.tmp $@
2019-09-05 22:09:40 +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)
@md5sum --quiet -c checksums.$(ROMID).md5
2019-09-05 22:09:40 +00:00
$(B_DIR)/segments/%.bin: $(B_DIR)/stage2.bin
@B_DIR=$(B_DIR) tools/extract-segment $*
################################################################################
# Raw data segments
2019-09-05 22:09:40 +00:00
$(B_DIR)/assets/fonts/%.o: $(A_DIR)/fonts/%.bin
mkdir -p $(B_DIR)/assets/fonts
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
$(B_DIR)/getitle.o: $(E_DIR)/getitle.bin
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
$(B_DIR)/assets/seq.ctl.o: $(A_DIR)/seq.ctl
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
$(B_DIR)/assets/seq.tbl.o: $(A_DIR)/seq.tbl
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
$(B_DIR)/assets/sfx.ctl.o: $(A_DIR)/sfx.ctl
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
$(B_DIR)/assets/sfx.tbl.o: $(A_DIR)/sfx.tbl
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) \
$(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
2019-12-07 14:19:45 +00:00
################################################################################
# Files
2019-09-05 22:09:40 +00:00
# Audio
$(B_DIR)/assets/files/A%M: $(A_DIR)/files/audio/%.mp3
@mkdir -p $(B_DIR)/assets/files
2019-12-07 14:19:45 +00:00
cp $< $@
2019-09-07 12:07:13 +00:00
# BG segs
$(B_DIR)/assets/files/bgdata/bg_%.seg: $(A_DIR)/files/bgdata/bg_%.seg
@mkdir -p $(B_DIR)/assets/files/bgdata
cp $< $@
# BG tiles
# src/assets/files/bgdata/bg_foo_tiles.s
# -> B_DIR/assets/files/bgdata/bg_foo_tiles.o (done here)
# -> B_DIR/assets/files/bgdata/bg_foo_tiles.elf (done here)
# -> A_DIR/assets/files/bgdata/bg_foo_tiles.bin (done here)
# -> B_DIR/assets/files/bgdata/bg_foo_tilesZ (done here)
# Or create $(A_DIR)/files/bgdata/bg_foo_tiles.bin to skip the earlier steps
$(B_DIR)/assets/files/bgdata/bg_%_tiles.o: src/files/bgdata/bg_%_tiles.s
2020-04-14 07:12:59 +00:00
$(TOOLCHAIN)-as --defsym VERSION=$(VERSION) -march=vr4300 -mabi=32 -I src/include -EB -o $@ $<
2019-10-28 23:10:46 +00:00
$(B_DIR)/assets/files/bgdata/bg_%_tiles.elf: $(B_DIR)/assets/files/bgdata/bg_%_tiles.o
TOOLCHAIN=$(TOOLCHAIN) tools/mksimpleelf $< $@
2019-10-28 23:10:46 +00:00
$(A_DIR)/files/bgdata/bg_%_tiles.bin: $(B_DIR)/assets/files/bgdata/bg_%_tiles.elf
$(TOOLCHAIN)-objcopy $< $@ -O binary
$(B_DIR)/assets/files/bgdata/bg_%_tilesZ: $(A_DIR)/files/bgdata/bg_%_tiles.bin
tools/rarezip $< > $@
# Chrs
$(B_DIR)/assets/files/C%Z: $(A_DIR)/files/chrs/%.bin
@mkdir -p $(B_DIR)/assets/files
tools/rarezip $< > $@
2019-12-07 14:19:45 +00:00
# Guns
$(B_DIR)/assets/files/G%Z: $(A_DIR)/files/guns/%.bin
@mkdir -p $(B_DIR)/assets/files
tools/rarezip $< > $@
2019-12-07 14:19:45 +00:00
# OB seg
$(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
# Props
$(B_DIR)/assets/files/P%Z: $(A_DIR)/files/props/%.bin
tools/rarezip $< > $@
2019-12-07 14:19:45 +00:00
# Stage setups
# $(A_DIR)/files/setup/foo.c
# -> B_DIR/assets/files/setup/foo.o (done here)
# -> B_DIR/assets/files/setup/foo.elf (done here)
# -> A_DIR/assets/files/setup/foo.bin (done here)
# -> B_DIR/assets/files/UsetupfooZ (done here)
# -> B_DIR/assets/files/UsetupfooZ.o (done elsewhere)
# Or create $(A_DIR)/files/setup/foo.bin to skip the earlier steps
2021-06-14 12:09:08 +00:00
$(B_DIR)/assets/files/setup/%.o: src/files/setup/%.c $(ASSETMGR_O_FILES)
@mkdir -p $(dir $@)
$(IDOCC) -c $(CFLAGS) $< -o $@
$(B_DIR)/assets/files/setup/%.elf: $(B_DIR)/assets/files/setup/%.o
TOOLCHAIN=$(TOOLCHAIN) tools/mksimpleelf $< $@
2019-12-07 14:19:45 +00:00
$(A_DIR)/files/setup/%.bin: $(B_DIR)/assets/files/setup/%.elf
@mkdir -p $(dir $@)
$(TOOLCHAIN)-objcopy $< $@ -O binary
$(B_DIR)/assets/files/U%Z: $(A_DIR)/files/setup/%.bin
tools/rarezip $< > $@
# General target to convert any finalised file into a raw object for ld
$(B_DIR)/assets/files/%.o: $(B_DIR)/assets/files/%
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
2020-04-26 11:48:17 +00:00
$(B_DIR)/assets/files/%.bin: $(B_DIR)/assets/files/%.elf
$(TOOLCHAIN)-objcopy $< $@ -O binary
2020-04-27 07:42:02 +00:00
################################################################################
2019-12-07 14:19:45 +00:00
# Miscellaneous
$(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 $< $@
$(B_DIR)/romheader.o: src/romheader/romheader.s
$(TOOLCHAIN)-as --defsym VERSION=$(VERSION) -march=vr4300 -mabi=32 -I src/include -EB -o $@ $<
$(B_DIR)/assets/accessingpakZ: $(A_DIR)/accessingpak.bin
tools/rarezip $< > $@
$(B_DIR)/assets/copyrightZ: $(A_DIR)/copyright.bin
tools/rarezip $< > $@
2019-09-07 12:07:13 +00:00
$(B_DIR)/assets/accessingpakZ.o: $(B_DIR)/assets/accessingpakZ
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
$(B_DIR)/assets/copyrightZ.o: $(B_DIR)/assets/copyrightZ
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
2019-09-05 22:09:40 +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)
@mkdir -p $(dir $@)
2021-03-27 03:31:52 +00:00
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s
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-01-30 07:28:30 +00:00
$(IDOCC) -c $(CFLAGS) $< -o $@
2021-01-25 07:38:12 +00:00
tools/patchmips3 $@ || rm $@
2021-06-14 12:09:08 +00:00
$(B_DIR)/lib/ultra/gu/align.o: src/lib/ultra/gu/align.c $(ASSETMGR_O_FILES)
2021-03-27 03:31:52 +00:00
@mkdir -p $(dir $@)
$(IDOCC) -c $(CFLAGS) $< -o $@
2021-06-14 12:09:08 +00:00
$(B_DIR)/lib/ultra/gu/frustum.o: src/lib/ultra/gu/frustum.c $(ASSETMGR_O_FILES)
2021-02-07 12:39:53 +00:00
@mkdir -p $(dir $@)
$(IDOCC) -c $(CFLAGS) $< -o $@
2021-06-14 12:09:08 +00:00
$(B_DIR)/lib/ultra/gu/ortho.o: src/lib/ultra/gu/ortho.c $(ASSETMGR_O_FILES)
2021-02-07 12:39:53 +00:00
@mkdir -p $(dir $@)
$(IDOCC) -c $(CFLAGS) $< -o $@
2021-06-14 12:09:08 +00:00
$(B_DIR)/lib/ultra/gu/scale.o: src/lib/ultra/gu/scale.c $(ASSETMGR_O_FILES)
2021-02-07 12:39:53 +00:00
@mkdir -p $(dir $@)
$(IDOCC) -c $(CFLAGS) $< -o $@
2021-06-11 08:36:29 +00:00
$(B_DIR)/lib/%.o: src/lib/%.c $(ASSETMGR_O_FILES)
@mkdir -p $(dir $@)
2021-03-27 03:31:52 +00:00
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s
2021-06-11 08:36:29 +00:00
$(B_DIR)/game/%.o: src/game/%.c $(ASSETMGR_O_FILES)
@mkdir -p $(dir $@)
2021-03-27 03:31:52 +00:00
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s
2021-04-25 06:48:18 +00:00
# Files requiring qemu-irix to build rather than recomp due to using MAXFLOAT
2021-06-14 12:09:08 +00:00
$(B_DIR)/game/chr/chraction.o: src/game/chr/chraction.c $(ASSETMGR_O_FILES)
2021-04-25 06:48:18 +00:00
@mkdir -p $(dir $@)
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< | $(QEMUCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s
2021-06-14 12:09:08 +00:00
$(B_DIR)/game/game_1657c0.o: src/game/game_1657c0.c $(ASSETMGR_O_FILES)
2021-06-13 11:35:10 +00:00
@mkdir -p $(dir $@)
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< | $(QEMUCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@
/usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s
2021-06-11 08:36:29 +00:00
$(B_DIR)/%.o: src/%.c $(ASSETMGR_O_FILES)
@mkdir -p $(dir $@)
2021-01-30 07:28:30 +00:00
$(IDOCC) -c $(CFLAGS) $< -o $@
2021-01-26 07:14:42 +00:00
$(B_DIR)/%.o: src/%.s
@mkdir -p $(dir $@)
2021-01-30 07:28:30 +00:00
$(IDOAS) $(CFLAGS) $< -o $@
2021-01-26 07:14:42 +00:00
$(B_DIR)/assets/%.o: $(A_DIR)/%.c
@mkdir -p $(dir $@)
$(IDOCC) -c $(CFLAGS) $< -o $@
extract:
ROMID=$(ROMID) tools/extract
rom: $(B_DIR)/pd.z64
2019-09-05 22:09:40 +00:00
clean:
rm -rf build/$(ROMID)
allclean:
2019-09-05 22:09:40 +00:00
rm -rf build/*
codeclean:
2021-03-15 13:28:01 +00:00
find $(B_DIR)/{game,inflate,lib} -name '*.o' -delete