From c5c2448617e72d088e818a5581a8a6cc85e81963 Mon Sep 17 00:00:00 2001
From: Rainer Gerhards <rgerhards@adiscon.com>
Date: Sat, 16 May 2026 10:44:45 +0200
Subject: [PATCH] configure: make libyaml default-on explicit

Why: Distro builds must not silently change rsyslog features based
on whether libyaml development files happen to be installed.

Impact: Default builds now require yaml-0.1 unless --disable-libyaml
is passed explicitly.

Before/After: Before, configure auto-disabled libyaml features;
after, the default fails fast and opt-out builds are explicit.

Closes https://github.com/rsyslog/rsyslog/issues/6914

Upstream-Status: Backport [v8.2604.0 -> 8.2606.0]
Upstream-Commit: c5c2448617e72d088e818a5581a8a6cc85e81963
---
 configure.ac | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

--- a/configure.ac
+++ b/configure.ac
@@ -166,11 +166,24 @@ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#i
                  )
 
 # Checks for libraries.
-PKG_CHECK_MODULES([LIBYAML], [yaml-0.1], [
-	AC_DEFINE([HAVE_LIBYAML], [1], [Define if libyaml is available])
-	have_libyaml=yes
+AC_ARG_ENABLE(libyaml,
+	[AS_HELP_STRING([--disable-libyaml],
+		[Disable libyaml-backed YAML configuration and policy file support @<:@default=enabled@:>@])],
+	[case "${enableval}" in
+	 yes) enable_libyaml="yes" ;;
+	  no) enable_libyaml="no" ;;
+	   *) AC_MSG_ERROR(bad value ${enableval} for --enable-libyaml) ;;
+	 esac],
+	[enable_libyaml="yes"]
+)
+AS_IF([test "x$enable_libyaml" = "xyes"], [
+	PKG_CHECK_MODULES([LIBYAML], [yaml-0.1], [
+		AC_DEFINE([HAVE_LIBYAML], [1], [Define if libyaml is available])
+		have_libyaml=yes
+	], [
+		AC_MSG_ERROR([libyaml support is enabled by default but yaml-0.1 was not found. Install libyaml development files or configure with --disable-libyaml.])
+	])
 ], [
-	AC_MSG_WARN([libyaml not found, rate limiting policies from files and YAML configuration support will be disabled])
 	have_libyaml=no
 ])
 AM_CONDITIONAL(HAVE_LIBYAML, test x$have_libyaml = xyes)
