forked from iCepa/Tor.framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenssl.sh
executable file
·78 lines (67 loc) · 2.99 KB
/
openssl.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
#!/bin/bash
ARCHS=($ARCHS)
REBUILD=0
# If the built binary includes a different set of architectures, then rebuild the target
if [[ ${ACTION:-build} = "build" ]]; then
for ARCH in "${ARCHS[@]}"
do
if [[ $(lipo -info "${BUILT_PRODUCTS_DIR}/libssl.a" 2>&1) != *"${ARCH}"* ]]; then
REBUILD=1;
elif [[ $(lipo -info "${BUILT_PRODUCTS_DIR}/libcrypto.a" 2>&1) != *"${ARCH}"* ]]; then
REBUILD=1;
fi
done
fi
# If rebuilding or cleaning then delete the built products
if [[ $ACTION = "clean" ]] || [[ $REBUILD = 1 ]]; then
make distclean 2>/dev/null
rm -r "${BUILT_PRODUCTS_DIR}/openssl-"* 2>/dev/null
rm "${BUILT_PRODUCTS_DIR}/libssl.a" 2>/dev/null
rm "${BUILT_PRODUCTS_DIR}/libcrypto.a" 2>/dev/null
fi
if [[ $REBUILD = 0 ]]; then
exit;
fi
if [[ "${BITCODE_GENERATION_MODE}" = "bitcode" ]]; then
BITCODE_FLAGS="-fembed-bitcode"
elif [[ "${BITCODE_GENERATION_MODE}" = "marker" ]]; then
BITCODE_FLAGS="-fembed-bitcode-marker"
fi
# Build each architecture one by one using clang
for ARCH in "${ARCHS[@]}"
do
SDK_COMPONENTS=($(echo ${SDKROOT} | sed -e 's/\/SDKs\//\'$'\n/'))
export CROSS_TOP="${SDK_COMPONENTS[0]}"
export CROSS_SDK="${SDK_COMPONENTS[1]}"
export CC="$(xcrun -f --sdk ${PLATFORM_NAME} clang) -arch ${ARCH} ${BITCODE_FLAGS}"
if [[ "${ARCH}" == "i386" ]]; then
./Configure no-shared no-asm --prefix="${CONFIGURATION_TEMP_DIR}/openssl-${ARCH}" darwin-i386-cc
elif [[ "${ARCH}" == "x86_64" ]]; then
./Configure no-shared no-asm enable-ec_nistp_64_gcc_128 --prefix="${CONFIGURATION_TEMP_DIR}/openssl-${ARCH}" darwin64-x86_64-cc
elif [[ "${ARCH}" == "arm64" ]]; then
./Configure no-shared no-async zlib-dynamic enable-ec_nistp_64_gcc_128 --prefix="${CONFIGURATION_TEMP_DIR}/openssl-${ARCH}" ios64-cross
else
./Configure no-shared no-async zlib-dynamic --prefix="${CONFIGURATION_TEMP_DIR}/openssl-${ARCH}" ios-cross
fi
make depend
make -j$(sysctl hw.ncpu | awk '{print $2}') build_libs
make install_dev
make distclean
done
mkdir -p "${BUILT_PRODUCTS_DIR}"
# Copy the build products from the temporary directory to the built products directory
for ARCH in "${ARCHS[@]}"
do
mkdir -p "${BUILT_PRODUCTS_DIR}/openssl-${ARCH}/openssl"
cp "${CONFIGURATION_TEMP_DIR}/openssl-${ARCH}/include/openssl/opensslconf.h" "${BUILT_PRODUCTS_DIR}/openssl-${ARCH}/openssl"
for LIBRARY in "${CONFIGURATION_TEMP_DIR}/openssl-${ARCH}/lib/"*.a;
do
cp $LIBRARY "${BUILT_PRODUCTS_DIR}/$(basename ${LIBRARY} .a).${ARCH}.a"
done
done
cp -rf "${BUILT_PRODUCTS_DIR}/openssl-${ARCHS[0]}" "${BUILT_PRODUCTS_DIR}/openssl"
# Combine the built products into a fat binary
xcrun --sdk $PLATFORM_NAME lipo -create "${BUILT_PRODUCTS_DIR}/libssl."*.a -output "${BUILT_PRODUCTS_DIR}/libssl.a"
xcrun --sdk $PLATFORM_NAME lipo -create "${BUILT_PRODUCTS_DIR}/libcrypto."*.a -output "${BUILT_PRODUCTS_DIR}/libcrypto.a"
rm "${BUILT_PRODUCTS_DIR}/libssl."*.a
rm "${BUILT_PRODUCTS_DIR}/libcrypto."*.a