summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2020-03-29 07:58:59 +0200
committerDavid Lamparter <equinox@diac24.net>2020-03-29 10:45:46 +0200
commitac92fc9e9fdc8f4683fda426237c38a23f3eac0c (patch)
treec1b3ee0f31592047967587bb0fcc805158599d83 /configure.ac
parenttools/gcc-plugins: add small test for frr-format (diff)
downloadfrr-ac92fc9e9fdc8f4683fda426237c38a23f3eac0c.tar.xz
frr-ac92fc9e9fdc8f4683fda426237c38a23f3eac0c.zip
build: gcc -fplugin=frr-format support
Try to find the plugin and add it to CFLAGS if successful. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'configure.ac')
-rwxr-xr-xconfigure.ac44
1 files changed, 42 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index d1391c67b..fe389ebb3 100755
--- a/configure.ac
+++ b/configure.ac
@@ -182,13 +182,13 @@ dnl - specifically, options to control warnings
AC_USE_SYSTEM_EXTENSIONS
AC_DEFUN([AC_C_FLAG], [{
- m4_pushdef([cachename],[m4_translit([frr_cv_$1],[ =-+],[____])])
+ m4_pushdef([cachename],[m4_translit([frr_cv_$1],[ =-+/{}$],[________])])
AC_CACHE_CHECK([[whether $CC supports $1]], cachename, [
AC_LANG_PUSH([C])
ac_c_flag_save="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[]])],
+ [AC_LANG_PROGRAM([[$4]])],
[
cachename=yes
], [
@@ -354,6 +354,44 @@ if test "$enable_undefined_sanitizer" = "yes"; then
fi
AC_SUBST([SAN_FLAGS])
+dnl frr-format.so
+if test "$with_frr_format" != "no" -a "$with_frr_format" != "yes" -a -n "$with_frr_format"; then
+ AC_C_FLAG([-fplugin=${with_frr_format}], [
+ AC_MSG_ERROR([specified frr-format plugin ($with_frr_format) does not work])
+ ],,[
+#ifndef _FRR_ATTRIBUTE_PRINTFRR
+#error plugin not loaded
+#endif
+#if _FRR_ATTRIBUTE_PRINTFRR < 0x10000
+#error plugin too old
+#endif
+ ])
+elif test "$with_frr_format" = "no"; then
+ : #nothing
+else
+ AC_C_FLAG([-fplugin=tools/gcc-plugins/frr-format.so],[
+ AC_C_FLAG([-fplugin=frr-format],[
+ if test "$with_frr_format" = "yes"; then
+ AC_MSG_ERROR([frr-format plugin requested but not found])
+ fi
+ ],,[
+#ifndef _FRR_ATTRIBUTE_PRINTFRR
+#error plugin not loaded
+#endif
+#if _FRR_ATTRIBUTE_PRINTFRR < 0x10000
+#error plugin too old
+#endif
+ ])
+ ],,[
+#ifndef _FRR_ATTRIBUTE_PRINTFRR
+#error plugin not loaded
+#endif
+#if _FRR_ATTRIBUTE_PRINTFRR < 0x10000
+#error plugin too old
+#endif
+ ])
+fi
+
dnl ----------
dnl Essentials
dnl ----------
@@ -600,6 +638,8 @@ AC_ARG_ENABLE([undefined-sanitizer],
AS_HELP_STRING([--undefined-sanitizer], [enable UndefinedBehaviorSanitizer support for detecting undefined behavior]))
AC_ARG_WITH([crypto],
AS_HELP_STRING([--with-crypto=<internal|openssl>], [choose between different implementations of cryptographic functions(default value is --with-crypto=internal)]))
+AC_ARG_WITH([frr-format],
+ AS_HELP_STRING([--with-frr-format[=<.../frr-format.so>]], [use frr-format GCC plugin]))
#if openssl, else use the internal
AS_IF([test "$with_crypto" = "openssl"], [