-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
130 lines (107 loc) · 6.25 KB
/
CMakeLists.txt
File metadata and controls
130 lines (107 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# OSDMenu CMake configuration
cmake_minimum_required(VERSION 3.13)
option(RELEASE "Build release package" OFF)
include($ENV{PS2SDK}/ps2dev.cmake)
set(BIN2C "$ENV{PS2SDK}/bin/bin2c")
set(PS2_PACKER "$ENV{PS2DEV}/bin/ps2-packer")
include(${CMAKE_SOURCE_DIR}/cmake/functions.cmake)
# Remove default linkfile from CMAKE_EXE_LINKER_FLAGS_INIT
# Targets will add them via target_link_options
string(REGEX REPLACE "-T[^ ]*linkfile[^ ]*" "" CLEANED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT}")
string(REGEX REPLACE " +" " " CLEANED_LINKER_FLAGS "${CLEANED_LINKER_FLAGS}")
string(STRIP "${CLEANED_LINKER_FLAGS}" CLEANED_LINKER_FLAGS)
set(CMAKE_EXE_LINKER_FLAGS_INIT "${CLEANED_LINKER_FLAGS}")
project(OSDMenu C ASM)
# Find Python 3 for KELF signing
find_program(PYTHON3 NAMES python3)
if(NOT PYTHON3)
message(WARNING "Python 3 not found. KELF signing will not work. Install Python 3 or set PYTHON3 manually.")
endif()
option(ENABLE_PRINTF "Enable printf debugging output (requires UDPTTY)" OFF)
option(DEBUG "Disable stripping ELFs (keeps debug symbols)" OFF)
set(UDPTTY_IP "192.168.1.6" CACHE STRING "UDPTTY IP address (used when ENABLE_PRINTF is ON)")
# Build smap_udptty if printf is enabled (used by both launcher and mbr)
if(ENABLE_PRINTF)
set(SMAP_UDPTTY_IRX_FILE "${CMAKE_SOURCE_DIR}/launcher/iop/smap_udptty/smap_udptty.irx")
add_custom_target(smap_udptty
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_SOURCE_DIR}/launcher/iop/smap_udptty" ${CMAKE_MAKE_PROGRAM}
BYPRODUCTS "${SMAP_UDPTTY_IRX_FILE}"
COMMENT "Building smap_udptty IOP module using Makefile"
)
endif()
add_subdirectory(utils/ps1vn)
add_subdirectory(utils/loader)
add_subdirectory(launcher)
add_subdirectory(mbr)
# Build patcher twice: once as osdmenu and once as hosdmenu
set(PATCHER_HOSD OFF)
include(${CMAKE_SOURCE_DIR}/patcher/CMakeLists.txt)
set(PATCHER_HOSD ON)
include(${CMAKE_SOURCE_DIR}/patcher/CMakeLists.txt)
# Build release package
if(RELEASE)
# Build installer only for release
add_subdirectory(utils/installer)
# Get binary directories for file paths
get_target_property(mbr_binary_dir osdmbr BINARY_DIR)
get_target_property(launcher_binary_dir launcher BINARY_DIR)
get_target_property(installer_binary_dir osdmbr-installer BINARY_DIR)
# Custom launcher, MBR and MBR installer paths
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/release/osdmbr/payloads/osdmbr.elf"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/release/osdmbr/payloads"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:osdmbr>" "${CMAKE_BINARY_DIR}/release/osdmbr/payloads/osdmbr.elf"
DEPENDS osdmbr
COMMENT "Copying osdmbr.elf to release package"
)
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/release/launcher/launcher.elf"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/release/launcher"
COMMAND ${CMAKE_COMMAND} -E copy "${launcher_binary_dir}/launcher.elf" "${CMAKE_BINARY_DIR}/release/launcher/launcher.elf"
DEPENDS launcher
COMMENT "Copying launcher.elf to release package"
)
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/release/osdmbr/osdmbr-installer.elf"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/release/osdmbr"
COMMAND ${CMAKE_COMMAND} -E copy "${installer_binary_dir}/osdmbr-installer.elf" "${CMAKE_BINARY_DIR}/release/osdmbr/osdmbr-installer.elf"
DEPENDS osdmbr-installer
COMMENT "Copying osdmbr-installer.elf to release package"
)
add_custom_target(release ALL
# Create release directory structure
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/release"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/release/patcher/kelfbinder"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/release/osdmbr/payloads"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/release/launcher"
# Copy examples
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/examples" "${CMAKE_BINARY_DIR}/release/examples"
# Copy osdmenu.elf and generate PSU
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/osdmenu/osdmenu.elf" "${CMAKE_BINARY_DIR}/release/osdmenu.elf"
COMMAND ${PYTHON3} "${CMAKE_SOURCE_DIR}/utils/scripts/makepsu.py" "${CMAKE_BINARY_DIR}/release/SYS_OSDMENU.psu" "SYS_OSDMENU" "${CMAKE_SOURCE_DIR}/utils/res/psu" "${CMAKE_BINARY_DIR}/release/osdmenu.elf"
# Copy hosdmenu.elf
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/hosdmenu/hosdmenu.elf" "${CMAKE_BINARY_DIR}/release/hosdmenu.elf"
# Copy osdmenu KELF and related files
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/patcher/README.md" "${CMAKE_BINARY_DIR}/release/patcher/README.md"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/utils/res/kelfbinder" "${CMAKE_BINARY_DIR}/release/patcher/kelfbinder"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/osdmenu/OSDMENU.XLF" "${CMAKE_BINARY_DIR}/release/patcher/kelfbinder/KELF/SYSTEM.XLF"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/examples/OSDMENU.CNF" "${CMAKE_BINARY_DIR}/release/patcher/kelfbinder/ASSETS/SYS-CONF/OSDMENU.CNF"
# Copy README.md
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/README.md" "${CMAKE_BINARY_DIR}/release/README.md"
# Copy osdmbr files
COMMAND ${CMAKE_COMMAND} -E copy "${mbr_binary_dir}/OSDMBR.XLF" "${CMAKE_BINARY_DIR}/release/osdmbr/OSDMBR.XLF"
COMMAND ${CMAKE_COMMAND} -E copy "${mbr_binary_dir}/osdmbr.bin" "${CMAKE_BINARY_DIR}/release/osdmbr/payloads/osdmbr.bin"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/mbr/README.md" "${CMAKE_BINARY_DIR}/release/osdmbr/README.md"
# Copy launcher files
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/launcher/README.md" "${CMAKE_BINARY_DIR}/release/launcher/README.md"
DEPENDS
osdmenu
hosdmenu
osdmbr
launcher
"${CMAKE_BINARY_DIR}/release/osdmbr/osdmbr-installer.elf"
"${CMAKE_BINARY_DIR}/release/osdmbr/payloads/osdmbr.elf"
"${CMAKE_BINARY_DIR}/release/launcher/launcher.elf"
COMMENT "Creating release package"
)
endif()