# PKG Manager Makefile PYTHON := python3 CC := /opt/ps5-payload-sdk/bin/prospero-clang AR := /opt/ps5-payload-sdk/bin/prospero-ar RANLIB := /opt/ps5-payload-sdk/bin/prospero-ranlib STRIP := /opt/ps5-payload-sdk/bin/prospero-strip SDK := /opt/ps5-payload-sdk TARGET := $(SDK)/target # Always build the checked-in revision and tracked patches. The SDK may hold # an older library with different private structs and unaccelerated signing. LIBSMB2 ?= build/libsmb2/lib/libsmb2.a SMB2_CMAKE ?= $(SDK)/bin/prospero-cmake SMB2_INPUTS := $(wildcard deps/libsmb2/lib/*.[ch] deps/libsmb2/include/*.h deps/libsmb2/include/smb2/*.h deps/libsmb2/libdcerpc/*.[ch] deps/libsmb2/cmake/* deps/libsmb2/cmake/Modules/*) deps/libsmb2/CMakeLists.txt deps/libsmb2/lib/CMakeLists.txt INCLUDES := -Iinclude -Ideps/libsmb2/include -Ideps/libsmb2/include/smb2 -I$(TARGET)/include LIBS := $(TARGET)/lib/libmicrohttpd.a \ $(LIBSMB2) \ -L$(TARGET)/lib -lpthread \ -lSceNetCtl -lSceUserService -lSceSystemService \ -lSceAppInstUtil -lSceNet SRCS := src/main.c src/pkg_parser.c src/pkg_scanner.c src/pkg_cache.c src/smb_client.c src/smb_debug_log.c src/debug_log_retention.c src/installer.c \ src/http_server.c src/stream_server.c src/stream_debug_log.c src/notification.c \ src/multipart.c src/miniz.c src/app_info.c src/sqlite3.c src/icon_blurhash.c src/leftovers.c src/app_diag.c \ src/app_installer.c # Direct-install WebSocket upload modules. SRCS_WS := src/ws_upload.c src/ws_stream.c SRCS_INSTALL_SERVICE := src/install_service.c src/install_ipc.c \ src/install_process.c src/install_helper_blob.S INSTALL_HELPER := build/install-helper.elf OBJS := $(SRCS:.c=.o) ELF := pkgmgr.elf GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") GIT_DIRTY := $(shell git diff --quiet 2>/dev/null || echo "-dirty") BUILD_COMMIT ?= $(GIT_COMMIT)$(GIT_DIRTY) BUILD_DATE ?= $(shell date -u +"%Y-%m-%d_%H:%M:%S_UTC") FRONTEND_DIST := frontend/dist/index.html ASSET_HEADER := include/assets_index_html.h MANIFEST_DIST := frontend/dist/cache.appcache MANIFEST_HEADER := include/assets_cache_appcache.h FAVICON_SVG_DIST := frontend/dist/favicon.svg FAVICON_SVG_HEADER := include/assets_favicon_svg.h ICON_PNG_DIST := frontend/dist/icon.png ICON_PNG_HEADER := include/assets_icon_png.h PARAM_JSON_DIST := assets/param.json PARAM_JSON_HEADER := include/assets_param_json.h ICON0_PNG_DIST := assets/icon0.png ICON0_PNG_HEADER := include/assets_icon0_png.h ASSET_HEADERS := $(ASSET_HEADER) $(MANIFEST_HEADER) $(FAVICON_SVG_HEADER) $(ICON_PNG_HEADER) $(PARAM_JSON_HEADER) $(ICON0_PNG_HEADER) CFLAGS := -Os -Wall -Wno-visibility -DPS5_BUILD -D_BSD_SOURCE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_THREADSAFE=2 -DSQLITE_OMIT_WAL -DPKGMGR_BUILD_COMMIT=\"$(BUILD_COMMIT)\" -DPKGMGR_BUILD_DATE=\"$(BUILD_DATE)\" -ffunction-sections -fdata-sections $(INCLUDES) LDFLAGS := -Wl,--gc-sections # Host test build (uses tests/mock_smb.c instead of real libsmb2; MHD not needed) TEST_CFLAGS := -g -O0 -Wall -Wextra -Iinclude -Ideps/libsmb2/include -Ideps/libsmb2/include/smb2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_THREADSAFE=2 -DSQLITE_OMIT_WAL -DPKGMGR_BUILD_COMMIT=\"$(BUILD_COMMIT)\" -DPKGMGR_BUILD_DATE=\"$(BUILD_DATE)\" TEST_SRCS := src/multipart.c src/pkg_parser.c src/pkg_scanner.c src/pkg_cache.c src/miniz.c src/smb_client.c src/smb_debug_log.c src/debug_log_retention.c src/installer.c src/stream_server.c src/stream_debug_log.c src/notification.c src/app_info.c src/icon_blurhash.c src/leftovers.c src/app_diag.c src/app_installer.c src/sqlite3.c tests/mock_smb.c tests/ps5_sim.c src/ws_upload.c src/ws_stream.c tests/ws_test_client.c TESTS := test_smb_auth test_smb_scan test_pkg_parser test_pkg_scanner test_pkg_cache test_installer test_leftovers test_edge_cases test_multipart test_stream_sim test_ws_upload test_direct_install_e2e test_ws_stream test_ws_stream_far test_parse_mem all: $(ELF) .PHONY: frontend-build frontend-build: @echo "Building frontend..." @VERSION=$$(grep '#define PKGMGR_VERSION' include/version.h | awk '{print $$3}' | tr -d '"'); \ COMMIT=$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \ DATE=$$(date -u +"%Y-%m-%d %H:%M:%S UTC"); \ TITLE="PKG Manager v$$VERSION ($$COMMIT, $$DATE) by PLK"; \ echo "Updating title in index.html to: $$TITLE"; \ (cd frontend && npm ci && VITE_APP_VERSION="$$VERSION" VITE_APP_COMMIT="$$COMMIT" VITE_APP_BUILD_DATE="$$DATE" npm run build); \ TMP=$$(mktemp "$${TMPDIR:-/tmp}/pkgmgr.XXXXXX"); \ sed -e "s|\[\[TITLE_PLACEHOLDER\]\]|$$TITLE|g" -e "s|