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