]> git.puffer.fish Git - matthieu/frr.git/commitdiff
build: gcc -fplugin=frr-format support
authorDavid Lamparter <equinox@diac24.net>
Sun, 29 Mar 2020 05:58:59 +0000 (07:58 +0200)
committerDavid Lamparter <equinox@diac24.net>
Sun, 29 Mar 2020 08:45:46 +0000 (10:45 +0200)
Try to find the plugin and add it to CFLAGS if successful.

Signed-off-by: David Lamparter <equinox@diac24.net>
configure.ac

index d1391c67b2ca9d50e04ee8e73959cf41e163b24e..fe389ebb35c827953016c8752f9f4c5a97d83ab1 100755 (executable)
@@ -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"], [