Commit fdfea29f6d3866ca60b11f268874e0a7770f3e10

Thomas de Grivel 2022-12-08T15:38:04

fix compilation on Linux

diff --git a/c3s/configure b/c3s/configure
index 2d962c2..a732f39 100755
--- a/c3s/configure
+++ b/c3s/configure
@@ -46,6 +46,7 @@ LIBS="${LIBS:=-lm}"
 # Common config for all targets
 CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
 config_asan
+config_gnu
 pkg_config libbsd-overlay
 pkg_config libffi
 pkg_config libmd
diff --git a/config.subr b/config.subr
index ffa4e15..eef1b1e 100644
--- a/config.subr
+++ b/config.subr
@@ -64,6 +64,12 @@ config_asan() {
     rm .config_asan.c
 }
 
+config_gnu() {
+    if grep -q _GNU_SOURCE /usr/include/features.h 2>/dev/null; then
+	CFLAGS="$CFLAGS -D_GNU_SOURCE"
+    fi
+}
+
 pkg_config() {
     if pkg-config "$1"; then
 	CFLAGS="$CFLAGS $(pkg-config --cflags "$1")"
diff --git a/ic3/configure b/ic3/configure
index 303f30f..8ed3b8c 100755
--- a/ic3/configure
+++ b/ic3/configure
@@ -46,6 +46,7 @@ LIBS="${LIBS:=-lm}"
 # Common config for all targets
 CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
 config_asan
+config_gnu
 pkg_config libbsd-overlay
 pkg_config libffi
 pkg_config libmd
diff --git a/libc3/configure b/libc3/configure
index a4e6da1..a96834a 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -47,6 +47,7 @@ LIBS="${LIBS:=-lm}"
 # Common config for all targets
 CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
 config_asan
+config_gnu
 pkg_config libbsd
 pkg_config libffi
 pkg_config libmd
diff --git a/test/configure b/test/configure
index 9e8343d..44d4eeb 100755
--- a/test/configure
+++ b/test/configure
@@ -48,6 +48,7 @@ LIBS="${LIBS:=} -lm"
 # Common config for all targets
 CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
 config_asan
+config_gnu
 pkg_config libbsd-overlay
 pkg_config libffi
 pkg_config libmd