-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathbuild_darwin_arm64.sh
More file actions
executable file
·110 lines (100 loc) · 3.03 KB
/
build_darwin_arm64.sh
File metadata and controls
executable file
·110 lines (100 loc) · 3.03 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
#!/bin/sh -eu
BUILD_CPU=arm64
BUILD_HOST=arm-apple-darwin
echo "running build_darwin_$BUILD_CPU.sh..."
SDK_PATH=$(xcrun --show-sdk-path)
XCODE_LIB="$SDK_PATH/usr/lib/"
XCODE_INCLUDE="$SDK_PATH/usr/include/"
if [ $# -eq 1 ]; then
re='^[0-9]+$'
if ! echo "$1" | grep -Eq "$re" ; then
echo "Invalid number of cores" >&2; exit 1
fi
jobs=$1
else
jobs=$(sysctl -n hw.logicalcpu_max)
fi
rm -rf $BUILD_CPU && mkdir $BUILD_CPU
tar -xvzf "zlib-$ZLIB_VERSION.tar.gz" -C $BUILD_CPU
cd "$BUILD_CPU/zlib-$ZLIB_VERSION"
CFLAGS="-target $BUILD_CPU-apple-macos11" LDFLAGS="-target $BUILD_CPU-apple-macos11" ./configure --prefix="$PWD/root"
make ${jobs:+-j${jobs}} && make ${jobs:+-j${jobs}} check && make install
cd ../../
tar -xvzf "openssl-$OPENSSL_VERSION.tar.gz" -C $BUILD_CPU
cd "$BUILD_CPU/openssl-$OPENSSL_VERSION"
./Configure --prefix="$PWD/root" \
darwin64-$BUILD_CPU-cc \
no-apps \
no-cmp \
no-cms \
no-comp \
no-ct \
no-dgram \
no-docs \
no-dso \
no-ec2m \
no-engine \
no-http \
no-legacy \
no-module \
no-nextprotoneg \
no-ocsp \
no-padlockeng \
no-psk \
no-quic \
no-rfc3779 \
no-shared \
no-srp \
no-srtp \
no-ssl-trace \
no-static-engine \
no-ts \
no-ui-console \
no-uplink
make ${jobs:+-j${jobs}} && make test && make install
cd ../../
#Apple messed up getentropy and clock_gettimesymbols when they added two functions in Sierra:
#they forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION checks.
#So we have to explicitly disable them for binaries to work on MacOS 10.11.
tar -zxvf "libevent-$LIBEVENT_VERSION.tar.gz" -C $BUILD_CPU
cd "$BUILD_CPU/libevent-$LIBEVENT_VERSION"
patch -p0 < ../../patch/libevent/regress.c.patch
patch -p0 < ../../patch/libevent/regress_http.c.patch
./configure \
LDFLAGS="-L$PWD/../openssl-$OPENSSL_VERSION/root/lib --target=$BUILD_CPU-apple-macos11" \
CPPFLAGS="-I$PWD/../openssl-$OPENSSL_VERSION/include --target=$BUILD_CPU-apple-macos11" \
--prefix="$PWD/install" \
--disable-openssl \
--disable-shared \
--enable-static \
--host=$BUILD_HOST \
--disable-clock-gettime \
--with-pic
make ${jobs:+-j${jobs}} && make ${jobs:+-j${jobs}} check && make install
cd ../../
tar -xvzf "tor-$TOR_VERSION.tar.gz" -C $BUILD_CPU
cd "$BUILD_CPU/tor-$TOR_VERSION"
patch -p0 < ../../patch/tor/test_slow.c.patch
./configure \
LDFLAGS="--target=$BUILD_CPU-apple-macos11 -L$XCODE_LIB" \
CPPFLAGS="--target=$BUILD_CPU-apple-macos11 -I$XCODE_INCLUDE" \
--prefix="$PWD/root" \
--enable-static-libevent \
--enable-static-openssl \
--enable-static-zlib \
--with-libevent-dir="$PWD/../libevent-$LIBEVENT_VERSION/install" \
--with-openssl-dir="$PWD/../openssl-$OPENSSL_VERSION/root" \
--with-zlib-dir="$PWD/../zlib-$ZLIB_VERSION/root" \
--disable-asciidoc \
--disable-html-manual \
--disable-lzma \
--disable-manpage \
--disable-zstd \
--disable-module-relay \
--disable-module-dirauth \
--host=$BUILD_HOST \
--disable-tool-name-check \
ac_cv_func_getentropy=no \
ac_cv_func_clock_gettime=no
make ${jobs:+-j${jobs}} && make install
cd ../../