-
Notifications
You must be signed in to change notification settings - Fork 14
/
bootstrap
executable file
·76 lines (69 loc) · 3.17 KB
/
bootstrap
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
#!/bin/bash
BUILDPATH=${PWD}/build
PREFIX=/
export MACOSX_DEPLOYMENT_TARGET="10.13"
RESOURCES=/Applications/Utilities/OpenSCTokenApp.app/Contents/PlugIns/OpenSCToken.appex/Contents/Resources
xcode_ver=$(xcodebuild -version | sed -En 's/Xcode[[:space:]](.*)/\1/p')
base_ver="12.2"
if [ $(echo -e $base_ver"\n"$xcode_ver | sort -V | head -1) == "$base_ver" ]; then
export BUILD_ARM="true"
fi
set -ex
if [ -z "$OPENSSL_CFLAGS" -a -z "$OPENSSL_LIBS" ] ; then
if ! test -e $BUILDPATH/openssl/$PREFIX/lib/pkgconfig; then
# Build OpenSSL manually, because Apple's binaries are deprecated
if ! test -e openssl; then
git clone --depth=1 https://github.com/openssl/openssl.git -b OpenSSL_1_1_1-stable
fi
cd openssl
MACHINE=x86_64 ./config no-shared --prefix=$PREFIX
make clean
make -j 4
make DESTDIR=$BUILDPATH/openssl install_sw
if test -n "${BUILD_ARM}"; then
make clean
MACHINE=arm64 KERNEL_BITS=64 ./config no-shared --prefix=$PREFIX
make -j 4
make DESTDIR=$BUILDPATH/openssl_arm64 install_sw
lipo -create $BUILDPATH/openssl_arm64/$PREFIX/lib/libcrypto.a $BUILDPATH/openssl/$PREFIX/lib/libcrypto.a -output libcrypto.a
lipo -create $BUILDPATH/openssl_arm64/$PREFIX/lib/libssl.a $BUILDPATH/openssl/$PREFIX/lib/libssl.a -output libssl.a
mv libcrypto.a $BUILDPATH/openssl/$PREFIX/lib/libcrypto.a
mv libssl.a $BUILDPATH/openssl/$PREFIX/lib/libssl.a
fi
cd ..
fi
export OPENSSL_CFLAGS="`env PKG_CONFIG_PATH=$BUILDPATH/openssl/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openssl pkg-config --static --cflags libcrypto`"
export OPENSSL_LIBS="` env PKG_CONFIG_PATH=$BUILDPATH/openssl/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openssl pkg-config --static --libs libcrypto`"
fi
if test -n "${BUILD_ARM}"; then
export CFLAGS="$CFLAGS -arch x86_64 -arch arm64"
export LDFLAGS="$LDFLAGS -arch x86_64 -arch arm64"
export OBJCFLAGS=$CFLAGS
fi
if [ -z "$OPENPACE_CFLAGS" -a -z "$OPENPACE_LIBS" ] ; then
if ! test -e $BUILDPATH/openpace/$PREFIX/lib/pkgconfig; then
if ! test -e openpace; then
git clone --depth=1 https://github.com/frankmorgner/openpace.git -b 1.1.3
fi
cd openpace
if ! test -e configure; then
autoreconf -vis
fi
./configure --disable-shared --prefix=$PREFIX --sysconfdir=$RESOURCES --enable-cvcdir=$RESOURCES --enable-x509dir=$RESOURCES CRYPTO_CFLAGS="$OPENSSL_CFLAGS" CRYPTO_LIBS="$OPENSSL_LIBS" HELP2MAN=/usr/bin/true
touch src/cvc-create.1 src/cvc-print.1
make DESTDIR=$BUILDPATH/openpace install
cd ..
fi
export OPENPACE_CFLAGS="`env PKG_CONFIG_PATH=$BUILDPATH/openssl/$PREFIX/lib/pkgconfig:$BUILDPATH/openpace/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openpace pkg-config --static --cflags libeac` $OPENSSL_CFLAGS"
export OPENPACE_LIBS="` env PKG_CONFIG_PATH=$BUILDPATH/openssl/$PREFIX/lib/pkgconfig:$BUILDPATH/openpace/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openpace pkg-config --static --libs libeac` $OPENSSL_LIBS"
fi
if ! test -e OpenSC; then
git clone --depth=1 https://github.com/OpenSC/OpenSC.git
fi
cd OpenSC
if ! test -e configure; then
autoreconf -vis
fi
./configure --disable-shared --prefix=$PREFIX --sysconfdir=$RESOURCES --disable-pcsc --enable-cryptotokenkit
make
cd ..