-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
75 lines (63 loc) · 2.18 KB
/
build.sh
File metadata and controls
75 lines (63 loc) · 2.18 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
#!/bin/sh
set -xe
OTP_DOWNLOAD_URL="https://github.com/erlang/otp/releases/download/OTP-${OTP_VERSION}/otp_src_${OTP_VERSION}.tar.gz"
REBAR3_DOWNLOAD_URL="https://github.com/erlang/rebar3/archive/${REBAR3_VERSION}.tar.gz"
export ERL_TOP=/usr/src/otp_src
export BUILD_TOP="$(pwd)"
apk add --no-cache --virtual .fetch-deps \
curl \
ca-certificates
curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL"
apk add --no-cache --virtual .build-deps \
perl \
clang \
libc-dev \
linux-headers \
make \
ncurses-dev \
ncurses-static \
openssl-dev \
openssl-libs-static \
tar
mkdir -vp $ERL_TOP
tar xzf otp-src.tar.gz -C $ERL_TOP --strip-components=1
rm otp-src.tar.gz
( cd $ERL_TOP \
&& ./configure \
CC=clang \
CXX=clang \
LIBS="-lncursesw -ltinfo -lcrypto -lssl -lstdc++" \
CFLAGS="-Os" \
LDFLAGS="-static -static-libgcc -static-libstdc++" \
--enable-jit \
--disable-pie \
--with-termcap \
--without-javac \
--enable-builtin-zlib \
--disable-dynamic-ssl-lib \
--with-ssl \
--enable-static-nifs \
--enable-static-drivers \
--without-wx \
--without-debugger \
--without-observer \
--without-docs \
--without-odbc \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install )
rm -fr $ERL_TOP
find /usr/local -regex '/usr/local/lib/erlang/\(lib/\|erts-\).*/\(man\|doc\|obj\|c_src\|emacs\|info\|examples\|priv/lib\)' | xargs rm -fr
find /usr/local -name src | xargs -r find | grep -v '\.hrl$' | xargs rm -v || true
find /usr/local -name src | xargs -r find | xargs rmdir -vp || true
scanelf --nobanner -E ET_EXEC -BF '%F' --recursive /usr/local | xargs -r strip --strip-all
scanelf --nobanner -E ET_DYN -BF '%F' --recursive /usr/local | xargs -r strip --strip-unneeded
curl -fSL -o rebar3-src.tar.gz "$REBAR3_DOWNLOAD_URL"
mkdir -p /usr/src/rebar3-src
tar -xzf rebar3-src.tar.gz -C /usr/src/rebar3-src --strip-components=1
rm rebar3-src.tar.gz
cd /usr/src/rebar3-src
HOME=$PWD ./bootstrap
install -v ./rebar3 /usr/local/lib/erlang/bin/
rm -rf /usr/src/rebar3-src
apk list -I > /usr/local/lib/erlang/versions.txt
apk del .fetch-deps .build-deps