]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1413] test OpenSSL headers regarding -Wno-strict-prototypes.
authorDave Hart <hart@ntp.org>
Sun, 13 Dec 2009 19:45:56 +0000 (19:45 +0000)
committerDave Hart <hart@ntp.org>
Sun, 13 Dec 2009 19:45:56 +0000 (19:45 +0000)
bk: 4b254474g8gYGZifOxYDZIGOjUQhEg

ChangeLog
configure.ac

index 6d7fc017e4d7633757ef1d291c35d89b591dd7e8..ddd79f30ec7be247b1ddd98b8d47bf91c242b0fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+---
+
+* [Bug 1413] test OpenSSL headers regarding -Wno-strict-prototypes.
+
 ---
 (4.2.6) 2009/12/09 Released by Harlan Stenn <stenn@ntp.org>
 * Include (4.2.4p8) - [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.
index 636b195b44fd80f96c1ed540658b672785d2bc56..d89839794f982e10f9e750760cf6bfb1079167b6 100644 (file)
@@ -318,7 +318,7 @@ case "$GCC" in
      yes)
        CFLAGS="$CFLAGS -Wstrict-overflow"
     esac
-    # if building with OpenSSL, -Wno-strict-prototypes is added later
+    # -W[no-]strict-prototypes is added later depending on OpenSSL
 esac
 
 case "$host" in
@@ -3368,23 +3368,65 @@ case "$ntp_openssl" in
 esac
 
 #
-# OpenSSL has a number of callback prototypes inside other function
-# prototypes which trigger copious warnings with -Wstrict-prototypes,
-# (which is included in -Wall).
+# Older OpenSSL headers have a number of callback prototypes inside
+# other function prototypes which trigger copious warnings with gcc's
+# -Wstrict-prototypes, which is included in -Wall.
 #
 # An example:
 #
 # int i2d_RSA_NET(const RSA *a, unsigned char **pp, 
-#                 int (*cb)(), int sgckey);
-#                 ^^^^^^^^^^^
+#                int (*cb)(), int sgckey);
+#                ^^^^^^^^^^^
 #
-# The OpenSSL headers probably haven't been fixed in this regard
-# due to the hoops you have to jump through to stay compatible with
-# K&R C compilers.
+# 
 #
+openssl_triggers_warnings=unknown
+SAVED_CFLAGS="$CFLAGS"
+
 case "$GCC$ntp_openssl" in
  yesyes)
-    CFLAGS="$CFLAGS -Wno-strict-prototypes"
+    CFLAGS="$CFLAGS -Werror"
+    AC_COMPILE_IFELSE(
+       AC_LANG_SOURCE([[ /* see if -Werror breaks gcc */ ]]),
+       [gcc_handles_Werror=yes],
+       [gcc_handles_Werror=no]
+    )
+    case "$gcc_handles_Werror" in
+     no)
+       # if this gcc doesn't do -Werror go ahead and use
+       # -Wstrict-prototypes.
+       openssl_triggers_warnings=yes
+       ;;
+     yes)
+       CFLAGS="$CFLAGS -Wstrict-prototypes"
+       AC_COMPILE_IFELSE(
+           AC_LANG_PROGRAM(
+               [[
+                   #include "openssl/asn1_mac.h"
+                   #include "openssl/bn.h"
+                   #include "openssl/err.h"
+                   #include "openssl/evp.h"
+                   #include "openssl/pem.h"
+                   #include "openssl/rand.h"
+                   #include "openssl/x509v3.h"
+               ]],
+               [[ /* empty body */ ]]
+           ),
+           [openssl_triggers_warnings=no],
+           [openssl_triggers_warnings=yes]
+       )
+    esac
+    case "$openssl_triggers_warnings" in
+     yes)
+       CFLAGS="$SAVED_CFLAGS -Wno-strict-prototypes"
+       ;;
+     *)
+       CFLAGS="$SAVED_CFLAGS -Wstrict-prototypes"
+    esac
+    ;;
+ yesno)
+    # gcc without OpenSSL
+    CFLAGS="$SAVED_CFLAGS -Wstrict-prototypes"
 esac
 
 AC_MSG_CHECKING([if we want to compile with ElectricFence])