-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeps.sh
More file actions
executable file
·273 lines (252 loc) · 9.14 KB
/
deps.sh
File metadata and controls
executable file
·273 lines (252 loc) · 9.14 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
#!/bin/bash -e
download_macos_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_macos_deps() {
echo "Downloading sources..."
download_macos_archive gettext.tar.gz https://ftp.gnu.org/gnu/gettext/gettext-0.22.5.tar.gz ec1705b1e969b83a9f073144ec806151db88127f5e40fe5a94cb6c8fa48996a0
download_macos_archive freetype.tar.xz https://downloads.sourceforge.net/project/freetype/freetype2/2.13.3/freetype-2.13.3.tar.xz 0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289
download_macos_archive gmp.tar.xz https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898
download_macos_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_macos_archive jsoncpp.tar.gz https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/1.9.5.tar.gz f409856e5920c18d0c2fb85276e24ee607d2a09b5e7d5f0a371368903c275da2
download_macos_archive libogg.tar.gz https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.5.tar.gz 0eb4b4b9420a0f51db142ba3f9c64b333f826532dc0f48c6410ae51f4799b664
download_macos_archive libpng.tar.xz https://downloads.sourceforge.net/project/libpng/libpng16/1.6.43/libpng-1.6.43.tar.xz 6a5ca0652392a2d7c9db2ae5b40210843c0bbc081cbd410825ab00cc59f14a6c
download_macos_archive libvorbis.tar.gz https://github.com/sfence/libvorbis/archive/refs/tags/v1.3.7_macos_apple_silicon.tar.gz 61dd22715136f13317326ea60f9c1345529fbc1bf84cab99d6b7a165bf86a609
download_macos_archive luajit.zip https://github.com/sfence/LuaJIT/archive/refs/heads/v2.1.zip 17ed9de0c3260de1932933121498437a276a25d117f175b6007458cc4617e1ea
download_macos_archive zstd.tar.gz https://github.com/facebook/zstd/archive/refs/tags/v1.5.6.tar.gz 30f35f71c1203369dc979ecde0400ffea93c27391bfd2ac5a9715d2173d92ff7
download_macos_archive sdl2.tar.gz https://github.com/libsdl-org/SDL/releases/download/release-2.32.0/SDL2-2.32.0.tar.gz f5c2b52498785858f3de1e2996eba3c1b805d08fe168a47ea527c7fc339072d0
download_macos_archive openal-soft.tar.gz https://github.com/kcat/openal-soft/archive/refs/tags/1.24.3.tar.gz 7e1fecdeb45e7f78722b776c5cf30bd33934b961d7fd2a11e0494e064cc631ce
}
untar_macos_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
unzip $downdir/luajit.zip
tar -xf $downdir/zstd.tar.gz
tar -xf $downdir/sdl2.tar.gz
tar -xf $downdir/openal-soft.tar.gz
}
check_macos_file() {
if [ ! -f "$1" ]; then
echo "File $1 not found"
exit 1
fi
}
build_macos_deps() {
arch=$1
osver=$2
xcodever=$3
installdir=$4
with_angle=$5
dir=$(pwd)
# setup environment
xcodeapp="Xcode.app"
if [[ -n $xcodever ]]; then
xcodeapp="Xcode_$xcodever.app"
fi
sysroot="/Applications/$xcodeapp/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${osver}.sdk"
if [ ! -d "$sysroot" ]; then
echo "SDK not in $sysroot. Try command line tools."
sysroot="/Library/Developer/CommandLineTools/SDKs/MacOSX${osver}.sdk"
fi
if [ ! -d "$sysroot" ]; then
echo "Requested sysroot SDK does not found MacOSX${osver}.sdk (sysroot = $sysroot)"
exit 1
fi
if [[ -n $xcodever ]]; then
sudo xcode-select -s /Applications/$xcodeapp/Contents/Developer
fi
export MACOSX_DEPLOYMENT_TARGET=$osver
export MACOS_DEPLOYMENT_TARGET=$osver
export CMAKE_PREFIX_PATH=$installdir
export CPPFLAGS="-arch ${arch}"
export CC="clang -arch ${arch}"
export CXX="clang++ -arch ${arch} -isysroot $sysroot"
export LDFLAGS="-arch ${arch}"
export SDKROOT=$sysroot
hostdarwin="--host=${arch}-apple-darwin"
hostmacos="--host=${arch}-apple-macos${osver}"
hostdarwin_limit="--host=${arch}-apple-darwin"
if [[ $arch == "arm64" ]]; then
hostdarwin_limit="--host=arm-apple-darwin"
fi
# 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_macos_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=clang -target ${arch}"
echo "Building freetype..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_macos_file "$installdir/lib/libfreetype.a"
cd $dir
# gettext
cd gettext-*
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_macos_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)" != "$arch" ]]; then
assembly=--disable-assembly
fi
#./configure "--prefix=$installdir" --with-pic M4=/usr/local/Cellar/m4/1.4.20/bin/m4
./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_macos_file "$installdir/lib/libgmp.a"
cd $dir
# libjpeg-turbo
cd libjpeg-turbo-*
echo "Configuring libjpeg-turbo..."
cmake . "-DCMAKE_INSTALL_PREFIX:PATH=$installdir" \
-DCMAKE_OSX_ARCHITECTURES=$arch \
-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_macos_file "$installdir/lib/libjpeg.a"
cd $dir
# jsoncpp
cd jsoncpp-*
logdir=$(pwd)
mkdir build
cd build
echo "Configuring jsoncpp..."
cmake .. "-DCMAKE_INSTALL_PREFIX:PATH=$installdir" \
-DCMAKE_OSX_ARCHITECTURES=$arch \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_NAME_DIR=$installdir/lib
echo "Building jsoncpp..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_macos_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_macos_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" \
$hostdarwin --enable-static --disable-shared
echo "Building libvorbis..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_macos_file "$installdir/lib/libvorbis.a"
cd $dir
# luajit
cd LuaJIT-*
echo "Building LuaJIT..."
jit_flags="-arch $arch -isysroot $sysroot"
make amalg -j$(sysctl -n hw.logicalcpu) "PREFIX=$installdir" \
"CFLAGS=$jit_flags" "HOST_CFLAGS=$jit_flags" \
"TARGET_CFLAGS=$jit_flags"
make install \
"CFLAGS=$jit_flags" "HOST_CFLAGS=$jit_flags" \
"TARGET_CFLAGS=$jit_flags" \
"PREFIX=$installdir"
check_macos_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_OSX_ARCHITECTURES=$arch \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_NAME_DIR=$installdir/lib
echo "Building zstd..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_macos_file "$installdir/lib/libzstd.a"
cd $dir
# SDL2
cd SDL2-*
logdir=$(pwd)
rm -fr build
mkdir build
cd build
echo "Configuring SDL2..."
SDL_OPENGL=1
if [[ "$with_angle" == "yes" ]]; then
SDL_OPENGL=0
fi
cmake .. "-DCMAKE_INSTALL_PREFIX:PATH=$installdir" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$osver \
-DCMAKE_OSX_ARCHITECTURES=$arch \
-DBUILD_SHARED_LIBS=OFF \
-DSDL_OPENGL=${SDL_OPENGL} -DSDL_OPENGLES=0 \
-DCMAKE_INSTALL_NAME_DIR=$installdir/lib
echo "Building SDL2..."
make -j$(sysctl -n hw.logicalcpu)
make install
check_macos_file "$installdir/lib/libSDL2.a"
cd $dir
# OpenAL-soft
cd openal-soft-*
rm -fr build
mkdir build
cd build
echo "Configuring OpenAL-soft..."
cmake .. "-DCMAKE_INSTALL_PREFIX:PATH=$installdir" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$osver \
-DCMAKE_OSX_ARCHITECTURES=$arch \
-DLIBTYPE=STATIC -DALSOFT_UTILS=OFF -DALSOFT_EXAMPLES=OFF \
-DCMAKE_INSTALL_NAME_DIR=$installdir/lib
echo "Building OpenAL-soft..."
make -j$(sysctl -n hw.logicalcpu)
make install 2>&1
cd $dir
}