PS3: Redo makefile

This commit is contained in:
UnknownShadow200 2025-07-13 23:25:49 +10:00
parent 8e3eebe483
commit b0f2597e38
18 changed files with 211 additions and 145 deletions

View File

@ -4,6 +4,8 @@ else
ROOTDIR = /opt/toolchains/sega
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options
@ -42,6 +44,10 @@ SHASFLAGS = --big
MDLDFLAGS = -T $(LDSCRIPTSDIR)/md.ld --oformat binary
MDASFLAGS = -m68000 --register-prefix-optional
#---------------------------------------------------------------------------------
# Compiler tools
#---------------------------------------------------------------------------------
SHPREFIX = $(ROOTDIR)/sh-elf/bin/sh-elf-
SHCC = $(SHPREFIX)gcc
SHAS = $(SHPREFIX)as

View File

@ -2,6 +2,8 @@ ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -2,7 +2,7 @@ ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITPRO)/devkitARM/gba_rules
.SUFFIXES:
#---------------------------------------------------------------------------------
@ -51,6 +51,17 @@ INCLUDES += $(foreach dir, $(LIBTONC), -I$(dir)/include)
LDFLAGS += $(foreach dir, $(LIBTONC), -L$(dir)/lib)
#---------------------------------------------------------------------------------
# Compiler tools
#---------------------------------------------------------------------------------
PREFIX = $(DEVKITPRO)/devkitARM/bin/arm-none-eabi-
ARM_AS = $(PREFIX)as
ARM_CC = $(PREFIX)gcc
ARM_OBJCOPY = $(PREFIX)objcopy
GBAFIX = $(DEVKITPRO)/tools/bin/gbafix
#---------------------------------------------------------------------------------
# Main targets
#---------------------------------------------------------------------------------
@ -67,21 +78,21 @@ $(BUILD_DIR):
# Executable generation
#---------------------------------------------------------------------------------
$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
$(ARM_CC) $(LDFLAGS) $^ -o $@ $(LIBS)
$(TARGET).gba: $(TARGET).elf
$(OBJCOPY) -O binary $< $@
gbafix $@ -t$(GAME_TITLE) -c$(GAME_CODE) -m$(MAKER_CODE)
$(ARM_OBJCOPY) -O binary $< $@
$(GBAFIX) $@ -t$(GAME_TITLE) -c$(GAME_CODE) -m$(MAKER_CODE)
#---------------------------------------------------------------------------------
# Object generation
#---------------------------------------------------------------------------------
$(BUILD_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
$(ARM_CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: src/gba/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
$(ARM_CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------

View File

@ -2,6 +2,8 @@ ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -4,6 +4,8 @@ $(warning export PSN00BSDK_ROOT=/usr/local/lib/psn00bsdk)
$(error Failed to find PSN00BSDK installation path)
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -2,6 +2,8 @@ ifeq ($(strip $(PS2SDK)),)
$(error "PS2SDK must be set in your environment")
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -1,8 +1,3 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(PS3DEV)),)
$(error "Please set PS3DEV in your environment. export PS3DEV=<path>")
endif
@ -10,132 +5,154 @@ ifeq ($(strip $(PSL1GHT)),)
$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path>")
endif
include $(PS3DEV)/ppu_rules
.SUFFIXES:
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# Configurable options
#---------------------------------------------------------------------------------
TARGET := ClassiCube-PS3
BUILD := build-ps3
SOURCES := src third_party/bearssl
SHADERS := misc/ps3
# Name of the final output
TARGET = ClassiCube-PS3
# Directory where object files are placed
BUILD_DIR = build/ps3
# List of directories containing source code
SOURCE_DIRS = src src/ps3 third_party/bearssl
SHADERS = misc/ps3
TITLE = ClassiCube
APPID = CUBE00200
CONTENTID = UP0001-$(APPID)_00-0000000000000000
ICON0 = misc/ps3/ICON0.png
SFOXML = misc/ps3/sfo.xml
TITLE := ClassiCube
APPID := CUBE00200
CONTENTID := UP0001-$(APPID)_00-0000000000000000
ICON0 := ../misc/ps3/ICON0.png
#---------------------------------------------------------------------------------
# options for code generation
# Compilable files
#---------------------------------------------------------------------------------
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)))
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(OBJS:%.o=%.d)
# Shaders
VCGFILES := $(notdir $(wildcard $(SHADERS)/*.vcg))
FCGFILES := $(notdir $(wildcard $(SHADERS)/*.fcg))
VPOFILES := $(addprefix $(BUILD_DIR)/, $(VCGFILES:.vcg=.vpo))
FPOFILES := $(addprefix $(BUILD_DIR)/, $(FCGFILES:.fcg=.fpo))
OBJS += $(addsuffix .o, $(VPOFILES))
OBJS += $(addsuffix .o, $(FPOFILES))
#---------------------------------------------------------------------------------
# Code generation
#--------------------------------------------------------------------------------
MACHDEP = -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections
CFLAGS = -O2 -DPLAT_PS3 -Wall -mcpu=cell -fno-math-errno $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map -fno-use-linker-plugin
LIBS = -lrsx -lgcm_sys -lio -lsysutil -lrt -llv2 -lm -lnet -lsysmodule
INCLUDE = -I$(PSL1GHT)/ppu/include -I$(PSL1GHT)/ppu/include/simdmath
LIBPATHS = -L$(PSL1GHT)/ppu/lib
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
# Compiler tools
#---------------------------------------------------------------------------------
LIBS := -lrsx -lgcm_sys -lio -lsysutil -lrt -llv2 -lm -lnet -lsysmodule
AS := $(PS3DEV)/ppu/bin/ppu-as
CC := $(PS3DEV)/ppu/bin/ppu-gcc
LD := $(PS3DEV)/ppu/bin/ppu-gcc
STRIP := $(PS3DEV)/ppu/bin/ppu-strip
OBJCOPY := $(PS3DEV)/ppu/bin/ppu-objcopy
PKG := $(PS3DEV)/bin/pkg.py
SFO := $(PS3DEV)/bin/sfo.py
SPRX := $(PS3DEV)/bin/sprxlinker
CGCOMP := $(PS3DEV)/bin/cgcomp
# fake SELF type4 / type8 tools
FSELF := $(PS3DEV)/bin/fself
FSELF_NPDRM := $(PS3DEV)/bin/fself -n
# signed SELF type4 / type8 tools
SELF := $(PS3DEV)/bin/make_self
SELF_NPDRM := $(PS3DEV)/bin/make_self_npdrm
# NPDRM pkg tool
PACKAGE_FINALIZE := $(PS3DEV)/bin/package_finalize
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
# Main targets
#---------------------------------------------------------------------------------
LIBDIRS :=
default: $(BUILD_DIR) $(TARGET).pkg $(TARGET).fake.self
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(SHADERS),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
export BUILDDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
VCGFILES := $(notdir $(wildcard misc/ps3/*.vcg))
FCGFILES := $(notdir $(wildcard misc/ps3/*.fcg))
VPOFILES := $(VCGFILES:.vcg=.vpo)
FPOFILES := $(FCGFILES:.fcg=.fpo)
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
export LD := $(CC)
export OFILES := $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o) \
$(addsuffix .o,$(VPOFILES)) \
$(addsuffix .o,$(FPOFILES))
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(LIBPSL1GHT_INC) \
-I$(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
$(LIBPSL1GHT_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/misc/ps3/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).self
rm -f $(TARGET).elf $(TARGET).fake.self $(TARGET).sprx $(TARGET).self $(TARGET).pkg $(OBJS) $(DEPFILES)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
#---------------------------------------------------------------------------------
else
# Executable generation
#---------------------------------------------------------------------------------
$(TARGET).elf: $(OBJS)
$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@
$(TARGET).fake.self: $(TARGET).elf
$(FSELF) $< $@
$(TARGET).sprx: $(TARGET).elf
$(STRIP) $< -o $@
$(SPRX) $@
$(TARGET).self: $(TARGET).sprx
$(SELF) $< $@
$(TARGET).pkg: $(TARGET).self
mkdir -p $(BUILD_DIR)/pkg/USRDIR
cp $(ICON0) $(BUILD_DIR)/pkg/ICON0.PNG
$(SELF_NPDRM) $(TARGET).sprx $(BUILD_DIR)/pkg/USRDIR/EBOOT.BIN $(CONTENTID) >> /dev/null
$(SFO) --title "$(TITLE)" --appid "$(APPID)" -f $(SFOXML) $(BUILD_DIR)/pkg/PARAM.SFO
$(PKG) --contentid $(CONTENTID) $(BUILD_DIR)/pkg/ $@ >> /dev/null
cp $@ $(TARGET).gnpdrm.pkg
$(PACKAGE_FINALIZE) $(TARGET).gnpdrm.pkg
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
# Object generation
#---------------------------------------------------------------------------------
$(OUTPUT).pkg: $(OUTPUT).self
$(OUTPUT).self: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
$(BUILD_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDE) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: src/ps3/%.c
$(CC) $(CFLAGS) $(INCLUDE) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: src/ps3/%.S
$(CC) $(CFLAGS) $(INCLUDE) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: third_party/bearssl/%.c
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
$(BUILD_DIR)/%.vpo: $(SHADERS)/%.vcg
$(CGCOMP) -v $(CGCFLAGS) $^ $@
$(BUILD_DIR)/%.fpo: $(SHADERS)/%.fcg
$(CGCOMP) -f $(CGCFLAGS) $^ $@
$(BUILD_DIR)/%.vpo.o: $(BUILD_DIR)/%.vpo
bin2s -a 64 $< | $(AS) -o $@
$(BUILD_DIR)/%.fpo.o: $(BUILD_DIR)/%.fpo
bin2s -a 64 $< | $(AS) -o $@
#---------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension
%.bin.o : %.bin
@echo $(notdir $<)
@$(bin2o)
%.vpo.o : %.vpo
@echo $(notdir $<)
@$(bin2o)
%.fpo.o : %.fpo
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
# Dependency tracking
#---------------------------------------------------------------------------------
$(DEPFILES):
include $(wildcard $(DEPFILES))

15
misc/ps3/sfo.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<sfo>
<value name="APP_VER" type="string">01.37</value>
<value name="ATTRIBUTE" type="integer">0</value>
<value name="BOOTABLE" type="integer">1</value>
<value name="CATEGORY" type="string">HG</value>
<value name="LICENSE" type="string">ClassiCube was created with the PSL1GHT homebrew SDK. This application is in no way associated with Sony Computer Entertainment Inc.</value>
<value name="PARENTAL_LEVEL" type="integer">0</value>
<value name="PS3_SYSTEM_VER" type="string">01.8000</value>
<value name="RESOLUTION" type="integer">63</value>
<value name="SOUND_FORMAT" type="integer">279</value>
<value name="TITLE" type="string">ClassiCube</value>
<value name="TITLE_ID" type="string">CUBE00200</value>
<value name="VERSION" type="string">01.37</value>
</sfo>

View File

@ -5,6 +5,8 @@ $(error Failed to find PSPSDK installation)
endif
PSPSDK=$(PSPDEV)/psp/sdk
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -2,6 +2,8 @@ ifeq ($(strip $(YAUL_INSTALL_ROOT)),)
$(error Undefined YAUL_INSTALL_ROOT (install root directory))
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -2,6 +2,8 @@ ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -4,6 +4,8 @@ $(warning export VITASDK=/usr/local/vitasdk)
$(error Failed to find VitaSDK installation)
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -2,6 +2,8 @@ ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options

View File

@ -2,6 +2,9 @@ ifeq ($(strip $(NXDK_DIR)),)
$(error "Please set NXDK_DIR in your environment")
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options
#---------------------------------------------------------------------------------

View File

@ -2,6 +2,9 @@ ifeq ($(strip $(DEVKITXENON)),)
$(error "Please set DEVKITXENON in your environment. export DEVKITXENON=<path to>devkitPPC")
endif
.SUFFIXES:
#---------------------------------------------------------------------------------
# Configurable options
#---------------------------------------------------------------------------------
@ -32,7 +35,7 @@ MACHDEP = -DXENON -m32 -maltivec -fno-pic -mpowerpc64 -mhard-float -L$(DEVKITXEN
LDSCRIPT = $(DEVKITXENON)/app.lds
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
LDFLAGS = -g $(MACHDEP) -Wl,--gc-sections -Wl,-Map,$(notdir $@).map
LDFLAGS = -g $(MACHDEP) -Wl,--gc-sections
LIBS = -lxenon -lm -lfat
CFLAGS += -I$(DEVKITXENON)/usr/include

View File

@ -1,9 +1,8 @@
#include "Core.h"
#if defined CC_BUILD_PS3
#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 <rsx/rsx.h>
#include <sysutil/video.h>
@ -797,4 +796,3 @@ void Gfx_DrawVb_IndexedTris(int verticesCount) {
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
rsxDrawVertexArray(context, GCM_TYPE_QUADS, startVertex, verticesCount);
}
#endif

View File

@ -1,15 +1,13 @@
#include "Core.h"
#if defined PLAT_PS3
#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 "PackedCol.h"
#include "../_PlatformBase.h"
#include "../Stream.h"
#include "../ExtMath.h"
#include "../Funcs.h"
#include "../Window.h"
#include "../Utils.h"
#include "../Errors.h"
#include "../PackedCol.h"
#include <errno.h>
#include <time.h>
#include <stdlib.h>
@ -32,7 +30,7 @@
#include <sys/systime.h>
#include <sys/tty.h>
#include <sys/process.h>
#include "_PlatformConsole.h"
#include "../_PlatformConsole.h"
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = 0x80010006; // ENOENT;
@ -494,4 +492,3 @@ static cc_result GetMachineID(cc_uint32* key) {
Mem_Copy(key, MACHINE_KEY, sizeof(MACHINE_KEY) - 1);
return 0;
}
#endif

View File

@ -1,17 +1,16 @@
#include "Core.h"
#if defined CC_BUILD_PS3
#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 "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 "../Logger.h"
#include "../VirtualKeyboard.h"
#include <io/pad.h>
#include <io/kb.h>
#include <sysutil/sysutil.h>
@ -405,4 +404,3 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED;
}
#endif