Skip to content

Commit

Permalink
Merge pull request #508 from sternenseemann/build-system
Browse files Browse the repository at this point in the history
configure.sh: make pkg-config and ar used for host configurable
  • Loading branch information
dinosaure authored Feb 28, 2024
2 parents cc80d3a + a5c727c commit 06682ae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ HOSTCFLAGS := -fstack-protector-strong -Wall -Werror -std=c11 -O2 -g
HOSTCPPFLAGS := -I$(TOPDIR)/include
HOSTLDFLAGS :=
HOSTLDLIBS :=
HOSTAR := ar
HOSTAR := $(CONFIG_HOST_AR)

define HOSTCOMPILE.c
@echo "HOSTCC $@"
Expand Down
27 changes: 19 additions & 8 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ Options:
Environment variables affecting the build system configuration:
HOST_CC
C compiler used for host tools and tenders.
HOST_AR
C compiler and ar tool used for host tools and tenders.
HOST_PKG_CONFIG
pkg-config executable to query for information on libraries needed to
build host tools and tenders.
TARGET_CC
TARGET_LD
Expand Down Expand Up @@ -247,6 +252,8 @@ done
#
# Configure host tools and tenders based on HOST_CC.
#
HOST_AR=${HOST_AR:-ar}

HOST_CC=${HOST_CC:-cc}
HOST_CC_MACHINE=$(${HOST_CC} -dumpmachine)
[ $? -ne 0 ] &&
Expand Down Expand Up @@ -281,6 +288,8 @@ case ${HOST_CC_MACHINE} in
;;
esac

HOST_PKG_CONFIG=${HOST_PKG_CONFIG:-pkg-config}

CONFIG_SPT_TENDER_NO_PIE=
CONFIG_SPT_TENDER_LIBSECCOMP_CFLAGS=
CONFIG_SPT_TENDER_LIBSECCOMP_LDFLAGS=
Expand All @@ -295,24 +304,24 @@ if [ -n "${CONFIG_SPT_TENDER}" ]; then
CONFIG_SPT_TENDER_NO_PIE=1
fi

if ! command -v pkg-config >/dev/null; then
die "pkg-config is required"
if ! command -v $HOST_PKG_CONFIG >/dev/null; then
die "pkg-config is required: $HOST_PKG_CONFIG not in PATH"
fi
if ! pkg-config libseccomp; then
if ! $HOST_PKG_CONFIG libseccomp; then
die "libseccomp development headers are required"
else
if ! pkg-config --atleast-version=2.3.3 libseccomp; then
if ! $HOST_PKG_CONFIG --atleast-version=2.3.3 libseccomp; then
# TODO Make this a hard error once there are no distros with
# libseccomp < 2.3.3 in the various CIs.
warn "libseccomp >= 2.3.3 is required" \
"for correct spt tender operation"
warn "Proceeding anyway, expect tests to fail"
elif ! pkg-config --atleast-version=2.4.1 libseccomp; then
elif ! $HOST_PKG_CONFIG --atleast-version=2.4.1 libseccomp; then
warn "libseccomp < 2.4.1 has known vulnerabilities"
warn "Proceeding anyway, but consider upgrading"
fi
CONFIG_SPT_TENDER_LIBSECCOMP_CFLAGS="$(pkg-config --cflags libseccomp)"
CONFIG_SPT_TENDER_LIBSECCOMP_LDLIBS="$(pkg-config --libs libseccomp)"
CONFIG_SPT_TENDER_LIBSECCOMP_CFLAGS="$($HOST_PKG_CONFIG --cflags libseccomp)"
CONFIG_SPT_TENDER_LIBSECCOMP_LDLIBS="$($HOST_PKG_CONFIG --libs libseccomp)"
fi
if ! CC="${HOST_CC}" PKG_CFLAGS="${CONFIG_SPT_TENDER_LIBSECCOMP_CFLAGS}" \
cc_check_header seccomp.h; then
Expand Down Expand Up @@ -342,6 +351,7 @@ CONFIG_DISABLE_TOOLCHAIN=1
CONFIG_HOST_ARCH=${CONFIG_HOST_ARCH}
CONFIG_HOST=${CONFIG_HOST}
CONFIG_HOST_CC=${HOST_CC}
CONFIG_HOST_AR=${HOST_AR}
CONFIG_HVT_TENDER_ENABLE_CAPSICUM=${CONFIG_HVT_TENDER_ENABLE_CAPSICUM}
CONFIG_HVT_TENDER=${CONFIG_HVT_TENDER}
CONFIG_SPT_TENDER=${CONFIG_SPT_TENDER}
Expand Down Expand Up @@ -520,6 +530,7 @@ CONFIG_PREFIX=${OPT_PREFIX}
CONFIG_HOST_ARCH=${CONFIG_HOST_ARCH}
CONFIG_HOST=${CONFIG_HOST}
CONFIG_HOST_CC=${HOST_CC}
CONFIG_HOST_AR=${HOST_AR}
CONFIG_HVT=${CONFIG_HVT}
CONFIG_HVT_TENDER_ENABLE_CAPSICUM=${CONFIG_HVT_TENDER_ENABLE_CAPSICUM}
CONFIG_HVT_TENDER=${CONFIG_HVT_TENDER}
Expand Down

0 comments on commit 06682ae

Please sign in to comment.