]> git.ipfire.org Git - people/ms/telemetry.git/commitdiff
configure: Refactor the source check
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Dec 2025 13:16:01 +0000 (13:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Dec 2025 13:16:01 +0000 (13:16 +0000)
The macros were not properly set which caused that the daemon was built
without any sources.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
configure.ac
m4/sources.m4

index dc0e19a3ae4b886e3fa584133fc9d2cd1e860530..73a06404dd76528b0d66ef911bc3cc78f8acc501 100644 (file)
@@ -209,27 +209,27 @@ LIBS="$save_LIBS"
 
 # ------------------------------------------------------------------------------
 
-ENABLE_SOURCE([conntrack])
-ENABLE_SOURCE([contextswitches])
-ENABLE_SOURCE([cpufreq])
-ENABLE_SOURCE([df])
-ENABLE_SOURCE([disk])
-ENABLE_SOURCE([hostapd])
-ENABLE_SOURCE([interface], [$have_libnl3 $have_libnl3_route])
-ENABLE_SOURCE([ipfrag4])
-ENABLE_SOURCE([iptables], [$have_libiptc])
-ENABLE_SOURCE([legacy-gateway-latency4], [$have_libnl3 $have_libnl3_route])
-ENABLE_SOURCE([loadavg])
-ENABLE_SOURCE([memory])
-ENABLE_SOURCE([nftables], [$have_libmnl $have_libnftnl])
-ENABLE_SOURCE([pressure-cpu])
-ENABLE_SOURCE([pressure-io])
-ENABLE_SOURCE([pressure-memory])
-ENABLE_SOURCE([sensors], [$have_sensors])
-ENABLE_SOURCE([softirq])
-ENABLE_SOURCE([suricata])
-ENABLE_SOURCE([unbound])
-ENABLE_SOURCE([uptime])
+AC_SOURCE([conntrack])
+AC_SOURCE([contextswitches])
+AC_SOURCE([cpufreq])
+AC_SOURCE([df])
+AC_SOURCE([disk])
+AC_SOURCE([hostapd])
+AC_SOURCE([interface], [$have_libnl3 $have_libnl3_route])
+AC_SOURCE([ipfrag4])
+AC_SOURCE([iptables], [$have_libiptc])
+AC_SOURCE([legacy-gateway-latency4], [$have_libnl3 $have_libnl3_route])
+AC_SOURCE([loadavg])
+AC_SOURCE([memory])
+AC_SOURCE([nftables], [$have_libmnl $have_libnftnl])
+AC_SOURCE([pressure-cpu])
+AC_SOURCE([pressure-io])
+AC_SOURCE([pressure-memory])
+AC_SOURCE([sensors], [$have_sensors])
+AC_SOURCE([softirq])
+AC_SOURCE([suricata])
+AC_SOURCE([unbound])
+AC_SOURCE([uptime])
 
 # ------------------------------------------------------------------------------
 have_manpages=no
index 7d84bd3c66d9d27ed35ccbd8f3d4507b9ce7c0d8..0a684d14f290646ad53f12dfd665c84089d81038 100644 (file)
@@ -1,14 +1,17 @@
-AC_DEFUN([ENABLE_SOURCE], [
-       # Replace hyphens with underscores
-       source=`echo "$1" | tr '-' '_'`
 
-       # Make the name uppercase for the macro
-       source_uppercase=`echo "$source" | tr 'a-z' 'A-Z'`
+m4_define([source_uppercase], [m4_translit(
+       m4_translit([$1], [-], [_]),        dnl replace - with _
+       m4_defn([m4_cr_letters]),           dnl lowercase letters
+       m4_defn([m4_cr_LETTERS])            dnl uppercase letters
+)])
+
+AC_DEFUN([AC_SOURCE], [
+       build_source=no
 
        AC_ARG_ENABLE([$1],
                AS_HELP_STRING([--enable-$1], [enable $1 source (auto/yes/no)]),
-               [eval enable_source_$source="$enableval"],
-               [eval enable_source_$source="auto"]
+               [build_source="$enableval"],
+               [build_source="auto"]
        )
 
     # Determine if all dependencies are present
@@ -20,25 +23,23 @@ AC_DEFUN([ENABLE_SOURCE], [
         fi
     done
 
-       eval "val=\$enable_source_$source"
-
-       case "$val" in
+       case "$build_source" in
                yes)
                        if test "x$all_deps" != "xyes"; then
                                AC_MSG_ERROR([source '$1' requested but one or more dependencies missing])
                        fi
-                       eval build_source_$source=yes
+                       build_source=yes
                        ;;
 
                no)
-                       eval build_source_$source=no
+                       build_source=no
                        ;;
 
                auto)
                        if test "x$all_deps" = "xyes"; then
-                               eval build_source_$source=yes
+                               build_source=yes
                        else
-                               eval build_source_$source=no
+                               build_source=no
                        fi
                        ;;
 
@@ -47,11 +48,15 @@ AC_DEFUN([ENABLE_SOURCE], [
                        ;;
        esac
 
-       eval "val=\$build_source_$source"
-
-       if test "x$val" = "xyes"; then
-               AC_DEFINE_UNQUOTED([BUILD_SOURCE_$source_uppercase], [1], [Build the $1 source])
-       else
-               AC_DEFINE_UNQUOTED([BUILD_SOURCE_$source_uppercase], [0], [Build the $1 source])
+       if test "x$build_source" = "xyes"; then
+               AC_DEFINE([BUILD_SOURCE_]source_uppercase([$1]), 1, [Define to 1 if the $1 source is enabled])
        fi
+
+       AM_CONDITIONAL([BUILD_SOURCE_]source_uppercase([$1]), [test "x$build_source" = "xyes"])
+
+       # Escape the source name
+       source_escaped="`echo "$1" | tr - _`"
+
+       # Store the state
+       eval build_source_$source_escaped=$build_source
 ])