Debian Codegraph @

libs/zziplib/zziplib-src/m4/ax_cflags_gcc_option.m4

raw
1 dnl /usr/share/aclocal/guidod-cvs/ax_cflags_gcc_option.m4
2 dnl @synopsis AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]])
3 dnl
4 dnl AX_CFLAGS_GCC_OPTION(-fvomit-frame) would show a message as like
5 dnl "checking CFLAGS for gcc -fvomit-frame ... yes" and adds the
6 dnl optionflag to CFLAGS if it is understood. You can override the
7 dnl shellvar-default of CFLAGS of course. The order of arguments stems
8 dnl from the explicit macros like AX_CFLAGS_WARN_ALL.
9 dnl
10 dnl The cousin AX_CXXFLAGS_GCC_OPTION would check for an option to add
11 dnl to CXXFLAGS - and it uses the autoconf setup for C++ instead of C
12 dnl (since it is possible to use different compilers for C and C++).
13 dnl
14 dnl The macro is a lot simpler than any special AX_CFLAGS_* macro (or
15 dnl ac_cxx_rtti.m4 macro) but allows to check for arbitrary options.
16 dnl However, if you use this macro in a few places, it would be great
17 dnl if you would make up a new function-macro and submit it to the
18 dnl ac-archive.
19 dnl
20 dnl - $1 option-to-check-for : required ("-option" as non-value)
21 dnl - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case)
22 dnl - $3 action-if-found : add value to shellvariable
23 dnl - $4 action-if-not-found : nothing
24 dnl
25 dnl note: in earlier versions, $1-$2 were swapped. We try to detect the
26 dnl situation and accept a $2=~/-/ as being the old
27 dnl option-to-check-for.
28 dnl
29 dnl also: there are other variants that emerged from the original macro
30 dnl variant which did just test an option to be possibly added.
31 dnl However, some compilers accept an option silently, or possibly for
32 dnl just another option that was not intended. Therefore, we have to do
33 dnl a generic test for a compiler family. For gcc we check "-pedantic"
34 dnl being accepted which is also understood by compilers who just want
35 dnl to be compatible with gcc even when not being made from gcc
36 dnl sources.
37 dnl
38 dnl see also:
39 dnl
40 dnl AX_CFLAGS_SUN_OPTION AX_CFLAGS_HPUX_OPTION
41 dnl AX_CFLAGS_AIX_OPTION AX_CFLAGS_IRIX_OPTION
42 dnl
43 dnl @category C
44 dnl @author Guido U. Draheim <[email protected]>
45 dnl @version 2006-12-12
46 dnl @license GPLWithACException
47
48 AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl
49 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
50 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl
51 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
52 VAR,[VAR="no, unknown"
53 AC_LANG_SAVE
54 AC_LANG_C
55 ac_save_[]FLAGS="$[]FLAGS"
56 for ac_arg dnl
57 in "-pedantic -Werror % m4_ifval($2,$2,-option)" dnl GCC
58 "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete" dnl new GCC
59 #
60 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
61 AC_TRY_COMPILE([],[return 0;],
62 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
63 done
64 FLAGS="$ac_save_[]FLAGS"
65 AC_LANG_RESTORE
66 ])
67 case ".$VAR" in
68 .ok|.ok,*) m4_ifvaln($3,$3) ;;
69 .|.no|.no,*) m4_ifvaln($4,$4) ;;
70 *) m4_ifvaln($3,$3,[
71 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
72 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
73 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
74 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
75 fi ]) ;;
76 esac
77 AS_VAR_POPDEF([VAR])dnl
78 AS_VAR_POPDEF([FLAGS])dnl
79 ])
80
81
82 dnl the only difference - the LANG selection... and the default FLAGS
83
84 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl
85 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
86 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl
87 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
88 VAR,[VAR="no, unknown"
89 AC_LANG_SAVE
90 AC_LANG_CPLUSPLUS
91 ac_save_[]FLAGS="$[]FLAGS"
92 for ac_arg dnl
93 in "-pedantic -Werror % m4_ifval($2,$2,-option)" dnl GCC
94 "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete" dnl new GCC
95 #
96 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
97 AC_TRY_COMPILE([],[return 0;],
98 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
99 done
100 FLAGS="$ac_save_[]FLAGS"
101 AC_LANG_RESTORE
102 ])
103 case ".$VAR" in
104 .ok|.ok,*) m4_ifvaln($3,$3) ;;
105 .|.no|.no,*) m4_ifvaln($4,$4) ;;
106 *) m4_ifvaln($3,$3,[
107 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
108 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
109 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
110 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
111 fi ]) ;;
112 esac
113 AS_VAR_POPDEF([VAR])dnl
114 AS_VAR_POPDEF([FLAGS])dnl
115 ])
116
117 dnl -------------------------------------------------------------------------
118
119 AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
120 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
121 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl
122 AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
123 VAR,[VAR="no, unknown"
124 AC_LANG_SAVE
125 AC_LANG_C
126 ac_save_[]FLAGS="$[]FLAGS"
127 for ac_arg dnl
128 in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC
129 "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC
130 #
131 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
132 AC_TRY_COMPILE([],[return 0;],
133 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
134 done
135 FLAGS="$ac_save_[]FLAGS"
136 AC_LANG_RESTORE
137 ])
138 case ".$VAR" in
139 .ok|.ok,*) m4_ifvaln($3,$3) ;;
140 .|.no|.no,*) m4_ifvaln($4,$4) ;;
141 *) m4_ifvaln($3,$3,[
142 if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
143 then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
144 else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
145 m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
146 fi ]) ;;
147 esac
148 AS_VAR_POPDEF([VAR])dnl
149 AS_VAR_POPDEF([FLAGS])dnl
150 ])
151
152
153 dnl the only difference - the LANG selection... and the default FLAGS
154
155 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl
156 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
157 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl
158 AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
159 VAR,[VAR="no, unknown"
160 AC_LANG_SAVE
161 AC_LANG_CPLUSPLUS
162 ac_save_[]FLAGS="$[]FLAGS"
163 for ac_arg dnl
164 in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC
165 "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC
166 #
167 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
168 AC_TRY_COMPILE([],[return 0;],
169 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
170 done
171 FLAGS="$ac_save_[]FLAGS"
172 AC_LANG_RESTORE
173 ])
174 case ".$VAR" in
175 .ok|.ok,*) m4_ifvaln($3,$3) ;;
176 .|.no|.no,*) m4_ifvaln($4,$4) ;;
177 *) m4_ifvaln($3,$3,[
178 if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
179 then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
180 else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
181 m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
182 fi ]) ;;
183 esac
184 AS_VAR_POPDEF([VAR])dnl
185 AS_VAR_POPDEF([FLAGS])dnl
186 ])
187
188 AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
189 [AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
190
191 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
192 [AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])])
193