]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
configure.ac: fixup to allow c++11 if c++20 is unavailable
authorSerhei Makarov <serhei@serhei.io>
Wed, 10 Jun 2026 18:33:26 +0000 (14:33 -0400)
committerSerhei Makarov <serhei@serhei.io>
Wed, 10 Jun 2026 18:33:26 +0000 (14:33 -0400)
configure.ac

index e18f247262139e363dd7114e3af13fec4300ce99..ec4525708df7e11e1d20a5c4041768f17ffc8491 100644 (file)
@@ -905,6 +905,12 @@ AX_CXX_COMPILE_STDCXX(20, noext, optional)
 AS_IF([test "x$HAVE_CXX20" = "x1"], [HAVE_CXX20=yes], [HAVE_CXX20=no])
 AM_CONDITIONAL([HAVE_CXX20],[test "x$HAVE_CXX20" = "xyes"])
 
+AS_IF([test "x$HAVE_CXX20" = "xno"], [
+  # For tests that need to use C++11, when C++20 is unavailable
+  AX_CXX_COMPILE_STDCXX(11, noext, optional)
+])
+AS_IF([test "x$HAVE_CXX11" = "x1"], [HAVE_CXX11=yes], [HAVE_CXX11=no])
+AM_CONDITIONAL([HAVE_CXX11],[test "x$HAVE_CXX11" = "xyes"])
 
 # For eu-stackprof
 # optional:
@@ -913,7 +919,18 @@ AM_CONDITIONAL([HAVE_LIBPFM], [test "x${ac_cv_header_perfmon_pfmlib_perf_event_h
 AC_CHECK_LIB(pfm, pfm_get_os_event_encoding, [AC_SUBST(libpfm_LIBS, '-lpfm')])
 # required:
 AC_CHECK_HEADERS([linux/perf_event.h])
-AM_CONDITIONAL([ENABLE_STACKPROF],[test "x${ac_cv_header_linux_perf_event_h}x${HAVE_CXX20}" = "xyesxyes" ])
+HAVE_CXX20_FORMAT=no
+AS_IF([test "x$HAVE_CXX20" = "xyes"], [
+  old_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -std=c++20"
+  AC_LANG_PUSH([C++])
+  AC_CACHE_CHECK([for c++20 format.h], ac_cv_have_cxx20_format_h,
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <format>])],
+               ac_cv_have_cxx20_format_h=yes, ac_cv_have_cxx20_format_h=no)])
+  AC_LANG_POP
+  CXXFLAGS="$old_CXXFLAGS"
+])
+AM_CONDITIONAL([ENABLE_STACKPROF],[test "x${ac_cv_header_linux_perf_event_h}x${ac_cv_have_cxx20_format_h}x${HAVE_CXX20}" = "xyesxyesxyes" ])
 
 
 AC_CHECK_HEADERS([execinfo.h])
@@ -964,6 +981,8 @@ AS_IF([test "x$with_libarchive" = "xyes" -a "x$have_libarchive" != "xyes"], [
 # pronounce judgement on ability to build server, overridden by =yes/=no
 if test "x$enable_debuginfod" = "xno"; then
    true
+elif test "x$have_jsonc$HAVE_CXX11$have_libarchive$have_sqlite3" = "xyesyesyesyes"; then
+   enable_debuginfod=yes
 elif test "x$have_jsonc$HAVE_CXX20$have_libarchive$have_sqlite3" = "xyesyesyesyes"; then
    enable_debuginfod=yes
 elif test "x$enable_debuginfod" = "xyes"; then
@@ -1063,11 +1082,12 @@ AC_MSG_NOTICE([
     Default DEBUGINFOD_URLS            : ${default_debuginfod_urls}
     Debuginfod RPM sig checking        : ${enable_debuginfod_ima_verification} 
     Default DEBUGINFOD_IMA_CERT_PATH   : ${default_debuginfod_ima_cert_path}
-    ${program_prefix}stackprof support              : ${enable_stackprof}
+    ${program_prefix}stackprof support               : ${enable_stackprof}
 
   EXTRA TEST FEATURES (used with make check)
     have bunzip2 installed (required)  : ${HAVE_BUNZIP2}
     have zstd installed                : ${HAVE_ZSTD}
+    C++11                              : ${HAVE_CXX11}
     C++20                              : ${HAVE_CXX20}
     debug branch prediction            : ${use_debugpred}
     gprof support                      : ${use_gprof}