[libegg/spread-table-dnd: 27/45] Add an --enable-warnings=fatal configure option



commit 5a8e378e368d75f617ea3fe073d5ab04acda5e13
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Mar 22 15:09:48 2011 +0100

    Add an --enable-warnings=fatal configure option
    
    This will make it easier to avoid deprecated code and to generally
    avoid compiler warnings in the existing code.

 configure.ac                          |    8 ++-
 doc/Makefile.am                       |    2 +-
 libegg/Makefile.am                    |    7 +--
 libegg/background-monitor/Makefile.am |    8 +--
 libegg/column-chooser/Makefile.am     |    7 +--
 libegg/datetime/Makefile.am           |    5 +-
 libegg/dock/Makefile.am               |    5 +-
 libegg/fileformatchooser/Makefile.am  |    7 +--
 libegg/iconchooser/Makefile.am        |    4 +-
 libegg/pixbufthumbnail/Makefile.am    |    2 +-
 libegg/spreadtable/Makefile.am        |    5 +-
 libegg/thumbnailpreview/Makefile.am   |    2 +-
 libegg/toolbareditor/Makefile.am      |    5 +-
 libegg/treeviewutils/Makefile.am      |    5 +-
 libegg/util/Makefile.am               |    4 +
 m4/dk-warn.m4                         |  114 +++++++++++++++++++++++++++++++++
 16 files changed, 142 insertions(+), 48 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5a107e4..41b5bd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,7 @@
 AC_INIT(libegg/util/eggmarshalers.list)
 
+AC_CONFIG_MACRO_DIR(m4)
+
 AM_CONFIG_HEADER(config.h)
 
 AM_INIT_AUTOMAKE(libegg, 0.0.1)
@@ -134,14 +136,16 @@ fi
 AC_SUBST(HTML_DIR)
 AM_CONDITIONAL(ENABLE_GTK_DOC, true)
 
