summaryrefslogtreecommitdiff
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)
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 6b98390..32819f2 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
6 6
7dnl Macro that checks for a compiler flag availability 7dnl Macro that checks for a compiler flag availability
8dnl 8dnl
9dnl EFL_CHECK_COMPILER_FLAG(EFL, FLAG[, ACTION-IF-FOUND[ ,ACTION-IF-NOT-FOUND]]) 9dnl _EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS)
10dnl AC_SUBST : EFL_CFLAGS (EFL being replaced by its value) 10dnl AC_SUBST : EFL_CFLAGS (EFL being replaced by its value)
11 11dnl have_flag: yes or no.
12AC_DEFUN([EFL_CHECK_COMPILER_FLAG], 12AC_DEFUN([_EFL_CHECK_COMPILER_FLAGS],
13[ 13[dnl
14m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z])) 14m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
15m4_pushdef([UP], m4_translit([[$2]], [-a-z], [_A-Z]))
16 15
17dnl store in options -Wfoo if -Wno-foo is passed 16dnl store in options -Wfoo if -Wno-foo is passed
18option=m4_bpatsubst([[$2]], [-Wno-], [-W]) 17option="m4_bpatsubst([[$2]], [-Wno-], [-W])"
19
20CFLAGS_save="${CFLAGS}" 18CFLAGS_save="${CFLAGS}"
21CFLAGS="${CFLAGS} ${option}" 19CFLAGS="${CFLAGS} ${option}"
22
23AC_LANG_PUSH([C]) 20AC_LANG_PUSH([C])
24AC_MSG_CHECKING([whether the compiler supports $2])
25 21
22AC_MSG_CHECKING([whether the compiler supports $2])
26AC_COMPILE_IFELSE( 23AC_COMPILE_IFELSE(
27 [AC_LANG_PROGRAM([[]])], 24 [AC_LANG_PROGRAM([[]])],
28 [have_flag="yes"], 25 [have_flag="yes"],
29 [have_flag="no"]) 26 [have_flag="no"])
30AC_MSG_RESULT([${have_flag}]) 27AC_MSG_RESULT([${have_flag}])
31 28
32CFLAGS="${CFLAGS_save}"
33AC_LANG_POP([C]) 29AC_LANG_POP([C])
34 30CFLAGS="${CFLAGS_save}"
35if test "x${have_flag}" = "xyes" ; then 31if test "x${have_flag}" = "xyes" ; then
36 UPEFL[_CFLAGS]="${UPEFL[_CFLAGS]} [$2]" 32 UPEFL[_CFLAGS]="${UPEFL[_CFLAGS]} [$2]"
37fi 33fi
38AC_ARG_VAR(UPEFL[_CFLAGS], [preprocessor flags for $2]) 34AC_SUBST(UPEFL[_CFLAGS])dnl
39AC_SUBST(UPEFL[_CFLAGS]) 35m4_popdef([UPEFL])dnl
40
41m4_popdef([UP])
42m4_popdef([UPEFL])
43]) 36])
44 37
45dnl Macro that iterates over a sequence of white separated flags
46dnl and that call EFL_CHECK_COMPILER_FLAG() for each of these flags
47dnl
48dnl EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS) 38dnl EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS)
49 39dnl Checks if FLAGS are supported and add to EFL_CLFAGS.
40dnl
41dnl It will first try every flag at once, if one fails will try them one by one.
50AC_DEFUN([EFL_CHECK_COMPILER_FLAGS], 42AC_DEFUN([EFL_CHECK_COMPILER_FLAGS],
51[ 43[dnl
52m4_foreach_w([flag], [$2], [EFL_CHECK_COMPILER_FLAG([$1], m4_defn([flag]))]) 44_EFL_CHECK_COMPILER_FLAGS([$1], [$2])
45if test "${have_flag}" != "yes"; then
46m4_foreach_w([flag], [$2], [_EFL_CHECK_COMPILER_FLAGS([$1], m4_defn([flag]))])
47fi
53]) 48])
54 49
55 50
56dnl Macro that checks for a linker flag availability 51dnl Macro that checks for a linker flag availability
57dnl 52dnl
58dnl EFL_CHECK_LINKER_FLAG(EFL, FLAG[, ACTION-IF-FOUND[ ,ACTION-IF-NOT-FOUND]]) 53dnl _EFL_CHECK_LINKER_FLAGS(EFL, FLAGS)
59dnl AC_SUBST : EFL_LDFLAGS (EFL being replaced by its value) 54dnl AC_SUBST : EFL_LDFLAGS (EFL being replaced by its value)
60 55dnl have_flag: yes or no
61AC_DEFUN([EFL_CHECK_LINKER_FLAG], 56AC_DEFUN([_EFL_CHECK_LINKER_FLAGS],
62[ 57[dnl
63m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z])) 58m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
64m4_pushdef([UP], m4_translit([[$2]], [,-a-z], [__A-Z]))
65 59
66LDFLAGS_save="${LDFLAGS}" 60LDFLAGS_save="${LDFLAGS}"
67LDFLAGS="${LDFLAGS} $2" 61LDFLAGS="${LDFLAGS} $2"
68
69AC_LANG_PUSH([C]) 62AC_LANG_PUSH([C])
70AC_MSG_CHECKING([whether the linker supports $2])
71 63
64AC_MSG_CHECKING([whether the linker supports $2])
72AC_LINK_IFELSE( 65AC_LINK_IFELSE(
73 [AC_LANG_PROGRAM([[]])], 66 [AC_LANG_PROGRAM([[]])],
74 [have_flag="yes"], 67 [have_flag="yes"],
75 [have_flag="no"]) 68 [have_flag="no"])
76AC_MSG_RESULT([${have_flag}]) 69AC_MSG_RESULT([${have_flag}])
77 70
78LDFLAGS="${LDFLAGS_save}"
79AC_LANG_POP([C]) 71AC_LANG_POP([C])
80 72LDFLAGS="${LDFLAGS_save}"
81if test "x${have_flag}" = "xyes" ; then 73if test "x${have_flag}" = "xyes" ; then
82 UPEFL[_LDFLAGS]="${UPEFL[_LDFLAGS]} [$2]" 74 UPEFL[_LDFLAGS]="${UPEFL[_LDFLAGS]} [$2]"
83fi 75fi
84AC_SUBST(UPEFL[_LDFLAGS]) 76AC_SUBST(UPEFL[_LDFLAGS])dnl
85 77m4_popdef([UPEFL])dnl
86m4_popdef([UP])
87m4_popdef([UPEFL])
88]) 78])
89 79
90dnl Macro that iterates over a sequence of white separated flags
91dnl and that call EFL_CHECK_LINKER_FLAG() for each of these flags
92dnl
93dnl EFL_CHECK_LINKER_FLAGS(EFL, FLAGS) 80dnl EFL_CHECK_LINKER_FLAGS(EFL, FLAGS)
94 81dnl Checks if FLAGS are supported and add to EFL_CLFAGS.
82dnl
83dnl It will first try every flag at once, if one fails will try them one by one.
95AC_DEFUN([EFL_CHECK_LINKER_FLAGS], 84AC_DEFUN([EFL_CHECK_LINKER_FLAGS],
96[ 85[dnl
97m4_foreach_w([flag], [$2], [EFL_CHECK_LINKER_FLAG([$1], m4_defn([flag]))]) 86_EFL_CHECK_LINKER_FLAGS([$1], [$2])
98]) 87if test "${have_flag}" != "yes"; then
88m4_foreach_w([flag], [$2], [_EFL_CHECK_LINKER_FLAGS([$1], m4_defn([flag]))])
89fi
90])dnl