1 | dnl @synopsis AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]])
|
---|
2 | dnl
|
---|
3 | dnl AX_CFLAGS_GCC_OPTION(-fvomit-frame) would show a message as like
|
---|
4 | dnl "checking CFLAGS for gcc -fvomit-frame ... yes" and adds
|
---|
5 | dnl the optionflag to CFLAGS if it is understood. You can override
|
---|
6 | dnl the shellvar-default of CFLAGS of course. The order of arguments
|
---|
7 | dnl stems from the explicit macros like AX_CFLAGS_WARN_ALL.
|
---|
8 | dnl
|
---|
9 | dnl The macro is a lot simpler than any special AX_CFLAGS_* macro (or
|
---|
10 | dnl ac_cxx_rtti.m4 macro) but allows to check for arbitrary options.
|
---|
11 | dnl However, if you use this macro in a few places, it would be great
|
---|
12 | dnl if you would make up a new function-macro and submit it to the
|
---|
13 | dnl ac-archive.
|
---|
14 | dnl
|
---|
15 | dnl - $1 option-to-check-for : required ("-option" as non-value)
|
---|
16 | dnl - $2 shell-variable-to-add-to : CFLAGS
|
---|
17 | dnl - $3 action-if-found : add value to shellvariable
|
---|
18 | dnl - $4 action-if-not-found : nothing
|
---|
19 | dnl
|
---|
20 | dnl note: in earlier versions, $1-$2 were swapped. We try to detect the
|
---|
21 | dnl situation and accept a $2=~/-/ as being the old option-to-check-for.
|
---|
22 | dnl
|
---|
23 | dnl also: there are other variants that emerged from the original macro
|
---|
24 | dnl variant which did just test an option to be possibly added. However,
|
---|
25 | dnl some compilers accept an option silently, or possibly for just
|
---|
26 | dnl another option that was not intended. Therefore, we have to do a
|
---|
27 | dnl generic test for a compiler family. For gcc we check "-pedantic"
|
---|
28 | dnl being accepted which is also understood by compilers who just want
|
---|
29 | dnl to be compatible with gcc even when not being made from gcc sources.
|
---|
30 | dnl
|
---|
31 | dnl see also:
|
---|
32 | dnl AX_CFLAGS_SUN_OPTION AX_CFLAGS_HPUX_OPTION
|
---|
33 | dnl AX_CFLAGS_AIX_OPTION AX_CFLAGS_IRIX_OPTION
|
---|
34 | dnl
|
---|
35 | dnl @, tested, experimental
|
---|
36 | dnl @version $Id: ax_cflags_gcc_option.m4,v 1.5 2003/11/29 08:13:25 guidod Exp $
|
---|
37 | dnl @author Guido Draheim <guidod@gmx.de>
|
---|
38 | dnl http://ac-archive.sourceforge.net/C_Support/ax_cflags_gcc_option.m4
|
---|
39 | dnl
|
---|
40 | AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl
|
---|
41 | AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
---|
42 | AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl
|
---|
43 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
|
---|
44 | VAR,[VAR="no, unknown"
|
---|
45 | AC_LANG_SAVE
|
---|
46 | AC_LANG_C
|
---|
47 | ac_save_[]FLAGS="$[]FLAGS"
|
---|
48 | for ac_arg dnl
|
---|
49 | in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC
|
---|
50 | #
|
---|
51 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
---|
52 | AC_TRY_COMPILE([],[return 0;],
|
---|
53 | [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
---|
54 | done
|
---|
55 | FLAGS="$ac_save_[]FLAGS"
|
---|
56 | AC_LANG_RESTORE
|
---|
57 | ])
|
---|
58 | case ".$VAR" in
|
---|
59 | .ok|.ok,*) m4_ifvaln($3,$3) ;;
|
---|
60 | .|.no|.no,*) m4_ifvaln($4,$4) ;;
|
---|
61 | *) m4_ifvaln($3,$3,[
|
---|
62 | if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
---|
63 | then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
---|
64 | else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
---|
65 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
---|
66 | fi ]) ;;
|
---|
67 | esac
|
---|
68 | AS_VAR_POPDEF([VAR])dnl
|
---|
69 | AS_VAR_POPDEF([FLAGS])dnl
|
---|
70 | ])
|
---|
71 |
|
---|
72 |
|
---|
73 | dnl -------------------------------------------------------------------------
|
---|
74 |
|
---|
75 | AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
|
---|
76 | AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
---|
77 | AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl
|
---|
78 | AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
|
---|
79 | VAR,[VAR="no, unknown"
|
---|
80 | AC_LANG_SAVE
|
---|
81 | AC_LANG_C
|
---|
82 | ac_save_[]FLAGS="$[]FLAGS"
|
---|
83 | for ac_arg dnl
|
---|
84 | in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC
|
---|
85 | #
|
---|
86 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
---|
87 | AC_TRY_COMPILE([],[return 0;],
|
---|
88 | [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
---|
89 | done
|
---|
90 | FLAGS="$ac_save_[]FLAGS"
|
---|
91 | AC_LANG_RESTORE
|
---|
92 | ])
|
---|
93 | case ".$VAR" in
|
---|
94 | .ok|.ok,*) m4_ifvaln($3,$3) ;;
|
---|
95 | .|.no|.no,*) m4_ifvaln($4,$4) ;;
|
---|
96 | *) m4_ifvaln($3,$3,[
|
---|
97 | if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
---|
98 | then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
|
---|
99 | else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
|
---|
100 | m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
|
---|
101 | fi ]) ;;
|
---|
102 | esac
|
---|
103 | AS_VAR_POPDEF([VAR])dnl
|
---|
104 | AS_VAR_POPDEF([FLAGS])dnl
|
---|
105 | ])
|
---|
106 |
|
---|
107 |
|
---|
108 | AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
|
---|
109 | [AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
|
---|