~ubuntu-branches/ubuntu/karmic/fastjar/karmic-security

« back to all changes in this revision

Viewing changes to m4/ax_cflags_gcc_option.m4

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-11-11 05:58:19 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20081111055819-y7rp49bl4rjmmlge
Tags: upstream-0.97
ImportĀ upstreamĀ versionĀ 0.97

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##### http://autoconf-archive.cryp.to/ax_cflags_gcc_option.html
 
2
#
 
3
# SYNOPSIS
 
4
#
 
5
#   AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]])
 
6
#
 
7
# DESCRIPTION
 
8
#
 
9
#   AX_CFLAGS_GCC_OPTION(-fvomit-frame) would show a message as like
 
10
#   "checking CFLAGS for gcc -fvomit-frame ... yes" and adds the
 
11
#   optionflag to CFLAGS if it is understood. You can override the
 
12
#   shellvar-default of CFLAGS of course. The order of arguments stems
 
13
#   from the explicit macros like AX_CFLAGS_WARN_ALL.
 
14
#
 
15
#   The cousin AX_CXXFLAGS_GCC_OPTION would check for an option to add
 
16
#   to CXXFLAGS - and it uses the autoconf setup for C++ instead of C
 
17
#   (since it is possible to use different compilers for C and C++).
 
18
#
 
19
#   The macro is a lot simpler than any special AX_CFLAGS_* macro (or
 
20
#   ac_cxx_rtti.m4 macro) but allows to check for arbitrary options.
 
21
#   However, if you use this macro in a few places, it would be great
 
22
#   if you would make up a new function-macro and submit it to the
 
23
#   ac-archive.
 
24
#
 
25
#     - $1 option-to-check-for : required ("-option" as non-value)
 
26
#     - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case)
 
27
#     - $3 action-if-found : add value to shellvariable
 
28
#     - $4 action-if-not-found : nothing
 
29
#
 
30
#   note: in earlier versions, $1-$2 were swapped. We try to detect the
 
31
#   situation and accept a $2=~/-/ as being the old
 
32
#   option-to-check-for.
 
33
#
 
34
#   also: there are other variants that emerged from the original macro
 
35
#   variant which did just test an option to be possibly added.
 
36
#   However, some compilers accept an option silently, or possibly for
 
37
#   just another option that was not intended. Therefore, we have to do
 
38
#   a generic test for a compiler family. For gcc we check "-pedantic"
 
39
#   being accepted which is also understood by compilers who just want
 
40
#   to be compatible with gcc even when not being made from gcc
 
41
#   sources.
 
42
#
 
43
#   see also:
 
44
#
 
45
#         AX_CFLAGS_SUN_OPTION               AX_CFLAGS_HPUX_OPTION
 
46
#         AX_CFLAGS_AIX_OPTION               AX_CFLAGS_IRIX_OPTION
 
47
#
 
48
# LAST MODIFICATION
 
49
#
 
50
#   2006-12-12
 
51
#
 
52
# COPYLEFT
 
53
#
 
54
#   Copyright (c) 2006 Guido U. Draheim <guidod@gmx.de>
 
55
#
 
56
#   This program is free software; you can redistribute it and/or
 
57
#   modify it under the terms of the GNU General Public License as
 
58
#   published by the Free Software Foundation; either version 2 of the
 
59
#   License, or (at your option) any later version.
 
60
#
 
61
#   This program is distributed in the hope that it will be useful, but
 
62
#   WITHOUT ANY WARRANTY; without even the implied warranty of
 
63
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
64
#   General Public License for more details.
 
65
#
 
66
#   You should have received a copy of the GNU General Public License
 
67
#   along with this program; if not, write to the Free Software
 
68
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
69
#   02111-1307, USA.
 
70
#
 
71
#   As a special exception, the respective Autoconf Macro's copyright
 
72
#   owner gives unlimited permission to copy, distribute and modify the
 
73
#   configure scripts that are the output of Autoconf when processing
 
74
#   the Macro. You need not follow the terms of the GNU General Public
 
75
#   License when using or distributing such scripts, even though
 
76
#   portions of the text of the Macro appear in them. The GNU General
 
77
#   Public License (GPL) does govern all other use of the material that
 
78
#   constitutes the Autoconf Macro.
 
79
#
 
80
#   This special exception to the GPL applies to versions of the
 
81
#   Autoconf Macro released by the Autoconf Macro Archive. When you
 
82
#   make and distribute a modified version of the Autoconf Macro, you
 
83
#   may extend this special exception to the GPL to apply to your
 
84
#   modified version as well.
 
85
 
 
86
AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl
 
87
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
 
88
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl
 
89
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
 
90
VAR,[VAR="no, unknown"
 
91
 AC_LANG_SAVE
 
92
 AC_LANG_C
 
93
 ac_save_[]FLAGS="$[]FLAGS"
 
94
for ac_arg dnl
 
95
in "-pedantic -Werror % m4_ifval($2,$2,-option)"  dnl   GCC
 
96
   "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete"  dnl new GCC
 
97
   #
 
98
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
 
99
   AC_TRY_COMPILE([],[return 0;],
 
100
   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
 
101
done
 
102
 FLAGS="$ac_save_[]FLAGS"
 
103
 AC_LANG_RESTORE
 
104
])
 
