-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathprepare_osx_build_environment.sh
More file actions
executable file
·136 lines (131 loc) · 4.62 KB
/
prepare_osx_build_environment.sh
File metadata and controls
executable file
·136 lines (131 loc) · 4.62 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
#!/bin/sh
set -e
OPENSSL_DIR=openssl-3.5.5
XMLSEC_DIR=xmlsec1-1.3.9
ARGS="$@"
case "$@" in
*android*)
echo "vcpkg is used for managing android dependencies "
exit
;;
*simulator*)
echo "Building for iOS Simulator"
TARGET_PATH=/Library/libdigidocpp.iphonesimulator
SYSROOT=$(xcrun -sdk iphonesimulator --show-sdk-path)
: ${ARCHS:="arm64 x86_64"}
: ${IPHONEOS_DEPLOYMENT_TARGET:="15.0"}
export IPHONEOS_DEPLOYMENT_TARGET
export CFLAGS="-arch ${ARCHS// / -arch } -isysroot ${SYSROOT}"
;;
*iphonecatalyst*)
echo "Building for iOS macOS Catalyst"
TARGET_PATH=/Library/libdigidocpp.iphonecatalyst
SYSROOT=$(xcrun -sdk macosx --show-sdk-path)
: ${ARCHS:="arm64 x86_64"}
: ${IPHONEOS_DEPLOYMENT_TARGET:="15.0"}
export IPHONEOS_DEPLOYMENT_TARGET
export CFLAGS="-arch ${ARCHS// / -arch } -target x86_64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-macabi -isysroot ${SYSROOT}"
;;
*iphoneos*)
echo "Building for iOS"
TARGET_PATH=/Library/libdigidocpp.iphoneos
SYSROOT=$(xcrun -sdk iphoneos --show-sdk-path)
: ${ARCHS:="arm64"}
: ${IPHONEOS_DEPLOYMENT_TARGET:="15.0"}
export IPHONEOS_DEPLOYMENT_TARGET
export CFLAGS="-arch ${ARCHS// / -arch } -isysroot ${SYSROOT}"
;;
*)
echo "Building for macOS"
TARGET_PATH=/Library/libdigidocpp
SYSROOT=$(xcrun -sdk macosx --show-sdk-path)
: ${ARCHS:="arm64 x86_64"}
: ${MACOSX_DEPLOYMENT_TARGET:="13.0"}
export MACOSX_DEPLOYMENT_TARGET
export CFLAGS="-arch ${ARCHS// / -arch } "
;;
esac
function xmlsec {
echo Building ${XMLSEC_DIR}
if [ ! -f ${XMLSEC_DIR}.tar.gz ]; then
XMLSEC_VERSION="${XMLSEC_DIR##*-}"
curl -O -L https://github.com/lsh123/xmlsec/releases/download/${XMLSEC_VERSION}/${XMLSEC_DIR}.tar.gz
fi
rm -rf ${XMLSEC_DIR}
tar xf ${XMLSEC_DIR}.tar.gz
cd ${XMLSEC_DIR}
patch -Np1 -i ../xmlsec1-1.3.5.legacy.patch
case "${ARGS}" in
*iphone*) CONFIGURE="--host=aarch64-apple-darwin --enable-static --disable-shared --without-libxslt" ;;
*) CONFIGURE="--disable-static --enable-shared" ;;
esac
./configure --prefix=${TARGET_PATH} ${CONFIGURE} \
--disable-dependency-tracking \
--disable-crypto-dl \
--disable-apps-crypto-dl \
--without-gnutls \
--without-gcrypt \
--without-nss \
--with-openssl=${TARGET_PATH} \
--disable-apps \
--disable-docs \
--disable-mans
make -s
sudo make install
cd -
}
function openssl {
echo Building ${OPENSSL_DIR}
if [ ! -f ${OPENSSL_DIR}.tar.gz ]; then
curl -O -L https://www.openssl.org/source/${OPENSSL_DIR}.tar.gz
fi
rm -rf ${OPENSSL_DIR}
tar xf ${OPENSSL_DIR}.tar.gz
pushd ${OPENSSL_DIR}
for ARCH in ${ARCHS}
do
case "${ARGS}" in
*simulator*) CC="" CFLAGS="" ./Configure iossimulator-${ARCH}-xcrun --prefix=${TARGET_PATH} no-apps no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;;
*catalyst*) CC="" CFLAGS="-target ${ARCH}-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-macabi" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} no-apps no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;;
*iphone*) CC="" CFLAGS="" ./Configure ios64-xcrun --prefix=${TARGET_PATH} no-apps no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;;
*) CC="" CFLAGS="" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} no-apps shared no-module no-tests enable-ec_nistp_64_gcc_128
esac
make -s > /dev/null
if [[ ${ARCHS} == ${ARCH}* ]]; then
sudo make install_sw > /dev/null
else
make install_sw DESTDIR=${PWD}/${ARCH} > /dev/null
mkdir -p universal/${TARGET_PATH}/lib
pushd ${ARCH}
for i in $(find ./${TARGET_PATH}/lib -type f -depth 1); do
lipo -create /$i $i -output ../universal/$i
done
popd
sudo mv universal/${TARGET_PATH}/lib/* ${TARGET_PATH}/lib/
fi
make distclean
done
popd
}
case "$@" in
*xmlsec*) xmlsec ;;
*openssl*) openssl ;;
*all*)
openssl
xmlsec
;;
*)
echo "Usage:"
echo " $0 [target] [task]"
echo " target: macos iphoneos iphonesimulator iphonecatalyst"
echo " tasks: openssl, xmlsec, all, help"
echo "To control builds set environment variables:"
echo " minimum deployment target"
echo " - MACOSX_DEPLOYMENT_TARGET=13.0"
echo " - IPHONEOS_DEPLOYMENT_TARGET=15.0"
echo " archs to build on macOS/iOS"
echo " - ARCHS=\"arm64 x86_64\" (macOS)"
echo " - ARCHS=\"arm64\" (iOS)"
echo " - ARCHS=\"arm64 x86_64\" (iPhoneSimulator)"
;;
esac