A simple payload for ejecting disks
| 1 | # Copyright (C) 2026 |
| 2 | # |
| 3 | # PS4/PS5 Disc Eject Payload - Makefile |
| 4 | # |
| 5 | # Compile for PS5 (default): |
| 6 | # make |
| 7 | # make ps5 |
| 8 | # |
| 9 | # Compile for PS4: |
| 10 | # make ps4 |
| 11 | # |
| 12 | # Compile for both: |
| 13 | # make all-platforms |
| 14 | # |
| 15 | # Test on console: |
| 16 | # export PS5_HOST=<console-ip> |
| 17 | # export PS5_PORT=9021 |
| 18 | # make test-ps5 |
| 19 | # |
| 20 | # This file is free software; you can redistribute it and/or modify it |
| 21 | # under the terms of the GNU General Public License as published by |
| 22 | # the Free Software Foundation; either version 3 of the License, or |
| 23 | # (at your option) any later version. |
| 24 | # |
| 25 | # This program is distributed in the hope that it will be useful, but |
| 26 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 27 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 28 | # General Public License for more details. |
| 29 | # |
| 30 | # You should have received a copy of the GNU General Public License |
| 31 | # along with this program; see the file COPYING. If not see |
| 32 | # <http://www.gnu.org/licenses/>. |
| 33 | |
| 34 | # Base directory |
| 35 | MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) |
| 36 | |
| 37 | # ---------- SDK Paths (external directory) ---------- |
| 38 | PS5_PAYLOAD_SDK ?= $(MAKEFILE_DIR)../external/ps5-payload-sdk |
| 39 | PS4_PAYLOAD_SDK ?= $(MAKEFILE_DIR)../external/ps4-payload-sdk |
| 40 | |
| 41 | # ---------- Console configuration ---------- |
| 42 | PS5_HOST ?= ps5 |
| 43 | PS5_PORT ?= 9021 |
| 44 | PS4_HOST ?= ps4 |
| 45 | PS4_PORT ?= 9020 |
| 46 | |
| 47 | # ---------- Output ---------- |
| 48 | ELF_PS5 := disc_eject_ps5.elf |
| 49 | ELF_PS4 := disc_eject_ps4.elf |
| 50 | |
| 51 | # ---------- Sources ---------- |
| 52 | SRC := main.c |
| 53 | |
| 54 | # ---------- Compilation flags ---------- |
| 55 | # |
| 56 | # -Wall -Werror : Strict warnings |
| 57 | # -g : Debug symbols (useful with gdb) |
| 58 | # -O2 : Optimization |
| 59 | # |
| 60 | # To enable modern notifications (libSceNotification): |
| 61 | # make MODERN_NOTIFY=1 |
| 62 | # |
| 63 | CFLAGS := -Wall -Werror -g -O2 |
| 64 | |
| 65 | ifdef MODERN_NOTIFY |
| 66 | CFLAGS += -DUSE_SCE_NOTIFICATION -lSceNotification |
| 67 | endif |
| 68 | |
| 69 | # ---------- Main targets ---------- |
| 70 | |
| 71 | .PHONY: all ps4 ps5 all-platforms clean test-ps5 test-ps4 debug-ps5 debug-ps4 |
| 72 | |
| 73 | all: ps5 |
| 74 | |
| 75 | ps5: |
| 76 | @echo "Building for PS5 using $(PS5_PAYLOAD_SDK)" |
| 77 | $(MAKE) -f Makefile.ps5 |
| 78 | |
| 79 | ps4: |
| 80 | @echo "Building for PS4 using $(PS4_PAYLOAD_SDK)" |
| 81 | $(MAKE) -f Makefile.ps4 |
| 82 | |
| 83 | all-platforms: ps4 ps5 |
| 84 | |
| 85 | clean: |
| 86 | rm -f $(ELF_PS5) $(ELF_PS4) |
| 87 | |
| 88 | # ---------- Deploy & Test ---------- |
| 89 | |
| 90 | test-ps5: $(ELF_PS5) |
| 91 | $(PS5_DEPLOY) -h $(PS5_HOST) -p $(PS5_PORT) $^ |
| 92 | |
| 93 | test-ps4: $(ELF_PS4) |
| 94 | $(PS4_DEPLOY) -h $(PS4_HOST) -p $(PS4_PORT) $^ |
| 95 | |
| 96 | # ---------- Remote debug ---------- |
| 97 | # |
| 98 | # Requires gdbsrv running on the console (port 2159) |
| 99 | # |
| 100 | debug-ps5: $(ELF_PS5) |
| 101 | gdb-multiarch \ |
| 102 | -ex "set architecture i386:x86-64" \ |
| 103 | -ex "target extended-remote $(PS5_HOST):2159" \ |
| 104 | -ex "file $(ELF_PS5)" \ |
| 105 | -ex "remote put $(ELF_PS5) /data/$(ELF_PS5)" \ |
| 106 | -ex "set remote exec-file /data/$(ELF_PS5)" \ |
| 107 | -ex "start" |
| 108 | |
| 109 | debug-ps4: $(ELF_PS4) |
| 110 | gdb-multiarch \ |
| 111 | -ex "set architecture i386:x86-64" \ |
| 112 | -ex "target extended-remote $(PS4_HOST):2159" \ |
| 113 | -ex "file $(ELF_PS4)" \ |
| 114 | -ex "remote put $(ELF_PS4) /data/$(ELF_PS4)" \ |
| 115 | -ex "set remote exec-file /data/$(ELF_PS4)" \ |
| 116 | -ex "start" |
| 117 |