-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathbuild-cmakelibs.sh
More file actions
executable file
·260 lines (212 loc) · 11.4 KB
/
Copy pathbuild-cmakelibs.sh
File metadata and controls
executable file
·260 lines (212 loc) · 11.4 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/bin/bash
set -e
## Determine the maximum number of processes that Make can work with.
## Also make preparations for different toolchains
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
FETCH="$SCRIPT_DIR/fetch.sh"
PROC_NR=$(getconf _NPROCESSORS_ONLN)
CFLAGS=""
XTRA_OPTS=""
MAKECMD=make
OSVER=$(uname)
if [ ${OSVER:0:5} == MINGW ]; then
XTRA_OPTS=(. -G"MinGW Makefiles")
MAKECMD=${OSVER:0:7}-make
else
XTRA_OPTS=(. -G"Unix Makefiles")
fi
EE_CMAKE_OPTIONS=(-Wno-dev "-DCMAKE_TOOLCHAIN_FILE=$PS2DEV/share/ps2dev.cmake" "-DCMAKE_INSTALL_PREFIX=$PS2SDK/ports" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo "-DCMAKE_PREFIX_PATH=$PS2SDK/ports")
IOP_CMAKE_OPTIONS=("-DCMAKE_TOOLCHAIN_FILE=$PS2DEV/share/ps2dev_iop.cmake" "-DCMAKE_INSTALL_PREFIX=$PS2SDK/ports_iop" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo "-DCMAKE_PREFIX_PATH=$PS2SDK/ports_iop")
IRX_CMAKE_OPTIONS=("-DCMAKE_TOOLCHAIN_FILE=$PS2DEV/share/ps2dev_iop.cmake" "-DCMAKE_PREFIX_PATH=$PS2SDK/ports_iop/irx" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo "-DCMAKE_PREFIX_PATH=$PS2SDK/ports_iop/irx")
function build_ee {
START_DIR="${PWD}"
DIR="$1"
shift
cd "$DIR"
mkdir -p build_ee
cd build_ee
echo "Building '$DIR' for EE..."
CFLAGS="$CFLAGS" cmake "${EE_CMAKE_OPTIONS[@]}" "$@" "${XTRA_OPTS[@]}" ..
"${MAKECMD}" -j "$PROC_NR" all install
cd "${START_DIR}"
}
function build_iop {
START_DIR="${PWD}"
DIR="$1"
shift
cd "$DIR"
mkdir -p build_iop
cd build_iop
echo "Building '$DIR' for IOP..."
CFLAGS="$CFLAGS" cmake "${IOP_CMAKE_OPTIONS[@]}" "$@" "${XTRA_OPTS[@]}" ..
"${MAKECMD}" -j "$PROC_NR" all install
cd "${START_DIR}"
}
function build_irx {
START_DIR="${PWD}"
DIR="$1"
shift
cd "$DIR"
mkdir -p build_irx
cd build_irx
echo "Building '$DIR' for IRX..."
CFLAGS="$CFLAGS" cmake "${IRX_CMAKE_OPTIONS[@]}" "$@" "${XTRA_OPTS[@]}" ..
"${MAKECMD}" -j "$PROC_NR" all install
cd "${START_DIR}"
}
## Create a symbolic link for retro-compatibility ps2dev.cmake and ps2dev_iop.cmake
(cd "${PS2SDK}" && ln -sf "../share/ps2dev.cmake" "ps2dev.cmake" && cd -)
(cd "${PS2SDK}" && ln -sf "../share/ps2dev_iop.cmake" "ps2dev_iop.cmake" && cd -)
##
## Clone repos
##
# Try to solve windows linking issues
$FETCH 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71 https://github.com/madler/zlib.git &
$FETCH v5.8.2 https://github.com/tukaani-project/xz.git &
$FETCH v1.10.0 https://github.com/lz4/lz4.git &
$FETCH v1.11.4 https://github.com/nih-at/libzip.git &
$FETCH 2.18.0 https://github.com/ImageOptim/libimagequant.git &
$FETCH v1.6.53 https://github.com/pnggroup/libpng.git &
$FETCH VER-2-14-1 https://github.com/freetype/freetype.git &
$FETCH v1.17.0 https://github.com/google/googletest.git &
$FETCH 0.2.5 https://github.com/yaml/libyaml.git &
$FETCH 3.1.3 https://github.com/libjpeg-turbo/libjpeg-turbo.git &
$FETCH v1.3.6 https://github.com/xiph/ogg.git &
$FETCH v1.3.7 https://github.com/xiph/vorbis.git &
$FETCH v5.8.2-stable https://github.com/wolfSSL/wolfssl.git &
$FETCH curl-8_18_0 https://github.com/curl/curl.git &
$FETCH 1.9.6 https://github.com/open-source-parsers/jsoncpp.git &
$FETCH libxmp-4.6.3 https://github.com/libxmp/libxmp.git &
$FETCH v1.6 https://github.com/xiph/opus.git &
# We need to clone the whole repo and point to the specific hash for now,
# till they release a new version with cmake compatibility
# we need to clone whole repo because it uses `git describe --tags` for version info
$FETCH cf218fb54929a1f54e30e2cb208a22d08b08c889 https://github.com/xiph/opusfile.git true &
$FETCH 1.5.0 https://github.com/xiph/flac.git true &
# We need to clone the whole repo and point to the specific hash for now,
# till they release a new version with cmake compatibility
$FETCH d1b97ed0020bc620a059d3675d1854b40bd2608d https://github.com/Konstanty/libmodplug.git &
$FETCH libmikmod-3.3.13 https://github.com/sezero/mikmod.git &
# We need to clone a fork, this is a PR opened for ading cmake support
# https://github.com/xiph/theora/pull/14
$FETCH feature/cmake https://github.com/mcmtroffaes/theora.git &
# gsKit requires libtiff
$FETCH v4.7.1 https://gitlab.com/libtiff/libtiff.git &
# SDL requires to have gsKit
$FETCH v1.5.0 https://github.com/ps2dev/gsKit.git &
# SDL requires ps2_drivers
$FETCH 1.7.1 https://github.com/fjtrujy/ps2_drivers &
# Point to a concrete hash for now, till the SDL team releases a new version
$FETCH release-2.32.10 https://github.com/libsdl-org/SDL.git &
$FETCH release-2.8.1 https://github.com/libsdl-org/SDL_mixer.git &
$FETCH release-2.8.8 https://github.com/libsdl-org/SDL_image.git &
$FETCH release-2.2.0 https://github.com/libsdl-org/SDL_net.git
$FETCH release-2.24.0 https://github.com/libsdl-org/SDL_ttf.git &
$FETCH libsmb2-6.2 https://github.com/sahlberg/libsmb2.git &
$FETCH v1.3.18 https://github.com/lsalzman/enet.git &
# Use wget to download argtable2
wget -c --directory-prefix=build http://prdownloads.sourceforge.net/argtable/argtable2-13.tar.gz &
$FETCH v3.2.2.f25c624 https://github.com/argtable/argtable3.git &
$FETCH v1.8.2 https://github.com/hyperrealm/libconfig.git &
$FETCH R_2_7_3 https://github.com/libexpat/libexpat.git &
$FETCH v3.8.4 https://github.com/libarchive/libarchive.git &
$FETCH pcre2-10.47 https://github.com/PCRE2Project/pcre2/ &
$FETCH 11.0.0 https://github.com/leethomason/tinyxml2.git &
# Concrete hash for indicating the version of libmpg used
$FETCH 2eb4320e161247a15f991a30e7919902a3629f19 https://github.com/libsdl-org/mpg123.git &
# NOTE: We need to clone this commit until a version is released.
$FETCH bf5f505d0156ad5c6635d05db06b1bb7593b45b7 https://gitlab.com/bzip2/bzip2.git &
$FETCH 184dac64cd556f435c309bb83ed4a31fe14e1cc5 https://github.com/libgme/game-music-emu.git &
$FETCH v3.0.0 https://github.com/Tehreer/SheenBidi.git
$FETCH 26.01 https://github.com/FNA-XNA/FAudio.git
# wait for fetch jobs to finish
wait
# extract argtable2
tar -xzf build/argtable2-13.tar.gz -C build
# NOTE: jsoncpp
# "snprintf" not found in "std" namespace error may occur, so patch that out here.
pushd build/jsoncpp
sed -i -e 's/std::snprintf/snprintf/' include/json/config.h
popd
# NOTE: xz
# flockfile and funlockfile should be made no-ops
pushd build/xz
sed -i -e 's/defined _WIN32/1/' lib/getopt.c
popd
# NOTE: ARGTABLE2
pushd build/argtable2-13
sed -i -e 's/defined __GNU_LIBRARY__/1/' src/getopt.h
popd
# NOTE: libarchive
pushd build/libarchive
# _timezone used for newlib
sed -i -e 's/defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)/1 || \0/' libarchive/archive_write_set_format_iso9660.c
# 32-bit integer "unsigned long int" prototype not compatible with "unsigned int"
sed -i -e 's/defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L/0 \&\& \0/' libarchive/xxhash.c
popd
pushd build/SDL_net
sed -i -e 's|#include <net/if.h>||' SDLnetsys.h
popd
###
### Change to the build folder
###
cd build
##
## Build cmake projects
##
build_ee zlib -DUNIX:BOOL=ON -DZLIB_BUILD_EXAMPLES=OFF -DZLIB_BUILD_SHARED=OFF -DINSTALL_PKGCONFIG_DIR="${PS2SDK}/ports/lib/pkgconfig"
build_ee xz -DTUKLIB_CPUCORES_FOUND=ON -DTUKLIB_PHYSMEM_FOUND=ON -DHAVE_GETOPT_LONG=OFF -DBUILD_TESTING=OFF -DXZ_TOOL_XZ=OFF
build_ee lz4/build/cmake -DLZ4_POSITION_INDEPENDENT_LIB=OFF -DLZ4_BUILD_CLI=OFF -DLZ4_BUILD_LEGACY_LZ4C=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_ee libzip -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF
build_ee libimagequant -DLIB_INSTALL_DIR=lib -DBUILD_WITH_SSE=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_ee libpng -DPNG_SHARED=OFF -DPNG_STATIC=ON
build_ee freetype
build_ee googletest -DCMAKE_CXX_FLAGS='-D_BSD_SOURCE -DGTEST_HAS_POSIX_RE=0'
build_ee libyaml -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_ee libjpeg-turbo -DENABLE_SHARED=FALSE -DWITH_SIMD=0
build_ee ogg -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_ee vorbis -DCMAKE_POLICY_VERSION_MINIMUM=3.5
CFLAGS="-DWOLFSSL_GETRANDOM -DNO_WRITEV -DXINET_PTON\(...\)=0" build_ee wolfssl -DWOLFSSL_CRYPT_TESTS=OFF -DWOLFSSL_EXAMPLES=OFF -DWOLFSSL_CURL=ON -DWARNING_C_FLAGS=-w
CFLAGS="-DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 -DNO_WRITEV" build_ee curl -DENABLE_THREADED_RESOLVER=OFF -DCURL_USE_OPENSSL=OFF -DCURL_USE_WOLFSSL=ON -DCURL_DISABLE_SOCKETPAIR=ON -DHAVE_BASENAME=NO -DHAVE_ATOMIC=NO -DENABLE_WEBSOCKETS=ON -DENABLE_IPV6=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF
build_ee libxmp -DBUILD_SHARED=OFF
build_ee opus
build_ee opusfile -DOP_DISABLE_HTTP=ON -DOP_DISABLE_DOCS=ON -DOP_DISABLE_EXAMPLES=ON
build_ee flac -DCMAKE_BUILD_TYPE=Release -DBUILD_PROGRAMS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DBUILD_DOCS=OFF -DINSTALL_MANPAGES=OFF -DCMAKE_C_FLAGS='-Wno-incompatible-pointer-types'
build_ee libmodplug -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_ee mikmod/libmikmod -DENABLE_SHARED=0 -DENABLE_DOC=OFF
build_ee jsoncpp -DBUILD_OBJECT_LIBS=OFF -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
CFLAGS="-Wno-implicit-function-declaration" build_ee theora -DHAVE_STRING_H=ON -DBUILD_EXAMPLES=OFF
# libtiff and libtiff_ps2_addons is mandatory for gsKit
CFLAGS="-Dlfind=bsearch" build_ee libtiff -Dtiff-tools=OFF -Dtiff-tests=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
# gsKit is mandatory for SDL
build_ee gsKit -DCMAKE_POLICY_VERSION_MINIMUM=3.5
# ps2_drivers is mandatory for SDL
build_ee ps2_drivers -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DBUILD_SAMPLES=OFF
build_ee SDL -DCMAKE_POSITION_INDEPENDENT_CODE=OFF -DSDL_TESTS=OFF
build_ee SDL_mixer -DCMAKE_POSITION_INDEPENDENT_CODE=OFF -DSDL2MIXER_DEPS_SHARED=OFF -DSDL2MIXER_MOD_MODPLUG=ON -DSDL2MIXER_OPUS=OFF -DSDL2MIXER_WAVPACK=OFF -DSDL2MIXER_MIDI=OFF -DSDL2MIXER_FLAC=OFF -DSDL2MIXER_SAMPLES=OFF
build_ee SDL_net -DCMAKE_POSITION_INDEPENDENT_CODE=OFF -DSDL2NET_SAMPLES=OFF
build_ee SDL_image -DCMAKE_POSITION_INDEPENDENT_CODE=OFF -DSDL2IMAGE_TIF=OFF
build_ee SDL_ttf -DCMAKE_POSITION_INDEPENDENT_CODE=OFF -DSDL2TTF_SAMPLES=OFF
build_ee enet
# Build argtable2
CFLAGS="-Wno-implicit-function-declaration -D__GNU_LIBRARY__" build_ee argtable2-13 -DHAVE_STRINGS_H=ON -DHAVE_STDC_HEADERS=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
# Copy manually the argtable2.h header
install -m644 argtable2-13/src/argtable2.h $PS2SDK/ports/include/
build_ee argtable3 -DARGTABLE3_INSTALL_CMAKEDIR="${PS2SDK}/ports/lib/cmake/" -DARGTABLE3_REPLACE_GETOPT=OFF -DARGTABLE3_ENABLE_EXAMPLES=OFF -DARGTABLE3_ENABLE_TESTS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_ee libsmb2 -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_ee libsmb2 -DPS2RPC=1 -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_iop libsmb2 -DCMAKE_POLICY_VERSION_MINIMUM=3.5
# Disabling for now, as it has some issues with the IRX build in CPU with several cores
# build_irx libsmb2 -DBUILD_IRX=1 -DCMAKE_POLICY_VERSION_MINIMUM=3.5
CFLAGS="-DHAVE_NEWLOCALE -DHAVE_USELOCALE -DHAVE_FREELOCALE" build_ee libconfig -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
CFLAGS="-D_BSD_SOURCE" build_ee libexpat/expat -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_BUILD_TESTS=OFF -DEXPAT_SHARED_LIBS=OFF -DEXPAT_BUILD_TOOLS=OFF
build_ee libarchive -DBUILD_SHARED_LIBS=OFF -DENABLE_WERROR=OFF -DENABLE_TEST=OFF
CFLAGS="-Wno-incompatible-pointer-types" build_ee pcre2 -DPCRE2_BUILD_PCRE2GREP=OFF -DPCRE2_BUILD_TESTS=OFF
build_ee tinyxml2 -DBUILD_TESTS=OFF
build_ee mpg123/ports/cmake -DBUILD_PROGRAM=OFF
build_ee bzip2 -DENABLE_LIBRARY=ON -DENABLE_STATIC_LIB=ON -DENABLE_SHARED_LIB=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
build_ee SheenBidi
CFLAGS="-Wno-incompatible-pointer-types" build_ee FAudio -DBUILD_SDL3=OFF
build_ee game-music-emu -DGME_BUILD_SHARED=OFF -DGME_ENABLE_UBSAN=OFF -DGME_BUILD_TESTING=OFF -DGME_BUILD_EXAMPLES=OFF
# Finish
cd ..