summaryrefslogtreecommitdiff
path: root/.github/scripts/build-hamlib-linux.sh
blob: 11676c569b8da7e78a709823989e17e33e2bab69 (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
#!/usr/bin/env bash
set -euo pipefail

if [ "$#" -ne 2 ]; then
  echo "Usage: build-hamlib-linux.sh REF PREFIX" >&2
  exit 2
fi

ref="$1"
prefix="$2"

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 "$ref"
git -C hamlib-src checkout --detach FETCH_HEAD
actual_commit="$(git -C hamlib-src rev-parse HEAD)"
if [[ "$ref" =~ ^[0-9a-f]{40}$ ]] && [ "$actual_commit" != "$ref" ]; then
  echo "Hamlib source mismatch: expected $ref, got $actual_commit" >&2
  exit 1
fi
cd hamlib-src
./bootstrap
./configure \
  --prefix="$prefix" \
  --disable-shared --enable-static \
  --without-cxx-binding \
  --without-readline \
  --without-indi \
  CFLAGS="-g -O2 -fPIC -fdata-sections -ffunction-sections" \
  LDFLAGS="-Wl,--gc-sections"
make -j"$(nproc)"
make install