summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Greear <greearb@candelatech.com>2010-07-29 23:43:02 -0700
committerBen Greear <greearb@candelatech.com>2010-07-29 23:43:02 -0700
commit45557a138e60031a6e680d62aa29ddf2bf925d8c (patch)
treec21a3c4bb0d5b1e5795c208f8329e4efc1bec0e4
parent3e33e2c2ba612d19cf7c1f77c8953b012489e801 (diff)
downloadc-ares-45557a138e60031a6e680d62aa29ddf2bf925d8c.tar.gz
c-ares-45557a138e60031a6e680d62aa29ddf2bf925d8c.tar.bz2
c-ares-45557a138e60031a6e680d62aa29ddf2bf925d8c.zip
build: Enable compiling with -Werror.
This helps find compile warnings because they simply break the build. To use: ./configure --enable-warnings --enable-werror Signed-off-by: Ben Greear <greearb@candelatech.com>
-rw-r--r--Makefile.am3
-rw-r--r--configure.ac7
-rw-r--r--m4/cares-confopts.m431
3 files changed, 41 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 6cb508e..672120d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -99,6 +99,9 @@ endif
libcares_la_LDFLAGS = $(UNDEF) $(VER)
+# Add -Werror if defined
+CFLAGS += @CARES_CFLAG_EXTRAS@
+
# Makefile.inc provides the CSOURCES and HHEADERS defines
include Makefile.inc
diff --git a/configure.ac b/configure.ac
index 667141d..d505e16 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,6 +13,7 @@ AM_MAINTAINER_MODE
CARES_CHECK_OPTION_DEBUG
CARES_CHECK_OPTION_OPTIMIZE
CARES_CHECK_OPTION_WARNINGS
+CARES_CHECK_OPTION_WERROR
CARES_CHECK_OPTION_CURLDEBUG
CARES_CHECK_OPTION_SYMBOL_HIDING
@@ -862,6 +863,12 @@ CARES_CONFIGURE_SYMBOL_HIDING
CARES_PRIVATE_LIBS="$LIBS"
AC_SUBST(CARES_PRIVATE_LIBS)
+CARES_CFLAG_EXTRAS=""
+if test X"$want_werror" == Xyes; then
+ CARES_CFLAG_EXTRAS="-Werror"
+fi
+AC_SUBST(CARES_CFLAG_EXTRAS)
+
dnl squeeze whitespace out of some variables
squeeze CFLAGS
diff --git a/m4/cares-confopts.m4 b/m4/cares-confopts.m4
index 438f9cd..fb665d4 100644
--- a/m4/cares-confopts.m4
+++ b/m4/cares-confopts.m4
@@ -253,6 +253,37 @@ AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
AC_MSG_RESULT([$want_warnings])
])
+dnl CARES_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([CARES_CHECK_OPTION_WERROR], [
+ AC_MSG_CHECKING([whether to treat compile warnings as errors])
+ OPT_COMPILER_WERROR="default"
+ AC_ARG_ENABLE(werror,
+AC_HELP_STRING([--enable-werror],[Treat compile warnings as errors])
+AC_HELP_STRING([--disable-warnings],[Don't treat compile warnings as werrors]),
+ OPT_COMPILER_WERROR=$enableval)
+ case "$OPT_COMPILER_WERROR" in
+ no)
+ dnl --disable-werror option used
+ want_werror="no"
+ ;;
+ default)
+ dnl configure option not specified, so
+ dnl use same setting as --enable-debug
+ want_werror="no"
+ ;;
+ *)
+ dnl --enable-werror option used
+ want_werror="yes"
+ ;;
+ esac
+ AC_MSG_RESULT([$want_werror])
+])
+
dnl CARES_CHECK_NONBLOCKING_SOCKET
dnl -------------------------------------------------