2
2
3
3
# # Prerequisites
4
4
# # The script supports builds from Linux and macOS.
5
- # # The 'patchelf' command is required for OpenSSL 3.
6
5
# # set BUILD_DIR and OUTPUT_ROOT variables to use custom build and output paths.
7
6
# # Set NDK_ROOT_PREFIX to use custom Android NDK root path that contains various
8
7
# # NDK versions.
@@ -94,8 +93,7 @@ configure_ssl() {
94
93
arch=$2
95
94
ndk=$3
96
95
build_type=$4
97
- output_dir=$5
98
- log_file=$6
96
+ log_file=$5
99
97
100
98
nkd_path=" $NDK_ROOT_PREFIX /$ndk "
101
99
@@ -116,12 +114,39 @@ configure_ssl() {
116
114
fi
117
115
done
118
116
119
- case $output_dir in
120
- ssl_1.1 )
117
+ case $ssl_version in
118
+ 1.1 * )
121
119
ANDROID_API=21
120
+ # use suffix _1_1.so with OpenSSL 1.1.x (up to Qt 6.4)
121
+ patch << EOF
122
+ --- Configurations/15-android.conf
123
+ +++ Configurations/15-android.conf
124
+ @@ -190,6 +190,8 @@
125
+ bn_ops => sub { android_ndk()->{bn_ops} },
126
+ bin_cflags => "-pie",
127
+ enable => [ ],
128
+ + shared_extension => ".so",
129
+ + shlib_variant => "_1_1",
130
+ },
131
+ "android-arm" => {
132
+ ################################################################
133
+ EOF
122
134
;;
123
- ssl_3 )
135
+ 3 * )
124
136
ANDROID_API=23
137
+ # use suffix _3.so with OpenSSL 3.1.x (Qt 6.5.0 and above)
138
+ patch << EOF
139
+ --- Configurations/15-android.conf
140
+ +++ Configurations/15-android.conf
141
+ @@ -192,6 +192,7 @@
142
+ bin_lflags => "-pie",
143
+ enable => [ ],
144
+ shared_extension => ".so",
145
+ + shlib_variant => "_3",
146
+ },
147
+ "android-arm" => {
148
+ ################################################################
149
+ EOF
125
150
;;
126
151
esac
127
152
@@ -134,55 +159,29 @@ configure_ssl() {
134
159
make depend
135
160
}
136
161
137
- build_ssl_1_1 () {
138
- # Qt up to 6.4 is using OpenSSL 1.1.x but the library is suffixed with _1_1.so
139
- output_dir=$1
140
- log_file=$2
141
-
142
- echo " Building..."
143
- make -j$( nproc) SHLIB_VERSION_NUMBER= SHLIB_EXT=_1_1.so build_libs 2>&1 1>> ${log_file} \
144
- | tee -a ${log_file} || exit 1
145
- }
146
-
147
- build_ssl_3 () {
148
- # Qt 6.5.0+ is using OpenSSL 3.1.x but the library is suffixed with _3.so
149
- output_dir=$1
150
- log_file=$2
162
+ build_ssl () {
163
+ log_file=$1
151
164
152
165
echo " Building..."
153
166
make -j$( nproc) SHLIB_VERSION_NUMBER= build_libs 2>&1 1>> ${log_file} \
154
167
| tee -a ${log_file} || exit 1
155
-
156
- mv libcrypto.so libcrypto_3.so
157
- mv libssl.so libssl_3.so
158
-
159
- # SHLIB_EXT is no longer supported for OpenSSL, so we need to manually
160
- # use patchelf to modify SONAME and NEEDED sections to set the correct
161
- # suffix for the shared libraries.
162
- # See https://github.com/openssl/openssl/issues/20854
163
- patchelf --set-soname libcrypto_3.so libcrypto_3.so || exit 1
164
- patchelf --set-soname libssl_3.so libssl_3.so || exit 1
165
- patchelf --replace-needed libcrypto.so libcrypto_3.so libssl_3.so || exit 1
166
168
}
167
169
168
170
strip_libs () {
169
- lib_suffix=$1
170
-
171
- llvm-strip --strip-all libcrypto_$lib_suffix .so
172
- llvm-strip --strip-all libssl_$lib_suffix .so
171
+ find . -name " libcrypto_*.so" -exec llvm-strip --strip-all {} \;
172
+ find . -name " libssl_*.so" -exec llvm-strip --strip-all {} \;
173
173
}
174
174
175
175
copy_build_artefacts () {
176
- lib_suffix=$1
177
- output_dir=$2
176
+ output_dir=$1
178
177
179
- cp libcrypto_$lib_suffix .so " $output_dir /libcrypto_ $lib_suffix .so " || exit 1
180
- cp libssl_$lib_suffix .so " $output_dir /libssl_ $lib_suffix .so " || exit 1
178
+ cp libcrypto_* .so " $output_dir /" || exit 1
179
+ cp libssl_* .so " $output_dir /" || exit 1
181
180
cp libcrypto.a libssl.a " $output_dir " || exit 1
182
181
183
182
# Create relative non-versioned symlinks
184
- ln -s " libcrypto_$lib_suffix .so" " $output_dir /libcrypto.so"
185
- ln -s " libssl_$lib_suffix .so" " $output_dir /libssl.so"
183
+ find . -name " libcrypto_* .so" -exec ln -s {} " $output_dir /libcrypto.so" \;
184
+ find . -name " libssl_* .so" -exec ln -s {} " $output_dir /libssl.so" \;
186
185
ln -s " ../include" " $output_dir /include"
187
186
}
188
187
@@ -211,8 +210,7 @@ for build_type in "${build_types[@]}"; do
211
210
pushd " openssl-$ssl_version -$arch " || exit 1
212
211
213
212
log_file=" build_${arch} _${ssl_version} .log"
214
- configure_ssl ${ssl_version} ${arch} " ${ndk} " " ${build_type} " \
215
- ${version_build_dir} ${log_file}
213
+ configure_ssl ${ssl_version} ${arch} " ${ndk} " " ${build_type} " ${log_file}
216
214
217
215
# Delete existing build artefacts
218
216
output_dir=" $OUTPUT_ROOT /$build_type /$version_build_dir /$qt_arch "
@@ -228,23 +226,9 @@ for build_type in "${build_types[@]}"; do
228
226
find " $output_dir /../" -name " *.def" -delete
229
227
fi
230
228
231
- case $version_build_dir in
232
- ssl_1.1)
233
- build_ssl_1_1 ${output_dir} ${log_file}
234
- suffix=" 1_1"
235
- ;;
236
- ssl_3)
237
- build_ssl_3 ${output_dir} ${log_file}
238
- suffix=" 3"
239
- ;;
240
- * )
241
- echo " Unhandled OpenSSL version $version_build_dir "
242
- exit 1
243
- ;;
244
- esac
245
-
246
- strip_libs " $suffix "
247
- copy_build_artefacts " $suffix " ${output_dir}
229
+ build_ssl ${log_file}
230
+ strip_libs
231
+ copy_build_artefacts ${output_dir}
248
232
249
233
250
234
popd
0 commit comments