krb5-auth-dialog r131 - in trunk: . m4



Author: guidog
Date: Wed Mar 11 16:25:55 2009
New Revision: 131
URL: http://svn.gnome.org/viewvc/krb5-auth-dialog?rev=131&view=rev

Log:
add more compiler warnings

Added:
   trunk/m4/
   trunk/m4/compiler-flags.m4
Modified:
   trunk/ChangeLog
   trunk/acinclude.m4
   trunk/configure.ac

Modified: trunk/acinclude.m4
==============================================================================
--- trunk/acinclude.m4	(original)
+++ trunk/acinclude.m4	Wed Mar 11 16:25:55 2009
@@ -115,3 +115,91 @@
          fi
     fi
   ])
+
+dnl
+dnl taken from libvirt which was
+dnl taken from gnome-common/macros2/gnome-compiler-flags.m4
+dnl
+dnl We've added:
+dnl   -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
+dnl We've removed
+dnl   CFLAGS="$realsave_CFLAGS"
+dnl   to avoid clobbering user-specified CFLAGS
+dnl
+AC_DEFUN([KA_COMPILE_WARNINGS],[
+    dnl ******************************
+    dnl More compiler warnings
+    dnl ******************************
+
+    AC_ARG_ENABLE(compile-warnings,
+                  AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
+                                 [Turn on compiler warnings]),,
+                  [enable_compile_warnings="m4_default([$1],[maximum])"])
+
+    warnCFLAGS=
+
+    common_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
+
+    case "$enable_compile_warnings" in
+    no)
+        try_compiler_flags=""
+	;;
+    minimum)
+	try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
+	;;
+    yes)
+	try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
+	;;
+    maximum|error)
+	try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
+	try_compiler_flags="$try_compiler_flags -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return"
+	try_compiler_flags="$try_compiler_flags -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare"
+	try_compiler_flags="$try_compiler_flags $common_flags"
+	if test "$enable_compile_warnings" = "error" ; then
+	    try_compiler_flags="$try_compiler_flags -Werror"
+	fi
+	;;
+    *)
+	AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
+	;;
+    esac
+
+    COMPILER_FLAGS=
+    for option in $try_compiler_flags; do
+        gl_COMPILER_FLAGS($option)
+    done
+    unset option
+    unset try_compiler_flags
+
+    AC_ARG_ENABLE(iso-c,
+                  AC_HELP_STRING([--enable-iso-c],
+                                 [Try to warn if code is not ISO C ]),,
+                  [enable_iso_c=no])
+
+    AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
+    complCFLAGS=
+    if test "x$enable_iso_c" != "xno"; then
+	if test "x$GCC" = "xyes"; then
+	case " $CFLAGS " in
+	    *[\ \	]-ansi[\ \	]*) ;;
+	    *) complCFLAGS="$complCFLAGS -ansi" ;;
+	esac
+	case " $CFLAGS " in
+	    *[\ \	]-pedantic[\ \	]*) ;;
+	    *) complCFLAGS="$complCFLAGS -pedantic" ;;
+	esac
+	fi
+    fi
+    AC_MSG_RESULT($complCFLAGS)
+
+    WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
+    AC_SUBST(WARN_CFLAGS)
+
+    dnl Needed to keep compile quiet on python 2.4
+    COMPILER_FLAGS=
+    gl_COMPILER_FLAGS(-Wno-redundant-decls)
+    WARN_PYTHON_CFLAGS=$COMPILER_FLAGS
+    AC_SUBST(WARN_PYTHON_CFLAGS)
+])
+
+m4_include([m4/compiler-flags.m4])

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Wed Mar 11 16:25:55 2009
@@ -1,6 +1,7 @@
-AC_INIT(src/krb5-auth-dialog.c)
-
-AM_INIT_AUTOMAKE(krb5-auth-dialog, 0.8)
+AC_INIT([krb5-auth-dialog], [0.8])
+AC_CONFIG_SRCDIR(src/krb5-auth-dialog.c)
+dnl Make automake keep quiet about wildcards & other GNUmake-isms
+AM_INIT_AUTOMAKE([-Wno-portability])
 AM_CONFIG_HEADER(config.h)
 
 AM_MAINTAINER_MODE
@@ -18,6 +19,8 @@
 AM_PROG_LEX
 AC_PROG_YACC
 
+KA_COMPILE_WARNINGS([maximum])
+
 ALL_LINGUAS="nb de"
 AM_GLIB_GNU_GETTEXT
 
@@ -200,6 +203,7 @@
 	$KRB5_CFLAGS \
 	$NETWORK_MANAGER_CFLAGS \
 	$LIBNOTIFY_CFLAGS \
+	$WARN_CFLAGS \
 	$CFLAGS"
 
 AC_OUTPUT([
@@ -238,6 +242,8 @@
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Miscellaneous])
 AC_MSG_NOTICE([])
+AC_MSG_NOTICE([          Warnings: $WARN_CFLAGS])
+AC_MSG_NOTICE([            Debug : $enable_debug])
 AC_MSG_NOTICE([  Minimum Lifetime: $minimum_lifetime minutes])
 AC_MSG_NOTICE([    Check Interval: $check_interval seconds])
 AC_MSG_NOTICE([])

Added: trunk/m4/compiler-flags.m4
==============================================================================
--- (empty file)
+++ trunk/m4/compiler-flags.m4	Wed Mar 11 16:25:55 2009
@@ -0,0 +1,40 @@
+# serial 3
+# Find valid warning flags for the C Compiler.           -*-Autoconf-*-
+#
+# Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301  USA
+
+# Written by Jesse Thilo.
+
+AC_DEFUN([gl_COMPILER_FLAGS],
+  [AC_MSG_CHECKING(whether compiler accepts $1)
+   AC_SUBST(COMPILER_FLAGS)
+   ac_save_CFLAGS="$CFLAGS"
+   CFLAGS="$CFLAGS $1"
+   AC_TRY_LINK([], [], has_option=yes, has_option=no,)
+   echo 'int x;' >conftest.c
+   $CC $CFLAGS -c conftest.c 2>conftest.err
+   ret=$?
+   if test $ret != 0 -o -s conftest.err -o $has_option = "no"; then
+       AC_MSG_RESULT(no)
+   else
+       AC_MSG_RESULT(yes)
+       COMPILER_FLAGS="$COMPILER_FLAGS $1"
+   fi
+   CFLAGS="$ac_save_CFLAGS"
+   rm -f conftest*
+ ])



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