joeylib2/make/psp.mk
2026-10-13 14:01:46 -05:00

65 lines
3.2 KiB
Makefile

# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# PSP build rules: JoeyLib programs as PSP homebrew, through the hosted core
# and the same SDL3 backend the sdl3 port uses (src/hosted,
# src/hosted/sdl3), cross-compiled with pspdev's psp-gcc against SDL3's PSP
# port (the installer's sdl3Psp component). The rules are make/hosted.mk's;
# this file says what is the PSP's. A project reaches it through
# make/project.mk.
#
# A program is a folder of its own, bin/NAME/: EBOOT.PBP, titled ID_TITLE
# (or NAME) in the PSP's menu, and its DATA/ beside it. The folder goes into
# PSP/GAME/ on the memory stick as it is: the program's folder is its
# current directory, as on every port, so DATA/, SAVES/ and joeylog.txt are
# there. The ELF the EBOOT.PBP is packed from (make/support/psp/packEboot.sh)
# stays in build/psp/elf, for psp-addr2line.
PLATFORM := psp
include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk
$(call requireTool,$(PSP_CC),toolchain:psp)
SDL3_PSP_LIB := $(SDL3_PSP_DIR)/lib/libSDL3.a
$(call requireTool,$(SDL3_PSP_LIB),toolchain:psp)
$(call requireTool,$(LIBXMP_DIR)/include/libxmp-lite/xmp.h,toolchain:psp)
# Only this SDL's own .pc: a host SDL3 must not answer for the PSP's.
SDL3_PSP_PKG_CONFIG := PKG_CONFIG_LIBDIR=$(SDL3_PSP_DIR)/lib/pkgconfig pkg-config
PSP_SDK := $(PSPDEV)/psp/sdk
# The firmware the PSPSDK's headers are read for (pspdev's default).
PSP_FW_VERSION := 600
PSP_PACK := $(REPO_DIR)/make/support/psp/packEboot.sh
HOSTED_CC := $(PSP_CC)
HOSTED_AR := $(PSPDEV)/bin/psp-ar
HOSTED_BACKEND := sdl3
HOSTED_DEFINES := -DJOEYLIB_PLATFORM_HOSTED -DJOEYLIB_HOSTED_SDL3
HOSTED_SDK_CFLAGS := $(shell $(SDL3_PSP_PKG_CONFIG) --cflags sdl3) -I$(PSP_SDK)/include -D_PSP_FW_VERSION=$(PSP_FW_VERSION)
# Section alignment as the PSPSDK links: smaller programs. Every program
# takes the module information the PSP loads it by from the backend
# (PSP_MODULE_INFO), even one that never opens the window.
HOSTED_LINK := $(shell $(SDL3_PSP_PKG_CONFIG) --static --libs sdl3) -L$(PSP_SDK)/lib -Wl,-zmax-page-size=128 -Wl,-u,module_info
PROGRAM_EXT :=
# A program is relinked when SDL changes.
HOSTED_PROGRAM_DEPS := $(SDL3_PSP_LIB)
# A program is linked to its ELF, then packed into its folder's EBOOT.PBP.
HOSTED_LINK_OUT = $(PROGRAM_BUILD)/elf/$(call programName,$(1)).elf
HOSTED_PACK = $(PSP_PACK) $(call HOSTED_LINK_OUT,$(1)) '$(or $(call programVar,$(1),TITLE),$(call programName,$(1)))' $(call programBin,$(1))
# Every program in a folder of its own, as PSP/GAME/ holds it.
programDir = $(or $(call programVar,$(1),BINDIR),$(BINDIR))/$(call programName,$(1))
programBin = $(call programDir,$(1))/EBOOT.PBP
include $(REPO_DIR)/make/hosted.mk
# ---- gates --------------------------------------------------------------------
ifndef JOEY_PROJECT
# Audio gate: AUDIOPRB (AUDIO pressing its own keys, make/examples.mk) under
# PPSSPPHeadless, its sound recorded and graded (a few seconds).
.PHONY: psp-verify-audio
psp-verify-audio: $(call programBin,AUDIOPRB)
$(REPO_DIR)/scripts/verify-psp-audio.sh $(call programDir,AUDIOPRB)
endif