-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeps.sh
More file actions
executable file
·286 lines (263 loc) · 10.1 KB
/
deps.sh
File metadata and controls
executable file
·286 lines (263 loc) · 10.1 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/bin/bash -e
download_ios_archive() {
rm -f $1
wget -O $1 $2
checksum=$(shasum -a 256 $1)
if [[ "$checksum" != "$3 $1" ]]; then
echo "Downloaded file $1 has unexpected checksum $checksum."
exit 1
fi
}
download_ios_deps() {
echo "Downloading sources..."
download_ios_archive gettext.tar.gz https://ftp.gnu.org/gnu/gettext/gettext-0.22.5.tar.gz ec1705b1e969b83a9f073144ec806151db88127f5e40fe5a94cb6c8fa48996a0
download_ios_archive freetype.tar.xz https://downloads.sourceforge.net/project/freetype/freetype2/2.13.3/freetype-2.13.3.tar.xz 0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289
download_ios_archive gmp.tar.xz https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898
download_ios_archive libjpeg-turbo.tar.gz https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/3.0.3/libjpeg-turbo-3.0.3.tar.gz 343e789069fc7afbcdfe44dbba7dbbf45afa98a15150e079a38e60e44578865d
download_ios_archive jsoncpp.tar.gz https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/1.9.5.tar.gz f409856e5920c18d0c2fb85276e24ee607d2a09b5e7d5f0a371368903c275da2
download_ios_archive libogg.tar.gz https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.5.tar.gz 0eb4b4b9420a0f51db142ba3f9c64b333f826532dc0f48c6410ae51f4799b664
download_ios_archive libpng.tar.xz https://downloads.sourceforge.net/project/libpng/libpng16/1.6.43/libpng-1.6.43.tar.xz 6a5ca0652392a2d7c9db2ae5b40210843c0bbc081cbd410825ab00cc59f14a6c
download_ios_archive libvorbis.tar.gz https://github.com/sfence/libvorbis/archive/refs/tags/v1.3.7_macos_apple_silicon.tar.gz 61dd22715136f13317326ea60f9c1345529fbc1bf84cab99d6b7a165bf86a609
download_ios_archive luajit.tar.gz https://github.com/LuaJIT/LuaJIT/archive/f725e44cda8f359869bf8f92ce71787ddca45618.tar.gz 2b5514bd6a6573cb6111b43d013e952cbaf46762d14ebe26c872ddb80b5a84e0
download_ios_archive zstd.tar.gz https://github.com/facebook/zstd/archive/refs/tags/v1.5.6.tar.gz 30f35f71c1203369dc979ecde0400ffea93c27391bfd2ac5a9715d2173d92ff7
download_ios_archive sdl2.tar.gz https://github.com/libsdl-org/SDL/releases/download/release-2.32.0/SDL2-2.32.0.tar.gz f5c2b52498785858f3de1e2996eba3c1b805d08fe168a47ea527c7fc339072d0
download_ios_archive curl.tar.gz https://github.com/curl/curl/releases/download/curl-8_11_0/curl-8.11.0.tar.gz 264537d90e58d2b09dddc50944baf3c38e7089151c8986715e2aaeaaf2b8118f
}
untar_ios_deps() {
downdir=$1
echo "Unarchiving sources..."
tar -xf $downdir/libpng.tar.xz
tar -xf $downdir/gettext.tar.gz
tar -xf $downdir/freetype.tar.xz
tar -xf $downdir/gmp.tar.xz
tar -xf $downdir/libjpeg-turbo.tar.gz
tar -xf $downdir/jsoncpp.tar.gz
tar -xf $downdir/libogg.tar.gz
tar -xf $downdir/libvorbis.tar.gz
tar -xf $downdir/luajit.tar.gz
tar -xf $downdir/zstd.tar.gz
tar -xf $downdir/sdl2.tar.gz
tar -xf $downdir/curl.tar.gz
}
check_ios_file() {
if [ ! -f "$1" ]; then
echo "File $1 not found"
exit 1
fi
}
build_ios_deps() {
arch=$1
osver=$2
xcodever=$3
installdir=$4
# setup environment
xcodeapp="Xcode.app"
if [[ -n $xcodever ]]; then
xcodeapp="Xcode_$xcodever.app"
fi
target_sysroot="/Applications/$xcodeapp/Contents/Developer/Platforms/${arch}.platform/Developer/SDKs/${arch}${osver}.sdk"
if [ ! -d "$target_sysroot" ]; then
echo "Requested target sysroot SDK does not found ${arch}${osver}.sdk"
exit 1
fi
host_sysroot="/Applications/$xcodeapp/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
if [ ! -d "$host_sysroot" ]; then
echo "Requested host sysroot SDK does not found MacOSX.sdk"
exit 1
fi
if [[ -n $xcodever ]]; then
sudo xcode-select -s /Applications/$xcodeapp/Contents/Developer
fi
mkdir -p $installdir
dir=$(pwd)
export CMAKE_PREFIX_PATH=$installdir
export CPPFLAGS="-arch arm64"
export CC="$(xcrun --sdk iphonesimulator --find clang) -isysroot $target_sysroot"
export CXX="$(xcrun --sdk iphonesimulator --find clang++) -isysroot $target_sysroot"
export LDFLAGS="-arch arm64"
HOST_CC="clang -isysroot $host_sysroot"
hostdarwin="--host=arm64-apple-darwin"
hostios="--host=arm64-apple-ios${osver}"
hostdarwin_limit="--host=arm-apple-darwin"
# libpng
cd libpng-*
echo "Configuring libpng..."
./configure "--prefix=$installdir" $hostdarwin --enable-static --disable-shared
echo "Building libpng..."
make -j$(sysctl -n hw.logicalcpu)
# make check
make install
check_ios_file "$installdir/lib/libpng.a"
cd $dir
# freetype
cd freetype-*
echo "Configuring freetype..."
./configure "--prefix=$installdir" "LIBPNG_LIBS=-L$installdir/lib -lpng" \
"LIBPNG_CFLAGS=-I$installdir/include" $hostdarwin \
--enable-static --disable-shared \
--with-harfbuzz=no --with-brotli=no --with-librsvg=no \
"CC_BUILD=$HOST_CC"
echo "Building freetype..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_ios_file "$installdir/lib/libfreetype.a"
cd $dir
# gettext
cd gettext-*
cd gettext-runtime
echo "Configuring gettext..."
./configure "--prefix=$installdir" --enable-static --disable-shared \
--disable-silent-rules --with-included-glib \
--with-included-libcroco --with-included-libunistring --with-included-libxml \
--with-emacs --disable-java --disable-csharp --without-git --without-cvs \
--without-xz --with-included-gettext $hostdarwin
echo "Building gettext..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_ios_file "$installdir/lib/libintl.a"
cd $dir
# gmp
cd gmp-*
echo "Configuring gmp..."
# different Cellar location on Intel and Arm MacOS
# --disable-assembly can be used for cross build
assembly=
if [[ "$(arch)" != "arm64" ]]; then
assembly=--disable-assembly
fi
#./configure "--prefix=$installdir" --with-pic M4=/usr/local/Cellar/m4/1.4.20/bin/m4
CC_FOR_BUILD="$HOST_CC" \
./configure "--prefix=$installdir" --enable-static --disable-shared \
--with-pic M4=/opt/homebrew/Cellar/m4/1.4.20/bin/m4 \
$hostdarwin $assembly
echo "Building gmp..."
make -j$(sysctl -n hw.logicalcpu)
#make check
make install
check_ios_file "$installdir/lib/libgmp.a"
cd $dir
# libjpeg-turbo
cd libjpeg-turbo-*
logdir=$(pwd)
#rm -fr build
#mkdir build
#cd build
echo "Configuring libjpeg-turbo..."
cmake . "-DCMAKE_INSTALL_PREFIX:PATH=$installdir" \
-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=$osver \
-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_SYSROOT=$target_sysroot \
-DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_NAME_DIR=$installdir/lib
echo "Building libjpeg-turbo..."
make -j$(sysctl -n hw.logicalcpu)
make install "PREFIX=$installdir"
check_ios_file "$installdir/lib/libjpeg.a"
cd $dir
# jsoncpp
cd jsoncpp-*
logdir=$(pwd)
rm -fr build
mkdir build
cd build
echo "Configuring jsoncpp..."
cmake .. "-DCMAKE_INSTALL_PREFIX:PATH=$installdir" \
-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=$osver \
-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_SYSROOT=$target_sysroot \
-DBUILD_SHARED_LIBS=OFF \
-DJSONCPP_WITH_TESTS=OFF \
-DCMAKE_INSTALL_NAME_DIR=$installdir/lib
echo "Building jsoncpp..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_ios_file "$installdir/lib/libjsoncpp.a"
cd $dir
# libogg
cd libogg-*
echo "Configuring libogg..."
./configure "--prefix=$installdir" $hostdarwin_limit --enable-static --disable-shared
echo "Building libogg..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_ios_file "$installdir/lib/libogg.a"
cd $dir
# libvorbis
cd libvorbis-*
echo "Configuring libvorbis..."
./autogen.sh
OGG_LIBS="-L$installdir/lib -logg" OGG_CFLAGS="-I$installdir/include" ./configure "--prefix=$installdir" \
--enable-static --disable-shared \
$hostdarwin
echo "Building libvorbis..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_ios_file "$installdir/lib/libvorbis.a"
cd $dir
# luajit
cd LuaJIT-*
echo "Building LuaJIT..."
target_jit_flags="-arch arm64 -isysroot $target_sysroot -DLUAJIT_DISABLE_JIT"
host_jit_flags="-arch arm64 -isysroot $host_sysroot -DLUAJIT_DISABLE_JIT"
make -j$(sysctl -n hw.logicalcpu) "PREFIX=$installdir" \
"CC=$CC" \
"HOST_CC=$HOST_CC" \
"CFLAGS=$target_jit_flags" "HOST_CFLAGS=$host_jit_flags" \
"TARGET_CFLAGS=$target_jit_flags" TARGET_SYS=iOS
make install \
"CFLAGS=$jit_flags" "HOST_CFLAGS=$jit_flags" \
"TARGET_CFLAGS=$jit_flags" TARGET_SYS=iOS\
"PREFIX=$installdir"
check_ios_file "$installdir/lib/libluajit-5.1.a"
cd $dir
# zstd
cd zstd-*
logdir=$(pwd)
cd build/cmake
echo "Configuring zstd..."
cmake . "-DCMAKE_INSTALL_PREFIX:PATH=$installdir" \
-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=$osver \
-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_SYSROOT=$target_sysroot \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_NAME_DIR=$installdir/lib
echo "Building zstd..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_ios_file "$installdir/lib/libzstd.a"
cd $dir
# SDL2
cd SDL2-*
logdir=$(pwd)
rm -fr build
mkdir build
cd build
echo "Configuring SDL2..."
cmake .. "-DCMAKE_INSTALL_PREFIX:PATH=$installdir" \
-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=$osver \
-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_SYSROOT=$target_sysroot \
-DBUILD_SHARED_LIBS=OFF \
-DSDL_OPENGL=0 -DSDL_OPENGLES=0 \
-DCMAKE_INSTALL_NAME_DIR=$installdir/lib
echo "Building SDL2..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_ios_file "$installdir/lib/libSDL2.a"
cd $dir
# curl
cd curl-*
echo "Configuring curl..."
./configure "--prefix=$installdir" --enable-static --disable-shared \
--host=arm-apple-darwin --with-secure-transport \
--disable-ftp --disable-imap --disable-pop3 --disable-smtp --disable-telnet \
--disable-tftp --disable-ldap --disable-rtsp --disable-dict --disable-gopher --disable-smb \
--disable-threaded-resolver --disable-pthreads --disable-verbose \
--disable-manual --disable-unix-sockets --disable-sspi \
--disable-tls-srp --disable-proxy --disable-alt-svc \
--disable-hsts --disable-mqtt --disable-libcurl-option \
--disable-cookies --disable-mime --disable-dateparse --disable-netrc \
--disable-progress-meter --without-libpsl
echo "Building curl..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_ios_file "$installdir/lib/libcurl.a"
cd $dir
}