From 301fa23ca22f60c9de5412f46ce4d4fa49781267 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 27 Jul 2012 17:23:52 -0300 Subject: [PATCH] force warning compile flags. By default use: -Wall -Wextra -Wshadow -fvisibility=hidden --- configure.ac | 8 +++++-- m4/efl_compiler_flag.m4 | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 m4/efl_compiler_flag.m4 diff --git a/configure.ac b/configure.ac index a0fdd2f..37e9a3c 100644 --- a/configure.ac +++ b/configure.ac @@ -11,8 +11,6 @@ AM_MAINTAINER_MODE PKG_PROG_PKG_CONFIG -COMPILER_FLAGS - AC_LANG_C AC_USE_SYSTEM_EXTENSIONS @@ -23,6 +21,12 @@ AC_C___ATTRIBUTE__ AC_DISABLE_STATIC AC_PROG_LIBTOOL +EFL_COMPILER_FLAG +EFL_COMPILER_FLAG([-Wall]) +EFL_COMPILER_FLAG([-Wextra]) +EFL_COMPILER_FLAG([-Wshadow]) +EFL_COMPILER_FLAG([-fvisibility=hidden]) + PKG_CHECK_MODULES([EFL], [ elementary diff --git a/m4/efl_compiler_flag.m4 b/m4/efl_compiler_flag.m4 new file mode 100644 index 0000000..25c285d --- /dev/null +++ b/m4/efl_compiler_flag.m4 @@ -0,0 +1,57 @@ +dnl Copyright (C) 2010 Vincent Torri +dnl and Albin Tonnerre +dnl That code is public domain and can be freely used or copied. + +dnl Macro that checks if a compiler flag is supported by the compiler. + +dnl Usage: EFL_COMPILER_FLAG(flag) +dnl flag is added to CFLAGS if supported. + +AC_DEFUN([EFL_COMPILER_FLAG], +[ + +CFLAGS_save="${CFLAGS}" +CFLAGS="${CFLAGS} $1" + +AC_LANG_PUSH([C]) +AC_MSG_CHECKING([whether the compiler supports $1]) + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]])], + [have_flag="yes"], + [have_flag="no"]) +AC_MSG_RESULT([${have_flag}]) + +if test "x${have_flag}" = "xno" ; then + CFLAGS="${CFLAGS_save}" +fi +AC_LANG_POP([C]) + +]) + +dnl Macro that checks if a linker flag is supported by the compiler. + +dnl Usage: EFL_LINKER_FLAG(flag) +dnl flag is added to LDFLAGS if supported (will be passed to ld anyway). + +AC_DEFUN([EFL_LINKER_FLAG], +[ + +LDFLAGS_save="${LDFLAGS}" +LDFLAGS="${LDFLAGS} $1" + +AC_LANG_PUSH([C]) +AC_MSG_CHECKING([whether the compiler supports $1]) + +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[]])], + [have_flag="yes"], + [have_flag="no"]) +AC_MSG_RESULT([${have_flag}]) + +if test "x${have_flag}" = "xno" ; then + LDFLAGS="${LDFLAGS_save}" +fi +AC_LANG_POP([C]) + +]) -- 2.7.4