source: vendor/current/source4/build/m4/ax_cflags_gcc_option.m4@ 414

Last change on this file since 414 was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

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