blob: df1df79b1cd6d2add9b457620716821003eaad6c (
plain) (
blame)
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
|
# libpsn00b interface targets
# (C) 2021 spicyjpeg - MPL licensed
# This script creates several "virtual" targets (psn00bsdk_*) that set include
# directories and compiler flags when a target is linked against them. These
# all end up in the autogenerated libpsn00b setup script after installation,
# so this file is only included when building libpsn00b.
# The following targets are currently defined:
# - psn00bsdk_common
# - psn00bsdk_object_lib (same as psn00bsdk_common)
# - psn00bsdk_static_exe
# - psn00bsdk_dynamic_exe
# - psn00bsdk_static_lib
# - psn00bsdk_shared_lib
# - psn00bsdk_module_lib (same as psn00bsdk_shared_lib)
include(GNUInstallDirs)
set(PSN00BSDK_VIRTUAL_TARGETS "")
macro(_add_interface_target name)
add_library(${name} INTERFACE)
list(APPEND PSN00BSDK_VIRTUAL_TARGETS ${name})
target_compile_options(
${name} INTERFACE
${_aflags}
$<$<COMPILE_LANGUAGE:C,CXX>:${_cflags}>
$<$<COMPILE_LANGUAGE:CXX>:${_cxxflags}>
)
target_link_options (${name} INTERFACE ${_ldflags})
target_link_libraries(${name} INTERFACE ${ARGN})
endmacro()
macro(_add_alias_target name)
#add_library(${name} ALIAS ${ARGN})
add_library(${name} INTERFACE)
list(APPEND PSN00BSDK_VIRTUAL_TARGETS ${name})
target_link_libraries(${name} INTERFACE ${ARGN})
endmacro()
# Options common to all target types:
# - Define PLAYSTATION=1 and set include directories
# - Optimize for MIPS R3000
# - Inject zero checks into division operations (will throw breaks)
# - All standard libraries (including libgcc) disabled
# - Put all symbols into separate sections when building
# - C++ features that require runtime support disabled
# - Unused section stripping enabled
set(_aflags -msoft-float -march=r3000 -mtune=r3000 -mabi=32)
set(_cflags -mdivide-breaks -O2 -ffreestanding -fno-builtin -nostdlib -fdata-sections -ffunction-sections -fsigned-char -fno-strict-overflow -fdiagnostics-color=always)
set(_cxxflags -fno-exceptions -fno-rtti -fno-unwind-tables -fno-threadsafe-statics -fno-use-cxa-atexit)
set(_ldflags -nostdlib -Wl,-gc-sections)
_add_interface_target(psn00bsdk_common)
_add_alias_target (psn00bsdk_object_lib psn00bsdk_common)
target_compile_definitions(
psn00bsdk_common INTERFACE
PLAYSTATION=1
$<$<CONFIG:DEBUG>:DEBUG=1>
)
# Options for executables without support for dynamic linking:
# - Position-independent code disabled
# - GP-relative addressing enabled only for local symbols
# - ABI-compatible calls disabled (incompatible with GP-relative addr)
set(_aflags -G8)
set(_cflags -mno-abicalls -mgpopt -mno-extern-sdata)
set(_cxxflags)
set(_ldflags -G8 -static)
_add_interface_target(psn00bsdk_static_exe psn00bsdk_common ${PSN00BSDK_LIBRARIES})
# Options for executables with support for dynamic linking:
# - Position-independent code disabled
# - GP-relative addressing disabled
# - ABI-compatible calls disabled (must be performed manually)
set(_aflags -G0)
set(_cflags -mno-abicalls -mno-gpopt)
set(_cxxflags)
set(_ldflags -G0 -static)
_add_interface_target(psn00bsdk_dynamic_exe psn00bsdk_common ${PSN00BSDK_LIBRARIES})
# Options for static libraries:
# - GP-relative addressing disabled
# - ABI-compatible calls disabled
# - Local stripping enabled
set(_aflags -G0 -Wa,--strip-local-absolute)
set(_cflags -mno-abicalls -mno-gpopt)
set(_cxxflags)
set(_ldflags)
_add_interface_target(psn00bsdk_static_lib psn00bsdk_common)
# Options for dynamically-loaded libraries:
# - Position-independent code enabled
# - GP-relative addressing disabled (incompatible with ABI calls)
# - ABI-compatible calls enabled
set(_aflags -G0)
set(_cflags -mabicalls -mshared -mno-gpopt -fPIC)
set(_cxxflags)
set(_ldflags -G0 -shared)
_add_interface_target(psn00bsdk_shared_lib psn00bsdk_common)
_add_alias_target (psn00bsdk_module_lib psn00bsdk_shared_lib)
|