105
case ".$VAR" in
 
106
     .ok|.ok,*) m4_ifvaln($3,$3) ;;
 
107
   .|.no|.no,*) m4_ifvaln($4,$4) ;;
 
108
   *) m4_ifvaln($3,$3,[
 
109
   if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
 
110
   then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
 
111
   else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
 
112
                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
 
113
   fi ]) ;;
 
114
esac
 
115
AS_VAR_POPDEF([VAR])dnl
 
116
AS_VAR_POPDEF([FLAGS])dnl
 
117
])
 
118
 
 
119
 
 
120
dnl the only difference - the LANG selection... and the default FLAGS
 
121
 
 
122
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl
 
123
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
 
124
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl
 
125
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
 
126
VAR,[VAR="no, unknown"
 
127
 AC_LANG_SAVE
 
128
 AC_LANG_CPLUSPLUS
 
129
 ac_save_[]FLAGS="$[]FLAGS"
 
130
for ac_arg dnl
 
131
in "-pedantic -Werror % m4_ifval($2,$2,-option)"  dnl   GCC
 
132
   "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete"  dnl new GCC
 
133
   #
 
134
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
 
135
   AC_TRY_COMPILE([],[return 0;],
 
136
   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
 
137
done
 
138
 FLAGS="$ac_save_[]FLAGS"
 
139
 AC_LANG_RESTORE
 
140
])
 
141
case ".$VAR" in
 
142
     .ok|.ok,*) m4_ifvaln($3,$3) ;;
 
143
   .|.no|.no,*) m4_ifvaln($4,$4) ;;
 
144
   *) m4_ifvaln($3,$3,[
 
145
   if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
 
146
   then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
 
147
   else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
 
148
                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
 
149
   fi ]) ;;
 
150
esac
 
151
AS_VAR_POPDEF([VAR])dnl
 
152
AS_VAR_POPDEF([FLAGS])dnl
 
153
])
 
154
 
 
155
dnl -------------------------------------------------------------------------
 
156
 
 
157
AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
 
158
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
 
159
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl
 
160
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
 
161
VAR,[VAR="no, unknown"
 
162
 AC_LANG_SAVE
 
163
 AC_LANG_C
 
164
 ac_save_[]FLAGS="$[]FLAGS"
 
165
for ac_arg dnl
 
166
in "-pedantic -Werror % m4_ifval($1,$1,-option)"  dnl   GCC
 
167
   "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete"  dnl new GCC
 
168
   #
 
169
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
 
170
   AC_TRY_COMPILE([],[return 0;],
 
171
   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
 
172
done
 
173
 FLAGS="$ac_save_[]FLAGS"
 
174
 AC_LANG_RESTORE
 
175
])
 
176
case ".$VAR" in
 
177
     .ok|.ok,*) m4_ifvaln($3,$3) ;;
 
178
   .|.no|.no,*) m4_ifvaln($4,$4) ;;
 
179
   *) m4_ifvaln($3,$3,[
 
180
   if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
 
181
   then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
 
182
   else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
 
183
                      m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
 
184
   fi ]) ;;
 
185
esac
 
186
AS_VAR_POPDEF([VAR])dnl
 
187
AS_VAR_POPDEF([FLAGS])dnl
 
188
])
 
189
 
 
190
 
 
191
dnl the only difference - the LANG selection... and the default FLAGS
 
192
 
 
193
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl
 
194
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
 
195
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl
 
196
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
 
197
VAR,[VAR="no, unknown"
 
198
 AC_LANG_SAVE
 
199
 AC_LANG_CPLUSPLUS
 
200
 ac_save_[]FLAGS="$[]FLAGS"
 
201
for ac_arg dnl
 
202
in "-pedantic -Werror % m4_ifval($1,$1,-option)"  dnl   GCC
 
203
   "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete"  dnl new GCC
 
204
   #
 
205
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
 
206
   AC_TRY_COMPILE([],[return 0;],
 
207
   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
 
208
done
 
209
 FLAGS="$ac_save_[]FLAGS"
 
210
 AC_LANG_RESTORE
 
211
])
 
212
case ".$VAR" in
 
213
     .ok|.ok,*) m4_ifvaln($3,$3) ;;
 
214
   .|.no|.no,*) m4_ifvaln($4,$4) ;;
 
215
   *) m4_ifvaln($3,$3,[
 
216
   if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
 
217
   then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
 
218
   else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
 
219
                      m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
 
220
   fi ]) ;;
 
221
esac
 
222
AS_VAR_POPDEF([VAR])dnl
 
223
AS_VAR_POPDEF([FLAGS])dnl
 
224
])
 
225
 
 
226
AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
 
227
[AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
 
228
 
 
229
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
 
230
[AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])])