Files
MoHadiShibli--Control4Free/Makefile
T
MoHadiShibli de0c0a3eea Release scaffolding: changelog, CI, and a research build for rumble
CHANGELOG.md says what 1.0.0 is. The CI workflow builds both toolchain images,
the payload and the package, runs every host test, and on a vX.Y.Z tag checks the
tag against VERSION before publishing the ELF, the package and their SHA256 sums.

`make C4F_PROBE=1` adds a poll of scePadVirtualDeviceGetRemoteSetting for every
live controller, logging the return code and only the bytes that change. That is
the one call that looks like it could carry a game's rumble and light-bar state
back to a virtual pad, and nothing is known about its buffer, so this is how to
find out on hardware. It builds to control4free-probe.elf and is never in a
release.
2026-10-05 02:36:26 +03:00

71 lines
2.0 KiB
Makefile

# Control4Free -- system-wide virtual controllers for the PS4 (GoldHEN payload).
#
# Build:
# make # build/control4free.elf
# make C4F_PROBE=1 # plus the rumble/light-bar research probe (dev only)
# make clean
#
# A build needs the ps4-payload-sdk; docker/Dockerfile has it, and
# tools/build.ps1 runs this inside the container.
ifdef PS4_PAYLOAD_SDK
include $(PS4_PAYLOAD_SDK)/toolchain/orbis.mk
else
$(error PS4_PAYLOAD_SDK is undefined -- build in Docker, or point it at an SDK)
endif
VERSION := $(shell cat VERSION)
NAME := control4free
ELF := build/$(NAME).elf
OBJDIR := build/payload
SOURCES := src/main.c src/log.c src/vda.c src/klog_line.c src/web.c src/net.c
# Research build: logs what scePadVirtualDeviceGetRemoteSetting returns. Its ELF
# gets its own name, so it can never be mistaken for a release.
ifdef C4F_PROBE
EXTRA_CFLAGS := -DC4F_PROBE_SETTING
ELF := build/$(NAME)-probe.elf
OBJDIR := build/probe
endif
OBJECTS := $(SOURCES:src/%.c=$(OBJDIR)/%.o) $(OBJDIR)/client.o $(OBJDIR)/assets.o
CFLAGS += -std=gnu11 -Wall -Wextra -Wpointer-arith -g -O2
CFLAGS += -MMD -MP
CFLAGS += -Iinclude -Ivendor/jsmn -DC4F_VERSION='"$(VERSION)"' $(EXTRA_CFLAGS)
LDFLAGS += -lScePad -lSceUserService -ldl -lpthread
.PHONY: all clean
.DEFAULT_GOAL := all
-include $(OBJECTS:.o=.d)
all: $(ELF)
$(OBJDIR) build:
mkdir -p $@
$(OBJDIR)/%.o: src/%.c | $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
build/client.c: client/index.html tools/embed_client.py | build
python3 tools/embed_client.py $< $@
$(OBJDIR)/client.o: build/client.c | $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
# The manifest and icon the page points at, so it can live on a home screen.
build/assets.c: client/manifest.webmanifest client/icon-192.png tools/embed_file.py | build
python3 tools/embed_file.py $@ c4fManifest=client/manifest.webmanifest c4fIcon=client/icon-192.png
$(OBJDIR)/assets.o: build/assets.c | $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
$(ELF): $(OBJECTS) | build
$(CC) -o $@ $(OBJECTS) $(LDFLAGS)
@echo "built $@ ($(VERSION))"
clean:
rm -rf build