gdb: Add maint set ignore-prologue-end-flag
[binutils-gdb.git] / gdb / acinclude.m4
1 dnl written by Rob Savoye <rob@cygnus.com> for Cygnus Support
2 dnl major rewriting for Tcl 7.5 by Don Libes <libes@nist.gov>
3
4 # Keep these includes in sync with the aclocal_m4_deps list in
5 # Makefile.in.
6
7 dnl NB: When possible, try to avoid explicit includes of ../config/ files.
8 dnl They're normally found by aclocal automatically and recorded in aclocal.m4.
9 dnl However, some are kept here explicitly to silence harmless warnings from
10 dnl aclocal when it finds AM_xxx macros via local search paths instead of
11 dnl system search paths.
12
13 m4_include(acx_configure_dir.m4)
14
15 # This gets GDB_AC_TRANSFORM.
16 m4_include(transform.m4)
17
18 # This get AM_GDB_COMPILER_TYPE.
19 m4_include(../gdbsupport/compiler-type.m4)
20
21 # This gets AM_GDB_WARNINGS.
22 m4_include(../gdbsupport/warning.m4)
23
24 # AM_GDB_UBSAN
25 m4_include(sanitize.m4)
26
27 # This gets GDB_AC_SELFTEST.
28 m4_include(../gdbsupport/selftest.m4)
29
30 dnl gdb/configure.in uses BFD_NEED_DECLARATION, so get its definition.
31 m4_include(../bfd/bfd.m4)
32
33 dnl For AM_LC_MESSAGES
34 m4_include([../config/lcmessage.m4])
35
36 dnl For AM_LANGINFO_CODESET.
37 m4_include([../config/codeset.m4])
38
39 dnl We need to explicitly include these before iconv.m4 to avoid warnings.
40 m4_include([../config/lib-ld.m4])
41 m4_include([../config/lib-prefix.m4])
42 m4_include([../config/lib-link.m4])
43 m4_include([../config/iconv.m4])
44
45 m4_include([../config/zlib.m4])
46
47 m4_include([../gdbsupport/common.m4])
48
49 dnl For libiberty_INIT.
50 m4_include(libiberty.m4)
51
52 dnl For GDB_AC_PTRACE.
53 m4_include(../gdbsupport/ptrace.m4)
54
55 m4_include(ax_cxx_compile_stdcxx.m4)
56
57 dnl written by Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva
58 dnl Version 1.3 (2001/03/02)
59 dnl source http://www.gnu.org/software/ac-archive/Miscellaneous/ac_define_dir.html
60
61 AC_DEFUN([AC_DEFINE_DIR], [
62 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
63 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
64 ac_define_dir=`eval echo [$]$2`
65 ac_define_dir=`eval echo [$]ac_define_dir`
66 ifelse($3, ,
67 AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
68 AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
69 ])
70
71 dnl See whether we need a declaration for a function.
72 dnl The result is highly dependent on the INCLUDES passed in, so make sure
73 dnl to use a different cache variable name in this macro if it is invoked
74 dnl in a different context somewhere else.
75 dnl gcc_AC_CHECK_DECL(SYMBOL,
76 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
77 AC_DEFUN(
78 [gcc_AC_CHECK_DECL],
79 [AC_MSG_CHECKING([whether $1 is declared])
80 AC_CACHE_VAL(
81 [gcc_cv_have_decl_$1],
82 [AC_COMPILE_IFELSE(
83 [AC_LANG_PROGRAM(
84 [$4],
85 [#ifndef $1
86 char *(*pfn) = (char *(*)) $1 ;
87 #endif]
88 )],
89 [eval "gcc_cv_have_decl_$1=yes"],
90 [eval "gcc_cv_have_decl_$1=no"]
91 )]
92 )
93 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
94 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
95 else
96 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
97 fi
98 ])dnl
99
100 dnl Check multiple functions to see whether each needs a declaration.
101 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
102 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
103 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
104 AC_DEFUN([gcc_AC_CHECK_DECLS],
105 [for ac_func in $1
106 do
107 changequote(, )dnl
108 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
109 changequote([, ])dnl
110 gcc_AC_CHECK_DECL($ac_func,
111 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
112 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
113 dnl It is possible that the include files passed in here are local headers
114 dnl which supply a backup declaration for the relevant prototype based on
115 dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
116 dnl will always return success. E.g. see libiberty.h's handling of
117 dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
118 dnl 1 so that any local headers used do not provide their own prototype
119 dnl during this test.
120 #undef $ac_tr_decl
121 #define $ac_tr_decl 1
122 $4
123 )
124 done
125 dnl Automatically generate config.h entries via autoheader.
126 if test x = y ; then
127 patsubst(translit([$1], [a-z], [A-Z]), [\w+],
128 [AC_DEFINE([HAVE_DECL_\&], 1,
129 [Define to 1 if we found this declaration otherwise define to 0.])])dnl
130 fi
131 ])
132
133 dnl Find the location of the private Tcl headers
134 dnl When Tcl is installed, this is TCL_INCLUDE_SPEC/tcl-private/generic
135 dnl When Tcl is in the build tree, this is not needed.
136 dnl
137 dnl Note: you must use first use SC_LOAD_TCLCONFIG!
138 AC_DEFUN([CY_AC_TCL_PRIVATE_HEADERS], [
139 AC_MSG_CHECKING([for Tcl private headers])
140 private_dir=""
141 dir=`echo ${TCL_INCLUDE_SPEC}/tcl-private/generic | sed -e s/-I//`
142 if test -f ${dir}/tclInt.h ; then
143 private_dir=${dir}
144 fi
145
146 if test x"${private_dir}" = x; then
147 AC_MSG_ERROR(could not find private Tcl headers)
148 else
149 TCL_PRIVATE_INCLUDE="-I${private_dir}"
150 AC_MSG_RESULT(${private_dir})
151 fi
152 ])
153
154 dnl Find the location of the private Tk headers
155 dnl When Tk is installed, this is TK_INCLUDE_SPEC/tk-private/generic
156 dnl When Tk is in the build tree, this not needed.
157 dnl
158 dnl Note: you must first use SC_LOAD_TKCONFIG
159 AC_DEFUN([CY_AC_TK_PRIVATE_HEADERS], [
160 AC_MSG_CHECKING([for Tk private headers])
161 private_dir=""
162 dir=`echo ${TK_INCLUDE_SPEC}/tk-private/generic | sed -e s/-I//`
163 if test -f ${dir}/tkInt.h; then
164 private_dir=${dir}
165 fi
166
167 if test x"${private_dir}" = x; then
168 AC_MSG_ERROR(could not find Tk private headers)
169 else
170 TK_PRIVATE_INCLUDE="-I${private_dir}"
171 AC_MSG_RESULT(${private_dir})
172 fi
173 ])
174
175 dnl GDB_AC_DEFINE_RELOCATABLE([VARIABLE], [ARG-NAME], [SHELL-VARIABLE])
176 dnl For use in processing directory values for --with-foo.
177 dnl If the path in SHELL_VARIABLE is relative to the prefix, then the
178 dnl result is relocatable, then this will define the C macro
179 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
180 AC_DEFUN([GDB_AC_DEFINE_RELOCATABLE], [
181 if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
182 if test "x$prefix" = xNONE; then
183 test_prefix=/usr/local
184 else
185 test_prefix=$prefix
186 fi
187 else
188 test_prefix=$exec_prefix
189 fi
190 value=0
191 case [$3] in
192 "${test_prefix}"|"${test_prefix}/"*|\
193 '${exec_prefix}'|'${exec_prefix}/'*)
194 value=1
195 ;;
196 esac
197 AC_DEFINE_UNQUOTED([$1]_RELOCATABLE, $value, [Define if the $2 directory should be relocated when GDB is moved.])
198 ])
199
200 dnl GDB_AC_WITH_DIR([VARIABLE], [ARG-NAME], [HELP], [DEFAULT])
201 dnl Add a new --with option that defines a directory.
202 dnl The result is stored in VARIABLE. AC_DEFINE_DIR is called
203 dnl on this variable, as is AC_SUBST.
204 dnl ARG-NAME is the base name of the argument (without "--with").
205 dnl HELP is the help text to use.
206 dnl If the user's choice is relative to the prefix, then the
207 dnl result is relocatable, then this will define the C macro
208 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
209 dnl DEFAULT is the default value, which is used if the user
210 dnl does not specify the argument.
211 AC_DEFUN([GDB_AC_WITH_DIR], [
212 AC_ARG_WITH([$2], AS_HELP_STRING([--with-][$2][=PATH], [$3]), [
213 [$1]=$withval], [[$1]=[$4]])
214 AC_DEFINE_DIR([$1], [$1], [$3])
215 AC_SUBST([$1])
216 GDB_AC_DEFINE_RELOCATABLE([$1], [$2], ${ac_define_dir})
217 ])
218
219 dnl GDB_AC_CHECK_BFD([MESSAGE], [CV], [CODE], [HEADER])
220 dnl Check whether BFD provides a feature.
221 dnl MESSAGE is the "checking" message to display.
222 dnl CV is the name of the cache variable where the result is stored.
223 dnl The result will be "yes" or "no".
224 dnl CODE is some code to compile that checks for the feature.
225 dnl A link test is run.
226 dnl HEADER is the name of an extra BFD header to include.
227 AC_DEFUN([GDB_AC_CHECK_BFD], [
228 OLD_CFLAGS=$CFLAGS
229 OLD_LDFLAGS=$LDFLAGS
230 OLD_LIBS=$LIBS
231 # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
232 # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
233 # always want our bfd.
234 CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
235 ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
236 LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
237 intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
238 LIBS="-lbfd -liberty -lz $intl $LIBS"
239 AC_CACHE_CHECK(
240 [$1],
241 [$2],
242 [AC_LINK_IFELSE(
243 [AC_LANG_PROGRAM(
244 [#include <stdlib.h>
245 #include <string.h>
246 #include "bfd.h"
247 #include "$4"],
248 [return $3;]
249 )],
250 [[$2]=yes],
251 [[$2]=no]
252 )]
253 )
254 CFLAGS=$OLD_CFLAGS
255 LDFLAGS=$OLD_LDFLAGS
256 LIBS=$OLD_LIBS])
257
258 dnl GDB_GUILE_PROGRAM_NAMES([PKG-CONFIG], [VERSION])
259 dnl
260 dnl Define and substitute 'GUILD' to contain the absolute file name of
261 dnl the 'guild' command for VERSION, using PKG-CONFIG. (This is
262 dnl similar to Guile's 'GUILE_PROGS' macro.)
263 AC_DEFUN([GDB_GUILE_PROGRAM_NAMES], [
264 AC_CACHE_CHECK([for the absolute file name of the 'guild' command],
265 [ac_cv_guild_program_name],
266 [ac_cv_guild_program_name="`$1 --variable guild $2`"
267
268 # In Guile up to 2.0.11 included, guile-2.0.pc would not define
269 # the 'guild' and 'bindir' variables. In that case, try to guess
270 # what the program name is, at the risk of getting it wrong if
271 # Guile was configured with '--program-suffix' or similar.
272 if test "x$ac_cv_guild_program_name" = "x"; then
273 guile_exec_prefix="`$1 --variable exec_prefix $2`"
274 ac_cv_guild_program_name="$guile_exec_prefix/bin/guild"
275 fi
276 ])
277
278 if ! "$ac_cv_guild_program_name" --version >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
279 AC_MSG_ERROR(['$ac_cv_guild_program_name' appears to be unusable])
280 fi
281
282 GUILD="$ac_cv_guild_program_name"
283 AC_SUBST([GUILD])
284 ])
285
286 dnl GDB_GUILD_TARGET_FLAG
287 dnl
288 dnl Compute the value of GUILD_TARGET_FLAG.
289 dnl For native builds this is empty.
290 dnl For cross builds this is --target=<host>.
291 AC_DEFUN([GDB_GUILD_TARGET_FLAG], [
292 if test "$cross_compiling" = no; then
293 GUILD_TARGET_FLAG=
294 else
295 GUILD_TARGET_FLAG="--target=$host"
296 fi
297 AC_SUBST(GUILD_TARGET_FLAG)
298 ])
299
300 dnl GDB_TRY_GUILD([SRC-FILE])
301 dnl
302 dnl We precompile the .scm files and install them with gdb, so make sure
303 dnl guild works for this host.
304 dnl The .scm files are precompiled for several reasons:
305 dnl 1) To silence Guile during gdb startup (Guile's auto-compilation output
306 dnl is unnecessarily verbose).
307 dnl 2) Make gdb developers see compilation errors/warnings during the build,
308 dnl and not leave it to later when the user runs gdb.
309 dnl 3) As a convenience for the user, so that one copy of the files is built
310 dnl instead of one copy per user.
311 dnl
312 dnl Make sure guild can handle this host by trying to compile SRC-FILE, and
313 dnl setting ac_cv_guild_ok to yes or no.
314 dnl Note that guild can handle cross-compilation.
315 dnl It could happen that guild can't handle the host, but guile would still
316 dnl work. For the time being we're conservative, and if guild doesn't work
317 dnl we punt.
318 AC_DEFUN([GDB_TRY_GUILD], [
319 AC_REQUIRE([GDB_GUILD_TARGET_FLAG])
320 AC_CACHE_CHECK([whether guild supports this host],
321 [ac_cv_guild_ok],
322 [echo "$ac_cv_guild_program_name compile $GUILD_TARGET_FLAG -o conftest.go $1" >&AS_MESSAGE_LOG_FD
323 if "$ac_cv_guild_program_name" compile $GUILD_TARGET_FLAG -o conftest.go "$1" >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
324 ac_cv_guild_ok=yes
325 else
326 ac_cv_guild_ok=no
327 fi])
328 ])