blob: 00e80453aa7b579281ab562259849ae6034678a9 (
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
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
|
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -ne 3 ]; then
echo "Usage: build-hamlib-armhf-cross.sh COMMIT SYSROOT TOOLCHAIN_PREFIX" >&2
exit 2
fi
commit=$1
sysroot=$2
toolchain_prefix=$3
triplet=arm-linux-gnueabihf
target_include="$sysroot/usr/include/$triplet"
target_lib="$sysroot/usr/lib/$triplet"
target_base_lib="$sysroot/lib/$triplet"
export PATH="$toolchain_prefix/bin:$PATH"
export PKG_CONFIG_SYSROOT_DIR="$sysroot"
export PKG_CONFIG_PATH=
export PKG_CONFIG_LIBDIR="$target_lib/pkgconfig:$sysroot/usr/share/pkgconfig"
git init hamlib-src
git -C hamlib-src remote add origin https://github.com/Hamlib/Hamlib.git
git -C hamlib-src fetch --depth 1 origin "$commit"
git -C hamlib-src checkout --detach FETCH_HEAD
actual_commit="$(git -C hamlib-src rev-parse HEAD)"
if [ "$actual_commit" != "$commit" ]; then
echo "Hamlib source mismatch: expected $commit, got $actual_commit" >&2
exit 1
fi
cd hamlib-src
./bootstrap
./configure \
--build=x86_64-pc-linux-gnu \
--host="$triplet" \
--prefix=/usr \
--disable-shared --enable-static \
--without-cxx-binding \
--without-readline \
--without-indi \
CC="${triplet}-gcc" \
CXX="${triplet}-g++" \
AR="${triplet}-ar" \
NM="${triplet}-nm" \
OBJDUMP="${triplet}-objdump" \
RANLIB="${triplet}-ranlib" \
STRIP="${triplet}-strip" \
CFLAGS="--sysroot=$sysroot -isystem $target_include -g -O2 -fPIC -fdata-sections -ffunction-sections" \
CXXFLAGS="--sysroot=$sysroot -isystem $target_include -g -O2 -fPIC -fdata-sections -ffunction-sections" \
LDFLAGS="--sysroot=$sysroot -B$target_lib/ -L$target_lib -Wl,-rpath-link,$target_lib -Wl,-rpath-link,$target_base_lib -Wl,--gc-sections"
make -j"$(nproc)"
make DESTDIR="$sysroot" install
for utility in rigctl rigctld rigctlcom; do
metadata="$(file "$sysroot/usr/bin/$utility")"
case "$metadata" in
*"ELF 32-bit"*"ARM, EABI5"*) ;;
*)
echo "Cross-built Hamlib utility has the wrong architecture: $metadata" >&2
exit 1
;;
esac
done
test -f "$sysroot/usr/lib/libhamlib.a"
|