cURL / Mailing Lists / curl-library / Single Mail

curl-library

[configure] configure: Enable ./configure --enable-werror

From: Ben Greear <greearb_at_candelatech.com>
Date: Sun, 28 Mar 2010 12:43:10 -0700

This allows developers to easily detect build errors as they
will cause the compile to fail.

Signed-off-by: Ben Greear <greearb_at_candelatech.com>

---
:100644 100644 221df9b... bcae01c... M	RELEASE-NOTES
:100644 100644 dbaa224... c3082eb... M	configure.ac
:100644 100644 8a1f1a9... 7629c6b... M	lib/Makefile.am
:100644 100644 fb11ee3... 3680961... M	m4/curl-confopts.m4
:100644 100644 3672458... f2b4c8c... M	src/Makefile.am
 RELEASE-NOTES       |    1 +
 configure.ac        |    7 +++++++
 lib/Makefile.am     |    3 +++
 m4/curl-confopts.m4 |   32 ++++++++++++++++++++++++++++++++
 src/Makefile.am     |    3 +++
 5 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 221df9b..bcae01c 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -12,6 +12,7 @@ This release includes the following changes:
  o The 'ares' subtree has been removed from the source repository
  o smoother rate limiting
  o allow user+password in the URL for all protocols
+ o Allow ./configure --enable-werror
 
 This release includes the following bugfixes:
 
diff --git a/configure.ac b/configure.ac
index dbaa224..c3082eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,7 @@ AM_MAINTAINER_MODE
 CURL_CHECK_OPTION_DEBUG
 CURL_CHECK_OPTION_OPTIMIZE
 CURL_CHECK_OPTION_WARNINGS
+CURL_CHECK_OPTION_WERROR
 CURL_CHECK_OPTION_CURLDEBUG
 CURL_CHECK_OPTION_ARES
 
@@ -51,6 +52,12 @@ CURL_CHECK_PATH_SEPARATOR_REQUIRED
 CONFIGURE_OPTIONS="\"$ac_configure_args\""
 AC_SUBST(CONFIGURE_OPTIONS)
 
+CURL_CFLAG_EXTRAS=""
+if test X"$want_werror" == Xyes; then
+  CURL_CFLAG_EXTRAS="-Werror"
+fi
+AC_SUBST(CURL_CFLAG_EXTRAS)
+
 dnl SED is mandatory for configure process and libtool.
 dnl Set it now, allowing it to be changed later.
 AC_PATH_PROG([SED], [sed], [not_found],
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 8a1f1a9..7629c6b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -44,6 +44,9 @@ CLEANFILES = $(DSP) $(VCPROJ)
 lib_LTLIBRARIES = libcurl.la
 LIBCURL_LIBS = @LIBCURL_LIBS@
 
+# This might hold -Werror
+CFLAGS += @CURL_CFLAG_EXTRAS@
+
 # Specify our include paths here, and do it relative to $(top_srcdir) and
 # $(top_builddir), to ensure that these paths which belong to the library
 # being currently built and tested are searched before the library which
diff --git a/m4/curl-confopts.m4 b/m4/curl-confopts.m4
index fb11ee3..3680961 100644
--- a/m4/curl-confopts.m4
+++ b/m4/curl-confopts.m4
@@ -314,6 +314,38 @@ AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
   AC_MSG_RESULT([$want_warnings])
 ])
 
+dnl CURL_CHECK_OPTION_WERROR
+dnl -------------------------------------------------
+dnl Verify if configure has been invoked with option
+dnl --enable-werror or --disable-werror, and set
+dnl shell variable want_werror as appropriate.
+
+AC_DEFUN([CURL_CHECK_OPTION_WERROR], [
+  AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
+  AC_BEFORE([$0],[CURL_CHECK_PROG_CC])dnl
+  AC_MSG_CHECKING([whether to enable compiler warnings as errors])
+  OPT_COMPILER_WERROR="default"
+  AC_ARG_ENABLE(werror,
+AC_HELP_STRING([--enable-werror],[Enable compiler warnings as errors])
+AC_HELP_STRING([--disable-werror],[Disable compiler warnings as errors]),
+  OPT_COMPILER_WERROR=$enableval)
+  case "$OPT_COMPILER_WERROR" in
+    no)
+      dnl --disable-werror option used
+      want_werror="no"
+      ;;
+    default)
+      dnl --disable-werror option not specified, default to off
+      want_werror="no"
+      ;;
+    *)
+      dnl --enable-werror option used
+      want_werror="yes"
+      ;;
+  esac
+  AC_MSG_RESULT([$want_werror])
+])
+
 
 dnl CURL_CHECK_NONBLOCKING_SOCKET
 dnl -------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 3672458..f2b4c8c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,6 +46,9 @@ bin_PROGRAMS = curl
 
 include Makefile.inc
 
+# This might hold -Werror
+CFLAGS += @CURL_CFLAG_EXTRAS@
+
 curl_LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@
 curl_DEPENDENCIES = $(top_builddir)/lib/libcurl.la
 BUILT_SOURCES = hugehelp.c
-- 
1.6.2.5
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-28