~ubuntu-branches/ubuntu/maverick/uim/maverick

« back to all changes in this revision

Viewing changes to sigscheme/m4/ax_cflags_gcc_option.m4

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2008-06-25 19:56:33 UTC
  • mfrom: (3.1.18 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080625195633-8jljph4rfq00l8o7
Tags: 1:1.5.1-2
* uim-tcode: provide tutcode-custom.scm, tutcode-bushudic.scm
  and tutcode-rule.scm (Closes: #482659)
* Fix FTBFS: segv during compile (Closes: #483078).
  I personally think this bug is not specific for uim but is a optimization
  problem on gcc-4.3.1. (https://bugs.freedesktop.org/show_bug.cgi?id=16477)

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-10-13
 
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  % m4_ifval($2,$2,-option)"  dnl   GCC
 
96
   #
 
97
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
 
98
   AC_TRY_COMPILE([],[return 0;],
 
99
   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
 
100
done
 
101
 FLAGS="$ac_save_[]FLAGS"
 
102
 AC_LANG_RESTORE
 
103
])
 
104
case ".$VAR" in
 
105
     .ok|.ok,*) m4_ifvaln($3,$3) ;;
 
106
   .|.no|.no,*) m4_ifvaln($4,$4) ;;
 
107
   *) m4_ifvaln($3,$3,[
 
108
   if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
 
109
   then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
 
110
   else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
 
111
                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
 
112
   fi ]) ;;
 
113
esac
 
114
AS_VAR_POPDEF([VAR])dnl
 
115
AS_VAR_POPDEF([FLAGS])dnl
 
116
])
 
117
 
 
118
 
 
119
dnl the only difference - the LANG selection... and the default FLAGS
 
120
 
 
121
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl
 
122
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
 
123
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl
 
124
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
 
125
VAR,[VAR="no, unknown"
 
126
 AC_LANG_SAVE
 
127
 AC_LANG_CXX
 
128
 ac_save_[]FLAGS="$[]FLAGS"
 
129
for ac_arg dnl
 
130
in "-pedantic  % m4_ifval($2,$2,-option)"  dnl   GCC
 
131
   #
 
132
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
 
133
   AC_TRY_COMPILE([],[return 0;],
 
134
   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
 
135
done
 
136
 FLAGS="$ac_save_[]FLAGS"
 
137
 AC_LANG_RESTORE
 
138
])
 
139
case ".$VAR" in
 
140
     .ok|.ok,*) m4_ifvaln($3,$3) ;;
 
141
   .|.no|.no,*) m4_ifvaln($4,$4) ;;
 
142
   *) m4_ifvaln($3,$3,[
 
143
   if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
 
144
   then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
 
145
   else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
 
146
                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
 
147
   fi ]) ;;
 
148
esac
 
149
AS_VAR_POPDEF([VAR])dnl
 
150
AS_VAR_POPDEF([FLAGS])dnl
 
151
])
 
152
 
 
153
dnl -------------------------------------------------------------------------
 
154
 
 
155
AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
 
156
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
 
157
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_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_C
 
162
 ac_save_[]FLAGS="$[]FLAGS"
 
163
for ac_arg dnl
 
164
in "-pedantic  % m4_ifval($1,$1,-option)"  dnl   GCC
 
165
   #
 
166
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
 
167
   AC_TRY_COMPILE([],[return 0;],
 
168
   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
 
169
done
 
170
 FLAGS="$ac_save_[]FLAGS"
 
171
 AC_LANG_RESTORE
 
172
])
 
173
case ".$VAR" in
 
174
     .ok|.ok,*) m4_ifvaln($3,$3) ;;
 
175
   .|.no|.no,*) m4_ifvaln($4,$4) ;;
 
176
   *) m4_ifvaln($3,$3,[
 
177
   if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
 
178
   then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
 
179
   else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
 
180
                      m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
 
181
   fi ]) ;;
 
182
esac
 
183
AS_VAR_POPDEF([VAR])dnl
 
184
AS_VAR_POPDEF([FLAGS])dnl
 
185
])
 
186
 
 
187
 
 
188
dnl the only difference - the LANG selection... and the default FLAGS
 
189
 
 
190
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl
 
191
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
 
192
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl
 
193
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
 
194
VAR,[VAR="no, unknown"
 
195
 AC_LANG_SAVE
 
196
 AC_LANG_CXX
 
197
 ac_save_[]FLAGS="$[]FLAGS"
 
198
for ac_arg dnl
 
199
in "-pedantic  % m4_ifval($1,$1,-option)"  dnl   GCC
 
200
   #
 
201
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
 
202
   AC_TRY_COMPILE([],[return 0;],
 
203
   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
 
204
done
 
205
 FLAGS="$ac_save_[]FLAGS"
 
206
 AC_LANG_RESTORE
 
207
])
 
208
case ".$VAR" in
 
209
     .ok|.ok,*) m4_ifvaln($3,$3) ;;
 
210
   .|.no|.no,*) m4_ifvaln($4,$4) ;;
 
211
   *) m4_ifvaln($3,$3,[
 
212
   if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
 
213
   then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
 
214
   else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
 
215
                      m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
 
216
   fi ]) ;;
 
217
esac
 
218
AS_VAR_POPDEF([VAR])dnl
 
219
AS_VAR_POPDEF([FLAGS])dnl
 
220
])
 
221
 
 
222
AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
 
223
[AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
 
224
 
 
225
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
 
226
[AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])])