use m4 macro ti check compiler flag
authorcaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 24 Jan 2010 11:13:23 +0000 (11:13 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 24 Jan 2010 11:13:23 +0000 (11:13 +0000)
patch by Lutin (who also wrote the m4 macro, i forgot that
in the previous commit)

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@45518 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

configure.ac
m4/efl_compiler_flag.m4 [new file with mode: 0644]

index 06721ac..1be6fe2 100644 (file)
@@ -294,32 +294,12 @@ case "${host_os}" in
 esac
 
 if ! test "x${VMIC}" = "x" ; then
-   CFLAGS_save="${CFLAGS}"
-   CFLAGS="${CFLAGS} -Wall -W"
-   AC_COMPILE_IFELSE(
-      [AC_LANG_PROGRAM([[]])],
-      [have_Wall="yes"],
-      [have_Wall="no"])
-   AC_MSG_CHECKING([whether the compiler supports -Wall])
-   AC_MSG_RESULT([${have_Wall}])
-   CFLAGS="${CFLAGS_save}"
-   if test "x${have_Wall}" = "xyes" ; then
-      EINA_CFLAGS="${EINA_CFLAGS} -Wall -W" # -Werror
-   fi
+   EFL_COMPILER_FLAG([-Wall])
+   EFL_COMPILER_FLAG([-W])
 fi
 
-CFLAGS_save="${CFLAGS}"
-CFLAGS="${CFLAGS} -fno-strict-aliasing"
-AC_COMPILE_IFELSE(
-   [AC_LANG_PROGRAM([[]])],
-   [have_no_strict_aliasing="yes"],
-   [have_no_strict_aliasing="no"])
-AC_MSG_CHECKING([whether the compiler supports -fno-strict-aliasing])
-AC_MSG_RESULT([${have_no_strict_aliasing}])
-CFLAGS="${CFLAGS_save}"
-if test "x${have_no_strict_aliasing}" = "xyes" ; then
-   EINA_CFLAGS="${EINA_CFLAGS} -fno-strict-aliasing"
-fi
+EFL_COMPILER_FLAG([-Wshadow])
+EFL_COMPILER_FLAG([-fno-strict-aliasing])
 
 AC_SUBST(EINA_CPPFLAGS)
 AC_SUBST(EINA_CFLAGS)
diff --git a/m4/efl_compiler_flag.m4 b/m4/efl_compiler_flag.m4
new file mode 100644 (file)
index 0000000..e3fc821
--- /dev/null
@@ -0,0 +1,24 @@
+dnl Checks if a given compiler switch is supported.
+dnl If so, this macro adds the flag to the CFLAGS
+
+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])
+
+])