Refactor Saturn makefile, fix PSP build

This commit is contained in:
UnknownShadow200 2025-07-10 20:12:33 +10:00
parent 221ee0303c
commit 403e466ac2
9 changed files with 191 additions and 108 deletions

View File

@ -26,7 +26,8 @@ INCLUDES =
S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
CFLAGS := -g -DNDEBUG -O3 -fipa-pta -fno-pie -flto=auto -fomit-frame-pointer -fbuiltin -ffast-math -ffp-contract=fast -mfsrra -mfsca -pipe -fno-math-errno
CFLAGS = -g -DNDEBUG -O3 -fipa-pta -fno-pie -flto=auto -fomit-frame-pointer -fbuiltin -ffast-math -ffp-contract=fast -mfsrra -mfsca -pipe -fno-math-errno
LDFLAGS = -g
# Dependency tracking

View File

@ -1,11 +1,9 @@
ifeq ($(strip $(PSPSDK)),)
$(warning "Please set PSPSDK variables in your environment. For example:")
$(warning export PSPSDK=/usr/local/pspsk/psp/sdk)
$(warning export PATH=/usr/local/pspsk/bin:$$PATH)
$(warning Or)
$(warning export PSPSDK=$$(shell psp-config --pspsdk-path))
ifeq ($(strip $(PSPDEV)),)
$(warning "Please set PSPDEV variables in your environment. For example:")
$(warning export PSPDEV=/usr/local/pspsdk)
$(error Failed to find PSPSDK installation)
endif
PSPSDK=$(PSPDEV)/psp/sdk
#---------------------------------------------------------------------------------
@ -36,13 +34,10 @@ S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
INCDIR := $(PSPDEV)/psp/include $(PSPSDK)/include
LIBDIR := $(PSPDEV)/psp/lib $(PSPSDK)/lib
CFLAGS := -I$(PSPSDK)/include -g -O1 -fno-math-errno -D_PSP_FW_VERSION=600
ASFLAGS := -I$(PSPSDK)/include -g
CFLAGS := $(addprefix -I,$(INCDIR)) -g -O1 -fno-math-errno -D_PSP_FW_VERSION=600
ASFLAGS := $(addprefix -I,$(INCDIR)) -g
LDFLAGS := $(addprefix -L,$(LIBDIR)) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx -Wl,-zmax-page-size=128
LDFLAGS := -L$(PSPSDK)/lib -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx -Wl,-zmax-page-size=128
LIBS := -lm -lpspgum -lpspgu -lpspge -lpspdisplay -lpspctrl -lpspdebug -lpspnet -lpspnet_apctl
# Dependency tracking
@ -53,12 +48,13 @@ DEPFILES := $(OBJS:%.o=%.d)
#---------------------------------------------------------------------------------
# Compiler tools
#---------------------------------------------------------------------------------
CC = psp-gcc
AS = psp-gcc
LD = psp-gcc
MKSFO = mksfoex
PACK_PBP = pack-pbp
FIXUP = psp-fixup-imports
CC = $(PSPDEV)/bin/psp-gcc
AS = $(PSPDEV)/bin/psp-gcc
LD = $(PSPDEV)/bin/psp-gcc
MKSFO = $(PSPDEV)/bin/mksfoex
PACK_PBP = $(PSPDEV)/bin/pack-pbp
FIXUP = $(PSPDEV)/bin/psp-fixup-imports
PRXGEN = $(PSPDEV)/bin/psp-prxgen
#---------------------------------------------------------------------------------
@ -81,7 +77,7 @@ $(TARGET).elf: $(OBJS)
$(FIXUP) $@
$(TARGET).prx: $(TARGET).elf
psp-prxgen $< $@
$(PRXGEN) $< $@
$(PSP_EBOOT_SFO):
$(MKSFO) -d MEMSIZE=1 '$(PSP_EBOOT_TITLE)' $@
@ -99,7 +95,7 @@ $(BUILD_DIR)/%.o : src/%.c
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o : src/psp/%.c
$(VITA_CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o : third_party/bearssl/%.c
$(CC) $(CFLAGS) -c $< -o $@

View File

@ -2,28 +2,131 @@ ifeq ($(strip $(YAUL_INSTALL_ROOT)),)
$(error Undefined YAUL_INSTALL_ROOT (install root directory))
endif
SH_BUILD_DIR := build-saturn
include $(YAUL_INSTALL_ROOT)/share/build.pre.mk
#---------------------------------------------------------------------------------
# Configurable options
#---------------------------------------------------------------------------------
# Directory where object files are placed
BUILD_DIR = build/saturn
# List of directories containing source code
SOURCE_DIRS = src src/saturn
# Name of the final output
TARGET = ClassiCube-saturn
# Each asset follows the format: <path>;<symbol>. Duplicates are removed
BUILTIN_ASSETS=
IP_VERSION = V1.370
IP_RELEASE_DATE = 20250101
IP_AREAS = JTUBKAEL
IP_PERIPHERALS = JAMKST
IP_TITLE = ClassiCube
#IP_MASTER_STACK_ADDR = 0x06004000
IP_MASTER_STACK_ADDR = 0x06100000
IP_SLAVE_STACK_ADDR = 0x06001E00
IP_1ST_READ_ADDR = 0x06004000
IP_1ST_READ_SIZE = 0
SH_PROGRAM := ClassiCube-saturn
SH_SRCS := $(wildcard src/*.c)
CD_PATH = $(BUILD_DIR)/cd
AUDIO_TRACKS_DIRECTORY = audio-tracks
IMAGE_1ST_READ_BIN = A.BIN
SH_CFLAGS+= -Os -I. -DPLAT_SATURN -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers
SH_LDFLAGS+=
IP_VERSION:= V1.000
IP_RELEASE_DATE:= 20230101
IP_AREAS:= JTUBKAEL
IP_PERIPHERALS:= JAMKST
IP_TITLE:= ClassiCube
#IP_MASTER_STACK_ADDR:= 0x06004000
IP_MASTER_STACK_ADDR:= 0x06100000
IP_SLAVE_STACK_ADDR:= 0x06001E00
IP_1ST_READ_ADDR:= 0x06004000
IP_1ST_READ_SIZE:= 0
#---------------------------------------------------------------------------------
# Code generation
#---------------------------------------------------------------------------------
S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
SH_OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
include $(YAUL_INSTALL_ROOT)/share/build.post.iso-cue.mk
SH_CFLAGS = -Os -DPLAT_SATURN -Wstrict-aliasing \
-I$(YAUL_INSTALL_ROOT)/$(YAUL_ARCH_SH_PREFIX)/include/yaul
SH_LDFLAGS = -static -Wl,--gc-sections \
-Wl,--defsym=___master_stack=$(IP_MASTER_STACK_ADDR) \
-Wl,--defsym=___slave_stack=$(IP_SLAVE_STACK_ADDR)
SH_SPECS = yaul.specs yaul-main.specs
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(SH_OBJS:%.o=%.d)
#---------------------------------------------------------------------------------
# Compiler tools
#---------------------------------------------------------------------------------
SH_AS:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_SH_PREFIX)-as
SH_CC:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_SH_PREFIX)-gcc
SH_LD:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_SH_PREFIX)-gcc
SH_OBJCOPY:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_SH_PREFIX)-objcopy
M68K_AS:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_M68K_PREFIX)-as
M68K_CC:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_M68K_PREFIX)-gcc
M68K_LD:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_M68K_PREFIX)-gcc
M68K_OBJCOPY:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_M68K_PREFIX)-objcopy
#---------------------------------------------------------------------------------
# Main targets
#---------------------------------------------------------------------------------
default: $(BUILD_DIR) $(TARGET).cue
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
clean:
rm -f $(SH_OBJS) $(TARGET).bin $(TARGET).cue $(TARGET).iso \
$(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin $(BUILD_DIR)/IP.BIN
#---------------------------------------------------------------------------------
# executable generation
#---------------------------------------------------------------------------------
$(BUILD_DIR)/$(TARGET).elf: $(SH_OBJS)
$(SH_LD) $(foreach specs,$(SH_SPECS),-specs=$(specs)) $(SH_OBJS) $(SH_LDFLAGS) -o $@
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf
$(SH_OBJCOPY) -O binary $< $@
@[ -z "${SILENT}" ] && du -hs $@ | awk '{ print $$1; }' || true
$(TARGET).bin: $(BUILD_DIR)/$(TARGET).bin
cp $< $@
$(BUILD_DIR)/IP.BIN: $(TARGET).bin
$(YAUL_INSTALL_ROOT)/bin/make-ip \
"$(BUILD_DIR)/$(TARGET).bin" \
$(IP_VERSION) $(IP_RELEASE_DATE) $(IP_AREAS) $(IP_PERIPHERALS) \
'"$(IP_TITLE)"' \
$(IP_MASTER_STACK_ADDR) $(IP_SLAVE_STACK_ADDR) \
$(IP_1ST_READ_ADDR) $(IP_1ST_READ_SIZE)
$(TARGET).iso: $(TARGET).bin $(BUILD_DIR)/IP.BIN
mkdir -p $(CD_PATH)
cp $(TARGET).bin $(CD_PATH)/$(IMAGE_1ST_READ_BIN)
printf "empty\n" > $(CD_PATH)/"ABS.TXT"
printf "empty\n" > $(CD_PATH)/"BIB.TXT"
printf "empty\n" > $(CD_PATH)/"CPY.TXT"
$(YAUL_INSTALL_ROOT)/bin/make-iso $(CD_PATH) $(BUILD_DIR)/IP.BIN . $(TARGET)
$(TARGET).cue: $(TARGET).iso
mkdir -p $(AUDIO_TRACKS_DIRECTORY)
$(YAUL_INSTALL_ROOT)/bin/make-cue $(AUDIO_TRACKS_DIRECTORY) $(TARGET).iso
#---------------------------------------------------------------------------------
# object generation
#---------------------------------------------------------------------------------
$(BUILD_DIR)/%.o : src/%.c
$(SH_CC) $(SH_CFLAGS) $(DEPFLAGS) $(foreach specs,$(SH_SPECS),-specs=$(specs)) -c $< -o $@
$(BUILD_DIR)/%.o : src/saturn/%.c
$(SH_CC) $(SH_CFLAGS) $(DEPFLAGS) $(foreach specs,$(SH_SPECS),-specs=$(specs)) -c $< -o $@
$(BUILD_DIR)/%.o : src/saturn/%.S
$(SH_CC) $(SH_CFLAGS) $(DEPFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# Dependency tracking
#---------------------------------------------------------------------------------
$(DEPFILES):
include $(wildcard $(DEPFILES))

View File

@ -1,9 +1,7 @@
#include "Core.h"
#if defined CC_BUILD_PSP
#include "_GraphicsBase.h"
#include "Errors.h"
#include "Logger.h"
#include "Window.h"
#include "../_GraphicsBase.h"
#include "../Errors.h"
#include "../Logger.h"
#include "../Window.h"
#include <malloc.h>
#include <pspkernel.h>
@ -454,4 +452,3 @@ void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, ICOUNT(verticesCount),
gfx_indices, gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED);
}
#endif

View File

@ -1,14 +1,11 @@
#include "Core.h"
#if defined CC_BUILD_PSP
#define CC_XTEA_ENCRYPTION
#include "_PlatformBase.h"
#include "Stream.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "Window.h"
#include "Utils.h"
#include "Errors.h"
#include "../_PlatformBase.h"
#include "../Stream.h"
#include "../ExtMath.h"
#include "../Funcs.h"
#include "../Window.h"
#include "../Utils.h"
#include "../Errors.h"
#include <errno.h>
#include <stdlib.h>
@ -22,7 +19,7 @@
#include <pspnet_resolver.h>
#include <pspnet_apctl.h>
#include <psprtc.h>
#include "_PlatformConsole.h"
#include "../_PlatformConsole.h"
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = ENOENT;
@ -496,4 +493,3 @@ static cc_result GetMachineID(cc_uint32* key) {
Mem_Copy(key, MACHINE_KEY, sizeof(MACHINE_KEY) - 1);
return 0;
}
#endif

View File

@ -1,16 +1,15 @@
#include "Core.h"
#if defined CC_BUILD_PSP
#include "Window.h"
#include "Platform.h"
#include "Input.h"
#include "Event.h"
#include "Graphics.h"
#include "String.h"
#include "Funcs.h"
#include "Bitmap.h"
#include "Errors.h"
#include "ExtMath.h"
#include "VirtualKeyboard.h"
#include "../Window.h"
#include "../Platform.h"
#include "../Input.h"
#include "../Event.h"
#include "../Graphics.h"
#include "../String.h"
#include "../Funcs.h"
#include "../Bitmap.h"
#include "../Errors.h"
#include "../ExtMath.h"
#include "../VirtualKeyboard.h"
#include <pspdisplay.h>
#include <pspge.h>
#include <pspctrl.h>
@ -201,4 +200,3 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED;
}
#endif

View File

@ -1,11 +1,10 @@
#include "Core.h"
#if defined CC_BUILD_SATURN
#include "_GraphicsBase.h"
#include "Errors.h"
#include "Window.h"
#include "../_GraphicsBase.h"
#include "../Errors.h"
#include "../Window.h"
#include "../_BlockAlloc.h"
#include <stdint.h>
#include <yaul.h>
#include "_BlockAlloc.h"
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 224
@ -790,4 +789,3 @@ void Gfx_End2D(void) {
Gfx_SetAlphaBlending(false);
gfx_rendering2D = false;
}
#endif

View File

@ -1,16 +1,14 @@
#include "Core.h"
#if defined PLAT_SATURN
#define CC_XTEA_ENCRYPTION
#include "_PlatformBase.h"
#include "Stream.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "Window.h"
#include "Utils.h"
#include "Errors.h"
#include "Options.h"
#include "PackedCol.h"
#include "../_PlatformBase.h"
#include "../Stream.h"
#include "../ExtMath.h"
#include "../Funcs.h"
#include "../Window.h"
#include "../Utils.h"
#include "../Errors.h"
#include "../Options.h"
#include "../PackedCol.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@ -24,7 +22,7 @@ void* calloc(size_t num, size_t size) {
return ptr;
}
#include "_PlatformConsole.h"
#include "../_PlatformConsole.h"
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = 99999;
@ -308,4 +306,3 @@ static cc_result GetMachineID(cc_uint32* key) {
Mem_Copy(key, MACHINE_KEY, sizeof(MACHINE_KEY) - 1);
return 0;
}
#endif

View File

@ -1,16 +1,14 @@
#include "Core.h"
#if defined CC_BUILD_SATURN
#include "Window.h"
#include "Platform.h"
#include "Input.h"
#include "Event.h"
#include "Graphics.h"
#include "String.h"
#include "Funcs.h"
#include "Bitmap.h"
#include "Errors.h"
#include "ExtMath.h"
#include "Logger.h"
#include "../Window.h"
#include "../Platform.h"
#include "../Input.h"
#include "../Event.h"
#include "../Graphics.h"
#include "../String.h"
#include "../Funcs.h"
#include "../Bitmap.h"
#include "../Errors.h"
#include "../ExtMath.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -274,4 +272,3 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED;
}
#endif