joeylib2/make/psp.mk

72 lines
3.5 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 with its icon (ID_ICON, ICON0 in the EBOOT),
# 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)
# 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
# The PSP's keyboard on the screen (a PSP has none).
HOSTED_BACKEND_EXTRA := $(SRC_DIR)/hosted/psp
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)) $(call shellQuote,$(or $(call programVar,$(1),TITLE),$(call programName,$(1)))) $(call HOSTED_ICON,$(1)) $(call programBin,$(1))
# Its icon: the EBOOT's ICON0, the picture the PSP's menu shows, always
# PSP_ICON0_SIZE.
PSP_ICON0_SIZE := 144x80
HOSTED_ICON = $(call programIconDir,$(1))/icon0.png
HOSTED_ICON_BAKE = $(ICON_BAKE) png $(call programIcon,$(1)) $(call HOSTED_ICON,$(1)) $(PSP_ICON0_SIZE)
# 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