summaryrefslogtreecommitdiff
path: root/deploy/cross-build.sh
blob: 75c181c6ab23975bb57c74512f0be8b34814dd6f (plain)
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
#!/bin/sh
# Cross-compile the static aarch64 binaries: bokfd, bokfctl and, for the
# web image, bokftui and bokfweb.
# Expects the source read-only at /src, writes the binaries to /out and takes
# the version from $VERSION. Run through deploy/Dockerfile.cross. OpenSSL and
# glibc are linked statically, so the Alpine runtime image needs no shared
# libraries (the kernel ABI is all that matters).
set -eu

# ncursesw needs its tinfo half spelled out for a static link
make -C /src -j"$(nproc)" BUILD=/tmp/build \
    backend /tmp/build/bokftui /tmp/build/bokfweb \
    CC=aarch64-linux-gnu-gcc \
    CFLAGS="-O2 -g -static -L/usr/lib/aarch64-linux-gnu" \
    SSL_LIBS="-l:libssl.a -l:libcrypto.a -l:libtinfo.a -ldl -lpthread" \
    VERSION="${VERSION:-0.1.0-dev}"

mkdir -p /out
cp /tmp/build/bokfd /tmp/build/bokfctl /tmp/build/bokftui \
   /tmp/build/bokfweb /out/

# A static glibc program loads its locale data from /usr/lib/locale, which
# the Alpine runtime does not have: without C.utf8 setlocale() fails and
# the TUI shows no åäö. Ship Debian's C.utf8 with the binaries.
mkdir -p /out/locale
cp -a /usr/lib/locale/C.utf8 /out/locale/