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