aboutsummaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-18 15:25:00 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-18 15:25:00 +0000
commit331f3583c78d836740a2d6694be949d8af287665 (patch)
tree10a19bcd981cc84894a96097e414305845a0123a /m4
parentab07b8bd5f653034bbba558d4b6c035592c48265 (diff)
downloadefl-331f3583c78d836740a2d6694be949d8af287665.tar.gz
efl-331f3583c78d836740a2d6694be949d8af287665.tar.xz
efl-331f3583c78d836740a2d6694be949d8af287665.zip
optimize check for compiler and linker flags.
do it once with all flags and just test individual if fails. Saves dozen of compiler/linker runs. SVN revision: 82983
Diffstat (limited to 'm4')
-rw-r--r--m4/efl_compiler.m480
1 files changed, 36 insertions, 44 deletions
diff --git a/m4/efl_compiler.m4 b/m4/efl_compiler.m4
index 6b98390e5..32819f26c 100644
--- a/m4/efl_compiler.m4
+++ b/m4/efl_compiler.m4
@@ -6,93 +6,85 @@ dnl Macro that check if compiler of linker flags are available
dnl Macro that checks for a compiler flag availability
dnl
-dnl EFL_CHECK_COMPILER_FLAG(EFL, FLAG[, ACTION-IF-FOUND[ ,ACTION-IF-NOT-FOUND]])
+dnl _EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS)
dnl AC_SUBST : EFL_CFLAGS (EFL being replaced by its value)
-
-AC_DEFUN([EFL_CHECK_COMPILER_FLAG],
-[
-m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))
-m4_pushdef([UP], m4_translit([[$2]], [-a-z], [_A-Z]))
+dnl have_flag: yes or no.
+AC_DEFUN([_EFL_CHECK_COMPILER_FLAGS],
+[dnl
+m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
dnl store in options -Wfoo if -Wno-foo is passed
-option=m4_bpatsubst([[$2]], [-Wno-], [-W])
-
+option="m4_bpatsubst([[$2]], [-Wno-], [-W])"
CFLAGS_save="${CFLAGS}"
CFLAGS="${CFLAGS} ${option}"
-
AC_LANG_PUSH([C])
-AC_MSG_CHECKING([whether the compiler supports $2])
+AC_MSG_CHECKING([whether the compiler supports $2])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]])],
[have_flag="yes"],
[have_flag="no"])
AC_MSG_RESULT([${have_flag}])
-CFLAGS="${CFLAGS_save}"
AC_LANG_POP([C])
-
+CFLAGS="${CFLAGS_save}"
if test "x${have_flag}" = "xyes" ; then
UPEFL[_CFLAGS]="${UPEFL[_CFLAGS]} [$2]"
fi
-AC_ARG_VAR(UPEFL[_CFLAGS], [preprocessor flags for $2])
-AC_SUBST(UPEFL[_CFLAGS])
-
-m4_popdef([UP])
-m4_popdef([UPEFL])
+AC_SUBST(UPEFL[_CFLAGS])dnl
+m4_popdef([UPEFL])dnl
])
-dnl Macro that iterates over a sequence of white separated flags
-dnl and that call EFL_CHECK_COMPILER_FLAG() for each of these flags
-dnl
dnl EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS)
-
+dnl Checks if FLAGS are supported and add to EFL_CLFAGS.
+dnl
+dnl It will first try every flag at once, if one fails will try them one by one.
AC_DEFUN([EFL_CHECK_COMPILER_FLAGS],
-[
-m4_foreach_w([flag], [$2], [EFL_CHECK_COMPILER_FLAG([$1], m4_defn([flag]))])
+[dnl
+_EFL_CHECK_COMPILER_FLAGS([$1], [$2])
+if test "${have_flag}" != "yes"; then
+m4_foreach_w([flag], [$2], [_EFL_CHECK_COMPILER_FLAGS([$1], m4_defn([flag]))])
+fi
])
dnl Macro that checks for a linker flag availability
dnl
-dnl EFL_CHECK_LINKER_FLAG(EFL, FLAG[, ACTION-IF-FOUND[ ,ACTION-IF-NOT-FOUND]])
+dnl _EFL_CHECK_LINKER_FLAGS(EFL, FLAGS)
dnl AC_SUBST : EFL_LDFLAGS (EFL being replaced by its value)
-
-AC_DEFUN([EFL_CHECK_LINKER_FLAG],
-[
-m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))
-m4_pushdef([UP], m4_translit([[$2]], [,-a-z], [__A-Z]))
+dnl have_flag: yes or no
+AC_DEFUN([_EFL_CHECK_LINKER_FLAGS],
+[dnl
+m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
LDFLAGS_save="${LDFLAGS}"
LDFLAGS="${LDFLAGS} $2"
-
AC_LANG_PUSH([C])
-AC_MSG_CHECKING([whether the linker supports $2])
+AC_MSG_CHECKING([whether the linker supports $2])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[]])],
[have_flag="yes"],
[have_flag="no"])
AC_MSG_RESULT([${have_flag}])
-LDFLAGS="${LDFLAGS_save}"
AC_LANG_POP([C])
-
+LDFLAGS="${LDFLAGS_save}"
if test "x${have_flag}" = "xyes" ; then
UPEFL[_LDFLAGS]="${UPEFL[_LDFLAGS]} [$2]"
fi
-AC_SUBST(UPEFL[_LDFLAGS])
-
-m4_popdef([UP])
-m4_popdef([UPEFL])
+AC_SUBST(UPEFL[_LDFLAGS])dnl
+m4_popdef([UPEFL])dnl
])
-dnl Macro that iterates over a sequence of white separated flags
-dnl and that call EFL_CHECK_LINKER_FLAG() for each of these flags
-dnl
dnl EFL_CHECK_LINKER_FLAGS(EFL, FLAGS)
-
+dnl Checks if FLAGS are supported and add to EFL_CLFAGS.
+dnl
+dnl It will first try every flag at once, if one fails will try them one by one.
AC_DEFUN([EFL_CHECK_LINKER_FLAGS],
-[
-m4_foreach_w([flag], [$2], [EFL_CHECK_LINKER_FLAG([$1], m4_defn([flag]))])
-])
+[dnl
+_EFL_CHECK_LINKER_FLAGS([$1], [$2])
+if test "${have_flag}" != "yes"; then
+m4_foreach_w([flag], [$2], [_EFL_CHECK_LINKER_FLAGS([$1], m4_defn([flag]))])
+fi
+])dnl