From: Selva Nair <selva.n...@gmail.com>

Some compilers (e.g., clang) only issue a warning for
unsupported options unless additional flags such
as -Werror are used to convert the warning to an error.

Add support for extra flags in ACL_CHECK_ADD_COMPILE_FLAGS.

Note: a similar approach is used in AX_CHECK_COMPILE_FLAG
in autoconf archives.

Signed-off-by: Selva Nair <selva.n...@gmail.com>
---

For successful travis build result see
https://travis-ci.org/selvanair/openvpn/builds/612019849

But this + https://patchwork.openvpn.net/patch/908/
alone does not fix the travis build as clang is not
happy with struct initializers: Like this

crypto.c:1860:31: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
    struct key server_key = { 0 };

I think clang wants {{0}} there.

Darn compilers and darn -Werror :)

 configure.ac | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 807804e5..e59bd91b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1275,18 +1275,21 @@ if test "${enable_pkcs11}" = "yes"; then
        )
 fi
 
+# Usage: ACL_CHECK_ADD_COMPILE_FLAGS(flag, [extra-flags])
+# Some compilers require extra flags to trigger an error on
+# unsupported options. E.g., clang requires -Werror.
 AC_DEFUN([ACL_CHECK_ADD_COMPILE_FLAGS], [
     old_cflags="$CFLAGS"
-    CFLAGS="$1 $CFLAGS"
-    AC_MSG_CHECKING([whether the compiler acceppts $1])
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [AC_MSG_RESULT([yes])],
+    CFLAGS="$2 $1 $CFLAGS"
+    AC_MSG_CHECKING([whether the compiler accepts $1])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [AC_MSG_RESULT([yes])]; CFLAGS="$1 
$old_cflags",
         [AC_MSG_RESULT([no]); CFLAGS="$old_cflags"])]
 )
 
-ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation])
-ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-function])
-ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-parameter])
-ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation], [-Werror])
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-function], [-Werror])
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-parameter], [-Werror])
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wall], [-Werror])
 
 if test "${enable_pedantic}" = "yes"; then
        enable_strict="yes"
-- 
2.20.1



_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to