-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_dependencies.sh
executable file
·290 lines (238 loc) · 6.78 KB
/
build_dependencies.sh
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
286
287
288
289
290
#!/bin/sh
SAVED_CFLAGS=$CFLAGS
SAVED_LDFLAGS=$LDFLAGS
PROJECT_ROOT=$(pwd)
# IM4 xcode project file
IM4PROJ=IM4.xcodeproj
# dependency directory
DEPDIR=dep
# dependencies
OPENSSL_VERSION=3.4.0
LIBSTROPHE_VERSION=0.13.1
LIBGPGERR_VERSION=1.51
LIBGCRYPT_VERSION=1.11.0
LIBOTR_VERSION=4.1.1
ZLIB_VERSION=1.3.1
# dependency
DL_OPENSSL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz
DL_ZLIB=http://zlib.net/zlib-$ZLIB_VERSION.tar.gz
DL_LIBSTROPHE=https://github.com/strophe/libstrophe/releases/download/$LIBSTROPHE_VERSION/libstrophe-$LIBSTROPHE_VERSION.tar.bz2
DL_LIBGPGERR=https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-$LIBGPGERR_VERSION.tar.bz2
DL_LIBGCRYPT=https://gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.bz2
DL_LIBOTR=https://otr.cypherpunks.ca/libotr-$LIBOTR_VERSION.tar.gz
SHA256_OPENSSL="e15dda82fe2fe8139dc2ac21a36d4ca01d5313c75f99f46c4e8a27709b7294bf openssl-3.4.0.tar.gz"
SHA256_ZLIB="9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 zlib-1.3.1.tar.gz"
SHA256_LIBSTROPHE="7768724d3d5f5f7b774fae4390be8d5ec00db71205e72477c3977bd90e1120cf libstrophe-0.13.1.tar.bz2"
SHA256_LIBGPGERR="be0f1b2db6b93eed55369cdf79f19f72750c8c7c39fc20b577e724545427e6b2 libgpg-error-1.51.tar.bz2"
SHA256_LIBGCRYPT="09120c9867ce7f2081d6aaa1775386b98c2f2f246135761aae47d81f58685b9c libgcrypt-1.11.0.tar.bz2"
SHA256_LIBOTR="8b3b182424251067a952fb4e6c7b95a21e644fbb27fbd5f8af2b2ed87ca419f5 libotr-4.1.1.tar.gz"
DIR_OPENSSL=openssl-$OPENSSL_VERSION
DIR_ZLIB=zlib-$ZLIB_VERSION
DIR_LIBSTROPHE=libstrophe-$LIBSTROPHE_VERSION
DIR_LIBGPGERR=libgpg-error-$LIBGPGERR_VERSION
DIR_LIBGCRYPT=libgcrypt-$LIBGCRYPT_VERSION
DIR_LIBOTR=libotr-$LIBOTR_VERSION
# check current directory
if [ ! -d "$IM4PROJ" ]; then
echo "Xcode project $IM4PROJ not found. Abort."
exit 1
fi
# download dependencies
mkdir -p $DEPDIR
cd $DEPDIR
for url in $DL_OPENSSL $DL_ZLIB $DL_LIBSTROPHE $DL_LIBGPGERR $DL_LIBGCRYPT $DL_LIBOTR; do
# clear previous downloads
rm -Rf $(basename $url)
echo "download: $url"
if ! curl -L -O $url; then
echo "download failed"
exit 1
fi
tar xvfz $(basename $url)
done
# check download hashes
DL_OPENSSL_SHA256=$(shasum -a 256 openssl-$OPENSSL_VERSION.tar.gz)
DL_ZLIB_SHA256=$(shasum -a 256 zlib-$ZLIB_VERSION.tar.gz)
DL_LIBSTROPHE_SHA256=$(shasum -a 256 libstrophe-$LIBSTROPHE_VERSION.tar.bz2)
DL_LIBGPGERR_SHA256=$(shasum -a 256 libgpg-error-$LIBGPGERR_VERSION.tar.bz2)
DL_LIBGCRYPT_SHA256=$(shasum -a 256 libgcrypt-$LIBGCRYPT_VERSION.tar.bz2)
DL_LIBOTR_SHA256=$(shasum -a 256 libotr-$LIBOTR_VERSION.tar.gz)
if [ "$SHA256_OPENSSL" != "$DL_OPENSSL_SHA256" ]; then
echo "openssl: wrong checksum"
echo "expected: $SHA256_OPENSSL"
echo "download: $DL_OPENSSL_SHA256"
exit 1
fi
if [ "$SHA256_ZLIB" != "$DL_ZLIB_SHA256" ]; then
echo "zlib: wrong checksum"
echo "expected: $SHA256_ZLIB"
echo "download: $DL_ZLIB_SHA256"
exit 1
fi
if [ "$SHA256_LIBSTROPHE" != "$DL_LIBSTROPHE_SHA256" ]; then
echo "libstrophe: wrong checksum"
echo "expected: $SHA256_LIBSTROPHE"
echo "download: $DL_LIBSTROPHE_SHA256"
exit 1
fi
if [ "$SHA256_LIBGPGERR" != "$DL_LIBGPGERR_SHA256" ]; then
echo "libgpg-err: wrong checksum"
echo "expected: $SHA256_LIBGPGERR"
echo "download: $DL_LIBGPGERR_SHA256"
exit 1
fi
if [ "$SHA256_LIBGCRYPT" != "$DL_LIBGCRYPT_SHA256" ]; then
echo "libgcrypt: wrong checksum"
echo "expected: $SHA256_LIBGCRYPT"
echo "download: $DL_LIBGCRYPT_SHA256"
exit 1
fi
if [ "$SHA256_LIBOTR" != "$DL_LIBOTR_SHA256" ]; then
echo "libotr: wrong checksum"
echo "expected: $SHA256_LIBOTR"
echo "download: $DL_LIBOTR_SHA256"
exit 1
fi
# build openssl
cd $DIR_OPENSSL
INSTALL_DIR="$PROJECT_ROOT/$DEPDIR/install"
./Configure --prefix=$INSTALL_DIR
if [ $? -ne 0 ]; then
echo "openssl configure failed"
exit 2
fi
make
if [ $? -ne 0 ]; then
echo "openssl make failed"
exit 2
fi
make install
if [ $? -ne 0 ]; then
echo "openssl make install failed"
exit 2
fi
cd ..
install_name_tool -id @rpath/libcrypto.3.dylib $INSTALL_DIR/lib/libcrypto.3.dylib
install_name_tool -id @rpath/libssl.3.dylib $INSTALL_DIR/lib/libssl.3.dylib
install_name_tool -change $INSTALL_DIR/lib/libcrypto.3.dylib @rpath/libcrypto.3.dylib $INSTALL_DIR/lib/libssl.3.dylib
# build zlib
export CFLAGS="$SAVED_CFLAGS -I$INSTALL_DIR/include"
export LDFLAGS="$SAVED_CFLAGS -L$INSTALL_DIR/lib"
export PATH=$PATH:$INSTALL_DIR/bin
export zlib_CFLAGS=$CFLAGS
export zlib_LIBS="$LDFLAGS -lz"
cd $DIR_ZLIB
./configure --prefix=$INSTALL_DIR
if [ -$? -ne 0 ]; then
echo "zlib configure failed"
exit 2
fi
make
if [ -$? -ne 0 ]; then
echo "zlib make failed"
exit 2
fi
make install
if [ -$? -ne 0]; then
echo "zlib make install failed"
exit 2
fi
cd ..
install_name_tool -id @rpath/libz.$ZLIB_VERSION.dylib $INSTALL_DIR/lib/libz.$ZLIB_VERSION.dylib
# build libstrophe
export CFLAGS="$SAVED_CFLAGS -I$INSTALL_DIR/include"
export LDFLAGS="$SAVED_LDFLAGS -L$INSTALL_DIR/lib"
export PATH=$PATH:$INSTALL_DIR/bin
cd $DIR_LIBSTROPHE
./configure --prefix=$INSTALL_DIR
if [ -$? -ne 0 ]; then
echo "libstrophe configure failed"
exit 2
fi
make
if [ -$? -ne 0 ]; then
echo "libstrophe make failed"
exit 2
fi
make install
if [ -$? -ne 0]; then
echo "libstrophe make install failed"
exit 2
fi
cd ..
install_name_tool -id @rpath/libstrophe.0.dylib $INSTALL_DIR/lib/libstrophe.0.dylib
# build libgpg-error
cd $DIR_LIBGPGERR
./configure --prefix=$INSTALL_DIR
if [ -$? -ne 0 ]; then
echo "libgpg-error configure failed"
exit 2
fi
make
if [ $? -ne 0 ]; then
echo "libgpg-error make failed"
exit 2
fi
make install
if [ -$? -ne 0 ]; then
echo "libgpg-error make install failed"
exit 2
fi
cd ..
install_name_tool -id @rpath/libgpg-error.0.dylib $INSTALL_DIR/lib/libgpg-error.0.dylib
# build libgcrypt
cd $DIR_LIBGCRYPT
./configure --prefix=$INSTALL_DIR --disable-asm
if [ -$? -ne 0 ]; then
echo "libgcrypt configure failed"
exit 2
fi
make
if [ $? -ne 0 ]; then
echo "libgcrypt make failed"
exit 2
fi
make install
if [ -$? -ne 0]; then
echo "libgcrypt make install failed"
exit 2
fi
cd ..
install_name_tool -id @rpath/libgcrypt.20.dylib $INSTALL_DIR/lib/libgcrypt.20.dylib
# build libotr
cat >> install/bin/libgcrypt-config << __EOF__
#!/bin/sh
INSTALL_DIR=$INSTALL_DIR
if [ \$1 = "--version" ]; then
echo "1.11.0"
exit
fi
if [ \$1 = "--cflags" ]; then
echo "-I\$INSTALL_DIR/include"
exit
fi
if [ \$1 = "--libs" ]; then
echo "-L\$INSTALL_DIR/lib -lgcrypt -lgpg-error"
exit
fi
__EOF__
chmod +x install/bin/libgcrypt-config
cd $DIR_LIBOTR
export CFLAGS="$SAVED_CFLAGS -I$INSTALL_DIR/include"
./configure --prefix=$INSTALL_DIR
if [ -$? -ne 0 ]; then
echo "libotr configure failed"
exit 2
fi
make
if [ $? -ne 0 ]; then
echo "libotr make failed"
exit 2
fi
make install
if [ -$? -ne 0 ]; then
echo "libotr make install failed"
exit 2
fi
cd ..
install_name_tool -id @rpath/libotr.5.dylib $INSTALL_DIR/lib/libotr.5.dylib