diff options
author | Joshua Lant <joshualant@googlemail.com> | 2024-08-28 13:47:31 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2024-08-29 14:07:35 +0200 |
commit | 76fce22826f8e860b5eb5b5a2463040c17ff85da (patch) | |
tree | 4d6418471f7ea1dc89980372c0114062e1b37fa7 /configure.ac | |
parent | e1496f52699b11569a09603765caeca8a4aed93f (diff) |
configure: Determine if musl is used for build
Error compiling with musl-libc:
The commit hash 810f8568f44f5863c2350a39f4f5c8d60f762958
introduces the netinet/ether.h header into xtables.h, which causes an error due
to the redefinition of the ethhdr struct, defined in linux/if_ether.h and
netinet/ether.h. This is fixed by the inclusion of -D__UAPI_DEF_ETHHDR=0 in
CFLAGS for musl. Automatically check for this macro, since it is defined
in musl but not in glibc.
Signed-off-by: Joshua Lant joshualant@gmail.com
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 2293702b..a19a60c0 100644 --- a/configure.ac +++ b/configure.ac @@ -206,6 +206,25 @@ if test "x$enable_profiling" = "xyes"; then regular_LDFLAGS+=" -lgcov --coverage" fi +AC_MSG_CHECKING([whether the build is using musl-libc]) +enable_musl_build="" + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include <netinet/if_ether.h>]], + [[ + #if ! defined(__UAPI_DEF_ETHHDR) || __UAPI_DEF_ETHHDR != 0 + #error error trying musl... + #endif + ]] + )], + [enable_musl_build="yes"],[enable_musl_build="no"] +) +AC_MSG_RESULT([${enable_musl_build}]) + +if test "x$enable_musl_build" = "xyes"; then + regular_CFLAGS+=" -D__UAPI_DEF_ETHHDR=0" +fi + define([EXPAND_VARIABLE], [$2=[$]$1 if test $prefix = 'NONE'; then @@ -277,7 +296,8 @@ Build parameters: Installation prefix (--prefix): ${prefix} Xtables extension directory: ${e_xtlibdir} Pkg-config directory: ${e_pkgconfigdir} - Xtables lock file: ${xt_lock_name}" + Xtables lock file: ${xt_lock_name} + Build against musl-libc: ${enable_musl_build}" if [[ -n "$ksourcedir" ]]; then echo " Kernel source directory: ${ksourcedir}" |