-
+DK_ARG_ENABLE_WARNINGS([EGG_WARNING_FLAGS],
+                       [-Wall -w1],
+                       [-pedantic -Wall -Wextra -w1],
+                       [GTK GDK GDK_PIXBUF G])
 
 AC_OUTPUT([
 Makefile
 libegg/Makefile
 libegg/util/Makefile
 libegg/background-monitor/Makefile
-libegg/sidebar/Makefile
 libegg/treeviewutils/Makefile
 libegg/column-chooser/Makefile
 libegg/toolbareditor/Makefile
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 2019d7c..da1e2b1 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -46,7 +46,7 @@ extra_files =
 
 # CFLAGS and LDFLAGS for compiling scan program. Only needed if your app/lib
 # contains GtkObjects/GObjects and you want to document signals and properties.
-GTKDOC_CFLAGS = -I$(top_srcdir) $(EGG_CFLAGS) \
+GTKDOC_CFLAGS = -I$(top_srcdir) $(EGG_CFLAGS) $(EGG_WARNING_FLAGS) \
   `pkg-config --cflags libxml-2.0`
 GTKDOC_LIBS = \
   $(top_builddir)/libegg/treeviewutils/libegg-treeview.la \
diff --git a/libegg/Makefile.am b/libegg/Makefile.am
index 1454802..a8d7072 100644
--- a/libegg/Makefile.am
+++ b/libegg/Makefile.am
@@ -40,10 +40,7 @@ SUBDIRS = util column-chooser treeviewutils \
 #$(iconchooser_SUBDIRS)
 
 INCLUDES = \
-  $(EGG_CFLAGS)  \
-  -DEGG_COMPILATION  \
-  -DGTK_DISABLE_DEPRECATED \
-  -DGDK_DISABLE_DEPRECATED \
-  -DG_DISABLE_DEPRECATED
+  $(EGG_CFLAGS) $(EGG_WARNING_FLAGS)  \
+  -DEGG_COMPILATION
 
 ##noinst_LTLIBRARIES = libegg.la
diff --git a/libegg/background-monitor/Makefile.am b/libegg/background-monitor/Makefile.am
index 8a066e0..4e2d8d7 100644
--- a/libegg/background-monitor/Makefile.am
+++ b/libegg/background-monitor/Makefile.am
@@ -1,11 +1,7 @@
 
 INCLUDES = \
-  $(EGG_CFLAGS) \
-  -Wall -Werror \
-  -DEGG_COMPILATION \
-  -DGTK_DISABLE_DEPRECATED \
-  -DGDK_DISABLE_DEPRECATED \
-  -DG_DISABLE_DEPRECATED
+  $(EGG_CFLAGS) $(EGG_WARNING_FLAGS) \
+  -DEGG_COMPILATION
 
 
 noinst_LTLIBRARIES = libegg-background-monitor.la
diff --git a/libegg/column-chooser/Makefile.am b/libegg/column-chooser/Makefile.am
index 50679fd..d7ae73f 100644
--- a/libegg/column-chooser/Makefile.am
+++ b/libegg/column-chooser/Makefile.am
@@ -1,9 +1,6 @@
 INCLUDES = \
-  $(EGG_30_CFLAGS) \
-  -DEGG_COMPILATION \
-  -DG_DISABLE_DEPRECATED \
-  -DGDK_DISABLE_DEPRECATED \
-  -DGTK_DISABLE_DEPRECATED
+  $(EGG_30_CFLAGS) $(EGG_WARNING_FLAGS) \
+  -DEGG_COMPILATION
 
 noinst_LTLIBRARIES = libegg-columnchooser.la
 
diff --git a/libegg/datetime/Makefile.am b/libegg/datetime/Makefile.am
index c16cef7..e1d6577 100644
--- a/libegg/datetime/Makefile.am
+++ b/libegg/datetime/Makefile.am
@@ -1,10 +1,7 @@
 # $Id$
 
 INCLUDES = \
-	$(EGG_CFLAGS)			\
-	-DGTK_DISABLE_DEPRECATED	\
-	-DGDK_DISABLE_DEPRECATED	\
-	-DG_DISABLE_DEPRECATED		\
+	$(EGG_CFLAGS) $(EGG_WARNING_FLAGS)			\
 	-DGETTEXT_PACKAGE=NULL
 
 noinst_LTLIBRARIES = libeggdatetime.la
diff --git a/libegg/dock/Makefile.am b/libegg/dock/Makefile.am
index 2ec7d26..83f828b 100644
--- a/libegg/dock/Makefile.am
+++ b/libegg/dock/Makefile.am
@@ -1,11 +1,8 @@
 INCLUDES = \
-	$(EGG_CFLAGS) \
+	$(EGG_CFLAGS) $(EGG_WARNING_FLAGS) \
 	$(EGG_DOCK_CFLAGS) \
 	$(EGG_XML_CFLAGS) \
 	-DG_LOG_DOMAIN=\"Egg\" \
-	-DG_DISABLE_DEPRECATED \
-	-DGTK_DISABLE_DEPRECATED \
-	-DGDK_DISABLE_DEPRECATED \
 	-DEGG_GLADEDIR=\".\" \
 	-DGETTEXT_PACKAGE=NULL \
 	-I$(top_srcdir)/libegg
diff --git a/libegg/fileformatchooser/Makefile.am b/libegg/fileformatchooser/Makefile.am
index 086c071..7ed505a 100644
--- a/libegg/fileformatchooser/Makefile.am
+++ b/libegg/fileformatchooser/Makefile.am
@@ -1,10 +1,7 @@
 INCLUDES = \
-  $(EGG_30_CFLAGS) \
+  $(EGG_30_CFLAGS) $(EGG_WARNING_FLAGS) \
   -I$(top_srcdir)/libegg/util \
-  -DEGG_COMPILATION \
-  -DGTK_DISABLE_DEPRECATED \
-  -DGDK_DISABLE_DEPRECATED \
-  -DG_DISABLE_DEPRECATED
+  -DEGG_COMPILATION
 
 
 noinst_LTLIBRARIES = libeggfileformatchooser.la
diff --git a/libegg/iconchooser/Makefile.am b/libegg/iconchooser/Makefile.am
index 8328c1b..5803b05 100644
--- a/libegg/iconchooser/Makefile.am
+++ b/libegg/iconchooser/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = \
 	-I$(top_srcdir)/libegg/util \
 	-I$(top_srcdir)/libegg/pixbufthumbnail \
 	-I$(top_srcdir)/libegg/thumbnailpreview \
-	$(EGG_CFLAGS)
+	$(EGG_CFLAGS) $(EGG_WARNING_FLAGS)
 
 
 noinst_LTLIBRARIES = \
@@ -49,7 +49,7 @@ testiconchooser_SOURCES =	\
 	prop-editor.c
 
 testiconchooser_CFLAGS = \
-	$(EGG_CFLAGS) \
+	$(EGG_CFLAGS) $(EGG_WARNING_FLAGS) \
 	-DG_LOG_DOMAIN="\"TestIconChooser\""
 
 testiconchooser_LDFLAGS = \
diff --git a/libegg/pixbufthumbnail/Makefile.am b/libegg/pixbufthumbnail/Makefile.am
index bfa47e6..4db3164 100644
--- a/libegg/pixbufthumbnail/Makefile.am
+++ b/libegg/pixbufthumbnail/Makefile.am
@@ -1,7 +1,7 @@
 # This file will be processed with automake-1.7 to create Makefile.in
 
 INCLUDES = \
-	$(EGG_CFLAGS)
+	$(EGG_CFLAGS) $(EGG_WARNING_FLAGS)
 
 noinst_LTLIBRARIES = \
 	libeggpixbufthumbnail.la
diff --git a/libegg/spreadtable/Makefile.am b/libegg/spreadtable/Makefile.am
index 941e5e7..c720963 100644
--- a/libegg/spreadtable/Makefile.am
+++ b/libegg/spreadtable/Makefile.am
@@ -1,9 +1,6 @@
 INCLUDES = \
-  $(EGG_30_CFLAGS) \
+  $(EGG_30_CFLAGS) $(EGG_WARNING_FLAGS) \
   -DEGG_COMPILATION \
-  -DGTK_DISABLE_DEPRECATED \
-  -DGDK_DISABLE_DEPRECATED \
-  -DG_DISABLE_DEPRECATED \
   -DGETTEXT_PACKAGE=\"libegg\"
 
 noinst_LTLIBRARIES = libegg-spreadtable.la
diff --git a/libegg/thumbnailpreview/Makefile.am b/libegg/thumbnailpreview/Makefile.am
index e72bbe4..bfdabbf 100644
--- a/libegg/thumbnailpreview/Makefile.am
+++ b/libegg/thumbnailpreview/Makefile.am
@@ -5,7 +5,7 @@ INCLUDES = \
 	-I$(top_srcdir)/libegg/util \
 	-I$(top_srcdir)/libegg/pixbufthumbnail \
 	-DG_LOG_DOMAIN=\""EggThumbnailPreview"\" \
-	$(EGG_30_CFLAGS)
+	$(EGG_30_CFLAGS) $(EGG_WARNING_FLAGS)
 
 noinst_LTLIBRARIES = \
 	libeggthumbnailpreview.la
diff --git a/libegg/toolbareditor/Makefile.am b/libegg/toolbareditor/Makefile.am
index db7f7a7..44be101 100644
--- a/libegg/toolbareditor/Makefile.am
+++ b/libegg/toolbareditor/Makefile.am
@@ -1,11 +1,8 @@
 INCLUDES = \
   -DCURSOR_DIR=\".\" \
-  $(EGG_30_CFLAGS) \
+  $(EGG_30_CFLAGS) $(EGG_WARNING_FLAGS) \
   $(EGG_XML_CFLAGS) \
   -DEGG_COMPILATION \
-  -DGTK_DISABLE_DEPRECATED \
-  -DGDK_DISABLE_DEPRECATED \
-  -DG_DISABLE_DEPRECATED \
   -I$(top_builddir)/libegg/util \
   -DGETTEXT_PACKAGE=\"libegg\"
 
diff --git a/libegg/treeviewutils/Makefile.am b/libegg/treeviewutils/Makefile.am
index 6891c05..1484580 100644
--- a/libegg/treeviewutils/Makefile.am
+++ b/libegg/treeviewutils/Makefile.am
@@ -1,9 +1,6 @@
 INCLUDES = \
-  $(EGG_CFLAGS) \
+  $(EGG_CFLAGS) $(EGG_WARNING_FLAGS) \
   -DEGG_COMPILATION \
-  -DG_DISABLE_DEPRECATED \
-  -DGDK_DISABLE_DEPRECATED \
-  -DGTK_DISABLE_DEPRECATED \
   -I$(top_builddir)/libegg/util
 
 noinst_LTLIBRARIES = libegg-treeview.la
diff --git a/libegg/util/Makefile.am b/libegg/util/Makefile.am
index d5ce262..1376e2a 100644
--- a/libegg/util/Makefile.am
+++ b/libegg/util/Makefile.am
@@ -1,5 +1,9 @@
 INCLUDES = \
 	$(EGG_CFLAGS)
+	
+# Note that we don't use EGG_WARNING_FLAGS here because
+# the marshalling code generally needs to ignore this warning:
+# "ISO C forbids conversion of object pointer to function pointer type"
 
 noinst_LTLIBRARIES=libeggutil.la
 
diff --git a/m4/dk-warn.m4 b/m4/dk-warn.m4
new file mode 100644
index 0000000..90243bd
--- /dev/null
+++ b/m4/dk-warn.m4
@@ -0,0 +1,114 @@
+## Copyright (c) 2004-2007 Daniel Elstner <daniel kitta gmail com>
+##
+## This file is part of danielk's Autostuff.
+##
+## danielk's Autostuff is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License as published
+## by the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## danielk's Autostuff is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+## for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with danielk's Autostuff; if not, write to the Free Software Foundation,
+## Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#serial 20070116
+
+## DK_ARG_ENABLE_WARNINGS(variable, min-flags, max-flags, [deprecation-prefixes])
+##
+## Provide the --enable-warnings configure argument, set to "min" by default.
+## <min-flags> and <max-flags> should be space-separated lists of compiler
+## warning flags to use with --enable-warnings=min or --enable-warnings=max,
+## respectively. Warning level "fatal" is the same as "max" but in addition
+## enables -Werror mode.
+##
+## If not empty, <deprecation-prefixes> should be a list of module prefixes
+## which is expanded to -D<module>_DISABLE_DEPRECATED flags if fatal warnings
+## are enabled, too.
+##
+AC_DEFUN([DK_ARG_ENABLE_WARNINGS],
+[dnl
+m4_if([$3],, [AC_FATAL([3 arguments expected])])[]dnl
+dnl
+AC_ARG_ENABLE([warnings], [AS_HELP_STRING(
+  [--enable-warnings=@<:@min|max|fatal|no@:>@],
+  [control compiler pickyness @<:@min@:>@])],
+  [dk_enable_warnings=$enableval],
+  [dk_enable_warnings=min])[]dnl
+
+dk_lang=
+case $ac_compile in
+  *'$CXXFLAGS '*)
+    dk_lang='C++'
+    dk_cc=$CXX
+    dk_conftest=conftest.${ac_ext-cc}
+    ;;
+  *'$CFLAGS '*)
+    dk_lang=C
+    dk_cc=$CC
+    dk_conftest=conftest.${ac_ext-c}
+    ;;
+esac
+
+AS_IF([test "x$dk_lang" != x],
+[
+  AC_MSG_CHECKING([which $dk_lang compiler warning flags to use])
+
+  case $dk_enable_warnings in
+    no) dk_warning_flags=;;
+    max) dk_warning_flags="$3";;
+    fatal) dk_warning_flags="$3 -Werror";;
+    *) dk_warning_flags="$2";;
+  esac
+
+  dk_deprecation_flags=
+m4_if([$4],,, [
+  AS_IF([test "x$dk_enable_warnings" = xfatal],
+  [
+    dk_deprecation_prefixes="$4"
+    for dk_prefix in $dk_deprecation_prefixes
+    do
+      dk_deprecation_flags="${dk_deprecation_flags}-D${dk_prefix}_DISABLE_DEPRECATED "
+    done
+  ])
+])[]dnl
+  dk_tested_flags=
+
+  AS_IF([test "x$dk_warning_flags" != x],
+  [
+    # Keep in mind that the dummy source must be devoid of any
+    # problems that might cause diagnostics.
+    AC_LANG_CONFTEST([AC_LANG_SOURCE(
+      [[int main(int argc, char** argv) { return (argv != 0) ? argc : 0; }]])])
+
+    for dk_flag in $dk_warning_flags
+    do
+      # Test whether the compiler accepts the flag. GCC doesn't bail
+      # out when given an unsupported flag but prints a warning, so
+      # check the compiler output instead.
+      dk_cc_out=`$dk_cc $dk_tested_flags $dk_flag -c "$dk_conftest" 2>&1 || echo failed`
+      rm -f "conftest.${OBJEXT-o}"
+
+      AS_IF([test "x$dk_cc_out" = x],
+      [
+        AS_IF([test "x$dk_tested_flags" = x],
+              [dk_tested_flags=$dk_flag],
+              [dk_tested_flags="$dk_tested_flags $dk_flag"])
+      ], [
+        echo "$dk_cc_out" >&AS_MESSAGE_LOG_FD
+      ])
+    done
+
+    rm -f "$dk_conftest"
+  ])
+  dk_all_flags=$dk_deprecation_flags$dk_tested_flags
+  AC_SUBST([$1], [$dk_all_flags])
+
+  test "x$dk_all_flags" != x || dk_all_flags=none
+  AC_MSG_RESULT([$dk_all_flags])
+])
+])



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]