This repository was archived by the owner on Mar 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_otp.sh
More file actions
executable file
·104 lines (80 loc) · 2.62 KB
/
build_otp.sh
File metadata and controls
executable file
·104 lines (80 loc) · 2.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
#!/bin/bash
##########
## Initial Prep
set -e
version=$1
if [ -z "${version}" ]; then
echo "usage: build_otp OTP_VERSION"
exit 1
fi
mkdir -p $TMPDIR
##########
## OpenSSL
OpenSSL_VERSION="1.1.1i"
OpenSSL_DIR="$HOME/openssl_prefix"
mkdir -p $OpenSSL_DIR
echo "building OpenSSL $OpenSSL_VERSION"
curl https://www.openssl.org/source/openssl-$OpenSSL_VERSION.tar.gz -O
tar -xzf openssl-$OpenSSL_VERSION.tar.gz
cd openssl-$OpenSSL_VERSION
if [[ $APPLE_SILICON == 1 ]]
then
CC="clang -target arm64-apple-macos11" ./Configure darwin64-arm64-cc no-shared --prefix="$OpenSSL_DIR" && make depend && make -j && make install
else
./config no-shared --prefix="$OpenSSL_DIR" && make depend && make && make install
fi
##########
## OTP
echo "building OTP ${version}"
OTP_BUILD_FLAGS="--disable-parallel-configure --without-jinterface --without-hipe --disable-dynamic-ssl-lib --with-ssl=$OpenSSL_DIR"
# Workaround for drawin compiler flags on some builds of OTP
if [[ $(uname -s) == Darwin ]]
then
echo "Setting MacOS workaround variables..."
export EGREP=egrep
export CC=clang
export CPP="clang -E"
fi
TMPDIR="${TMPDIR:=tmp}/beamup"
mkdir -p $TMPDIR
echo "cd $TMPDIR"
cd $TMPDIR
export arch="$(uname -sm | tr '[:upper:]' '[:lower:]' | tr ' ' '-')"
if [ ! -f otp_src_${version}.tar.gz ]; then
url=https://github.com/erlang/otp/releases/download/OTP-${version}/otp_src_${version}.tar.gz
echo "downloading $url" 1>&2
curl --fail -LO $url 1>&2
fi
if [ ! -d otp_src_${version} ]; then
mkdir -p otp_src_${version}
tar xzf otp_src_${version}.tar.gz -C otp_src_${version} --strip-components 1
cd otp_src_${version}
export ERL_TOP=$PWD
# Add target flag and xcomp flags if we are building for Apple Silicon
if [[ $APPLE_SILICON == 1 ]]
then
# we need a bootstrap an install first on our native platform
echo "We are cross compiling for Apple Silicon, bootstrapping!"
./configure --enable-bootstrap-only
make -j
# set cross comp flags and compiler target flags
export CC="$CC -target arm64-apple-macos11"
export CXX="$clang++ -target arm64-apple-macos11"
export OTP_BUILD_FLAGS="$OTP_BUILD_FLAGS --host=aarch64-apple-darwin --build=x86_64-apple-darwin"
export arch="darwin-arm64"
export erl_xcomp_sysroot="$OpenSSL_DIR"
fi
# do the real OTP build
./otp_build setup -a $OTP_BUILD_FLAGS 1>&2
cd ..
fi
##########
## Release archive
cd otp_src_${version}
export ERL_TOP=$PWD
release=$(echo otp-${version}-$arch)
export RELEASE_ROOT=$TMPDIR/${release}
make release -j$(getconf _NPROCESSORS_ONLN) 1>&2
cd $TMPDIR
echo "creating ${TMPDIR}/${release}.tar.gz"
tar czf ${release}.tar.gz ${release}