scx/meson-scripts/build_libbpf
Jordan Rome 1769dece7d Remove libbpf as a submodule
Instead clone the libbpf repo at a specific hash during setup.
This is to fix an issue whereby submodules are not included
in the tarball and therefore won't be updated/fetched during
setup after unzipping the tarball.
2024-03-07 18:31:09 -08:00

28 lines
518 B
Bash
Executable File

#!/bin/bash
set -e
out=$("$1" 'map(select(.["file"] | contains ("cc_cflags_probe.c"))) | first | .["command"]' < compile_commands.json)
out=${out#\"}
out=${out%\"}
args=($out)
idx=0
cc=${args[idx]}
if [ "$cc" = "ccache" ]; then
idx=$((idx+1))
cc="$cc ${args[idx]}"
fi
declare -a cflags=()
for arg in ${args[@]:(idx+1)}; do
case $arg in
-I*|-M*|-o|-c) ;;
-*) cflags+="$arg ";;
esac
done
make_out=$(env CC="$cc" CFLAGS="$cflags" BUILD_STATIC_ONLY=y DESTDIR=. "$2" install -C "$3" -j"$4")
exit $?