Files
F3DEX3/Makefile

171 lines
6.1 KiB
Makefile
Raw Normal View History

2023-02-15 22:28:04 -08:00
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
.SUFFIXES:
2023-10-21 15:24:26 -07:00
default: F3DEX3_BrZ F3DEX3_BrW
2023-02-14 10:44:08 -08:00
2023-10-21 15:24:26 -07:00
# List of all compile-time options supported by the microcode source.
2023-02-14 10:44:08 -08:00
ALL_OPTIONS := \
2023-12-23 22:47:48 -08:00
CFG_G_BRANCH_W \
2024-01-27 18:05:54 -08:00
CFG_DEBUG_NORMALS \
2024-02-27 21:30:23 -08:00
CFG_PROFILING_A \
CFG_PROFILING_B \
CFG_PROFILING_C
2023-12-23 22:47:48 -08:00
2023-02-14 10:44:08 -08:00
ARMIPS ?= armips
2024-02-27 21:30:23 -08:00
PARENT_OUTPUT_DIR ?= ./build
2023-02-15 22:28:04 -08:00
ifeq ($(PARENT_OUTPUT_DIR),.)
$(error Cannot build directly in repo directory; see Makefile for details.)
# The problem is that we want to be able to have targets like F3DEX2_2.08,
# but this would also be the directory itself, whose existence and possible
# modification needs to be handled by the Makefile. It is possible to write
# the Makefile where the directory is the main target for that microcode, but
# this has worse behavior in case of modification to the directory. Worse, if
# it was done this way, then it would break if the user tried to set
# PARENT_OUTPUT_DIR anywhere else. So, better to support building everywhere
# but here than to support only building here.
endif
2023-02-14 10:44:08 -08:00
NO_COL := \033[0m
RED := \033[0;31m
GREEN := \033[0;32m
YELLOW := \033[0;33m
BLUE := \033[0;34m
2023-02-15 22:28:04 -08:00
INFO := $(BLUE)
2023-02-14 10:44:08 -08:00
SUCCESS := $(GREEN)
FAILURE := $(RED)
WARNING := $(YELLOW)
$(PARENT_OUTPUT_DIR):
@printf "$(INFO)Creating parent output directory$(NO_COL)\n"
ifeq ($(OS),Windows_NT)
2023-02-15 22:28:04 -08:00
mkdir $@
2023-02-14 10:44:08 -08:00
else
2023-02-15 22:28:04 -08:00
mkdir -p $@
2023-02-14 10:44:08 -08:00
endif
ALL_UCODES :=
ALL_UCODES_WITH_MD5S :=
2023-02-14 16:03:21 -08:00
ALL_OUTPUT_DIRS :=
2023-02-14 10:44:08 -08:00
2023-02-15 22:28:04 -08:00
define reset_vars
NAME :=
2023-02-16 21:20:48 -08:00
DESCRIPTION := (Not used in any retail games)
2023-02-15 22:28:04 -08:00
ID_STR := Custom F3DEX2-based microcode, github.com/Mr-Wiseguy/f3dex2 & Nintendo
ID_STR := RSP Gfx ucode F3DEX fifo 2.04H Yoshitaka Yasumoto 1998 Nintendo.
MD5_CODE :=
MD5_DATA :=
OPTIONS :=
2023-02-17 10:56:20 -08:00
EXTRA_DEPS :=
2023-02-15 22:28:04 -08:00
endef
2023-02-14 10:44:08 -08:00
define ucode_rule
2023-02-15 22:28:04 -08:00
# Variables defined outside the function need one dollar sign, whereas
# variables defined within the function need two. This is because make first
# expands all this text, substituting single-dollar-sign variables, and then
# executes all of it, causing all the assignments to actually happen.
2023-02-14 10:44:08 -08:00
ifeq ($(NAME),)
2023-02-15 22:28:04 -08:00
$$(error Microcode name not set!)
2023-02-14 10:44:08 -08:00
endif
2023-02-15 22:28:04 -08:00
UCODE_OUTPUT_DIR := $(PARENT_OUTPUT_DIR)/$(NAME)
2023-02-14 10:44:08 -08:00
CODE_FILE := $$(UCODE_OUTPUT_DIR)/$(NAME).code
DATA_FILE := $$(UCODE_OUTPUT_DIR)/$(NAME).data
SYM_FILE := $$(UCODE_OUTPUT_DIR)/$(NAME).sym
TEMP_FILE := $$(UCODE_OUTPUT_DIR)/$(NAME).tmp.s
ALL_UCODES += $(NAME)
2023-02-15 22:28:04 -08:00
ifneq ($(MD5_CODE),)
2023-02-14 10:44:08 -08:00
ALL_UCODES_WITH_MD5S += $(NAME)
endif
2023-02-15 22:28:04 -08:00
ALL_OUTPUT_DIRS += $$(UCODE_OUTPUT_DIR)
OFF_OPTIONS := $(filter-out $(OPTIONS),$(ALL_OPTIONS))
OPTIONS_EQU :=
$$(foreach option,$(OPTIONS),$$(eval OPTIONS_EQU += -equ $$(option) 1))
OFF_OPTIONS_EQU :=
$$(foreach o2,$$(OFF_OPTIONS),$$(eval OFF_OPTIONS_EQU += -equ $$(o2) 0))
2023-02-14 10:44:08 -08:00
ARMIPS_CMDLINE := \
2023-02-15 22:28:04 -08:00
-strequ CODE_FILE $$(CODE_FILE) \
-strequ DATA_FILE $$(DATA_FILE) \
$$(OPTIONS_EQU) \
$$(OFF_OPTIONS_EQU) \
2023-10-21 15:24:26 -07:00
f3dex3.s \
2023-02-15 22:28:04 -08:00
-sym2 $$(SYM_FILE) \
-temp $$(TEMP_FILE)
# Microcode target
.PHONY: $(NAME)
$(NAME): $$(CODE_FILE)
# Directory target variables, see below.
$$(UCODE_OUTPUT_DIR): UCODE_OUTPUT_DIR:=$$(UCODE_OUTPUT_DIR)
# Directory target recipe
$$(UCODE_OUTPUT_DIR):
2023-02-24 10:41:00 -08:00
@printf "$(INFO)Creating directory $$(UCODE_OUTPUT_DIR)$(NO_COL)\n"
2023-02-14 10:44:08 -08:00
ifeq ($(OS),Windows_NT)
2023-02-24 10:41:00 -08:00
@mkdir $$(subst /,\,$$(UCODE_OUTPUT_DIR))
2023-02-14 10:44:08 -08:00
else
2023-02-15 22:28:04 -08:00
@mkdir -p $$(UCODE_OUTPUT_DIR)
2023-02-14 10:44:08 -08:00
endif
2023-02-15 22:28:04 -08:00
# Code file target variables. make does not expand variables within recipes
# until the recipe is executed, meaning that all the parts of the recipe would
# have the values from the very last microcode in the file. Here, we set
# target-specific variables--effectively local variables within the recipe--
# to the values from the global variables have right now. We are only
# targeting CODE_FILE even though we also want DATA_FILE, because target-
# specific variables may not work as expected with multiple targets from one
# recipe.
$$(CODE_FILE): ARMIPS_CMDLINE:=$$(ARMIPS_CMDLINE)
$$(CODE_FILE): CODE_FILE:=$$(CODE_FILE)
$$(CODE_FILE): DATA_FILE:=$$(DATA_FILE)
# Target recipe
2023-10-21 15:24:26 -07:00
$$(CODE_FILE): ./f3dex3.s ./rsp/* $(EXTRA_DEPS) | $$(UCODE_OUTPUT_DIR)
2023-02-16 21:20:48 -08:00
@printf "$(INFO)Building microcode: $(NAME): $(DESCRIPTION)$(NO_COL)\n"
@$(ARMIPS) -strequ ID_STR "$(ID_STR)" $$(ARMIPS_CMDLINE)
ifneq ($(MD5_CODE),)
2023-02-20 10:40:24 -08:00
@(printf "$(MD5_CODE) *$$(CODE_FILE)" | md5sum --status -c -) && printf " $(SUCCESS)$(NAME) code matches$(NO_COL)\n" || printf " $(FAILURE)$(NAME) code differs$(NO_COL)\n"
@(printf "$(MD5_DATA) *$$(DATA_FILE)" | md5sum --status -c -) && printf " $(SUCCESS)$(NAME) data matches$(NO_COL)\n" || printf " $(FAILURE)$(NAME) data differs$(NO_COL)\n"
2023-02-15 22:28:04 -08:00
else ifneq ($(1),1)
2024-03-03 20:40:10 -08:00
@printf "(MD5 sums not in database for $(NAME), this is normal in development)\n"
2023-02-14 10:44:08 -08:00
endif
2023-02-15 22:28:04 -08:00
$$(eval $$(call reset_vars))
2023-02-14 10:44:08 -08:00
endef
2023-02-15 22:28:04 -08:00
$(eval $(call reset_vars))
2023-02-13 23:00:03 -08:00
2023-10-21 15:24:26 -07:00
NAME := F3DEX3_BrZ
DESCRIPTION := Will make you want to finally ditch HLE (G_BRANCH_Z version)
ID_STR := F3DEX3 by Sauraen & Nintendo, G_BRANCH_Z version______________________
2024-02-27 21:30:23 -08:00
# Add options you want here, e.g. CFG_PROFILING_A
2023-10-21 15:24:26 -07:00
OPTIONS :=
$(eval $(call ucode_rule))
2023-02-13 23:00:03 -08:00
2023-10-21 15:24:26 -07:00
NAME := F3DEX3_BrW
2024-03-03 20:40:10 -08:00
DESCRIPTION := Will make you want to finally ditch HLE (G_BRANCH_W, default profiling)
ID_STR := F3DEX3 by Sauraen & Nintendo; G_BRANCH_W, default profiling___________
2024-02-27 22:18:38 -08:00
OPTIONS := CFG_G_BRANCH_W
2023-10-21 15:24:26 -07:00
$(eval $(call ucode_rule))
2023-02-14 16:03:21 -08:00
2024-03-03 20:40:10 -08:00
NAME := F3DEX3_BrW_PA
DESCRIPTION := Will make you want to finally ditch HLE (G_BRANCH_W, PROFILING_A)
ID_STR := F3DEX3 by Sauraen & Nintendo; G_BRANCH_W, PROFILING_A_________________
OPTIONS := CFG_G_BRANCH_W CFG_PROFILING_A
$(eval $(call ucode_rule))
NAME := F3DEX3_BrW_PB
DESCRIPTION := Will make you want to finally ditch HLE (G_BRANCH_W, PROFILING_B)
ID_STR := F3DEX3 by Sauraen & Nintendo; G_BRANCH_W, PROFILING_B_________________
OPTIONS := CFG_G_BRANCH_W CFG_PROFILING_B
$(eval $(call ucode_rule))
NAME := F3DEX3_BrW_PC
DESCRIPTION := Will make you want to finally ditch HLE (G_BRANCH_W, PROFILING_C)
ID_STR := F3DEX3 by Sauraen & Nintendo; G_BRANCH_W, PROFILING_C_________________
OPTIONS := CFG_G_BRANCH_W CFG_PROFILING_C
$(eval $(call ucode_rule))
2023-02-14 16:03:21 -08:00
.PHONY: default ok all clean
all: $(ALL_UCODES)
ok: $(ALL_UCODES_WITH_MD5S)
clean:
@printf "$(WARNING)Deleting all built microcode files$(NO_COL)\n"
2023-02-15 22:31:03 -08:00
@rm -rf $(ALL_OUTPUT_DIRS)