]> granicus.if.org Git - curl/commitdiff
configure: conditionally enable pedantic-errors
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Mon, 9 Jul 2018 16:38:23 +0000 (18:38 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Tue, 21 Aug 2018 16:53:44 +0000 (18:53 +0200)
Enable pedantic-errors for GCC >= 5 with --enable-werror. Before GCC 5,
pedantic-errors was synonymous to -Werror=pedantic [0], which is still
the case for clang [1]. With GCC 5, it became complementary [2].

Also fix a resulting error in acinclude.m4 as main's return type was
missing, which is illegal in C99.

[0] https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Warning-Options.html
[1] https://clang.llvm.org/docs/UsersManual.html#options-to-control-error-and-warning-messages
[2] https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/Warning-Options.html

Closes https://github.com/curl/curl/pull/2747

acinclude.m4
configure.ac

index f32e86cda5ad9986ca149c371f90f306e5aca86c..355ee3a61c283dcc95b715674151833fbb6628a8 100644 (file)
@@ -2158,7 +2158,7 @@ AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
     dnl point also is available run-time!
     AC_MSG_CHECKING([run-time libs availability])
     CURL_RUN_IFELSE([
-main()
+int main()
 {
   return 0;
 }
index 18b7ae0f1bde8e31f95077fa5d10d720d7a00edf..ff8f5df9b9d4b0a3f8b204b195ac9d8b6856eaec 100755 (executable)
@@ -61,6 +61,13 @@ AC_SUBST(CONFIGURE_OPTIONS)
 CURL_CFLAG_EXTRAS=""
 if test X"$want_werror" = Xyes; then
   CURL_CFLAG_EXTRAS="-Werror"
+  if test "$compiler_id" = "GNU_C"; then
+    dnl enable -pedantic-errors for GCC 5 and later,
+    dnl as before that it was the same as -Werror=pedantic
+    if test "$compiler_num" -ge "500"; then
+      CURL_CFLAG_EXTRAS="$CURL_CFLAG_EXTRAS -pedantic-errors"
+    fi
+  fi
 fi
 AC_SUBST(CURL_CFLAG_EXTRAS)