[Groonga-mysql-commit] mroonga/mroonga [fix-for-visual-studio] add -Wall option to gcc and g++ if available.

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Oct 4 10:32:46 JST 2012


Kouhei Sutou	2011-11-27 18:50:40 +0900 (Sun, 27 Nov 2011)

  New Revision: 7d305c76d1491b7d17788fef9e9e13a5344b991c
  https://github.com/mroonga/mroonga/commit/7d305c76d1491b7d17788fef9e9e13a5344b991c

  Log:
    add -Wall option to gcc and g++ if available.

  Modified files:
    configure.ac

  Modified: configure.ac (+35 -0)
===================================================================
--- configure.ac    2011-11-27 18:47:44 +0900 (c0b34d9)
+++ configure.ac    2011-11-27 18:50:40 +0900 (e60786f)
@@ -24,6 +24,41 @@ AC_PROG_CXX
 AC_PROG_CPP
 AC_PROG_LIBTOOL
 
+AC_DEFUN([CHECK_CFLAG], [
+  AC_MSG_CHECKING([if gcc supports $1])
+  old_CFLAGS=$CFLAGS
+  CFLAGS="$CFLAGS $1 -Werror"
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+    [check_cflag=yes],
+    [check_cflag=no])
+  CFLAGS="$old_CFLAGS"
+  if test "x$check_cflag" = "xyes"; then
+    CFLAGS="$CFLAGS $1"
+  fi
+  AC_MSG_RESULT([$check_cflag])
+])
+
+AC_DEFUN([CHECK_CXXFLAG], [
+  AC_MSG_CHECKING([if g++ supports $1])
+  old_CXXFLAGS=$CXXFLAGS
+  CXXFLAGS="$CXXFLAGS $1 -Werror"
+  AC_LANG_PUSH([C++])
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+    [check_cxxflag=yes],
+    [check_cxxflag=no])
+  AC_LANG_POP([C++])
+  CXXFLAGS="$old_CXXFLAGS"
+  if test "x$check_cxxflag" = "xyes"; then
+    CXXFLAGS="$CXXFLAGS $1"
+  fi
+  AC_MSG_RESULT([$check_cxxflag])
+])
+
+if test "$GCC" = "yes"; then
+  CHECK_CFLAG([-Wall])
+  CHECK_CXXFLAG([-Wall])
+fi
+
 standalone_build=
 
 AC_DEFUN([CONFIG_OPTION_PLUGINS],
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-mysql-commit mailing list
Back to archive index