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>
4 # Keep these includes in sync with the aclocal_m4_deps list in
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.
13 m4_include(acx_configure_dir.m4)
15 # This gets GDB_AC_TRANSFORM.
16 m4_include(transform.m4)
18 # This get AM_GDB_COMPILER_TYPE.
19 m4_include(../gdbsupport/compiler-type.m4)
21 # This gets AM_GDB_WARNINGS.
22 m4_include(../gdbsupport/warning.m4)
25 m4_include(sanitize.m4)
27 # This gets GDB_AC_SELFTEST.
28 m4_include(../gdbsupport/selftest.m4)
30 dnl gdb/configure.in uses BFD_NEED_DECLARATION, so get its definition.
31 m4_include(../bfd/bfd.m4)
33 dnl For AM_LC_MESSAGES
34 m4_include([../config/lcmessage.m4])
36 dnl For AM_LANGINFO_CODESET.
37 m4_include([../config/codeset.m4])
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])
45 m4_include([../config/zlib.m4])
46 m4_include([../config/zstd.m4])
48 m4_include([../gdbsupport/common.m4])
50 dnl For libiberty_INIT.
51 m4_include(../gdbsupport/libiberty.m4)
53 dnl For GDB_AC_PTRACE.
54 m4_include(../gdbsupport/ptrace.m4)
56 m4_include(ax_cxx_compile_stdcxx.m4)
58 dnl written by Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva
59 dnl Version 1.3 (2001/03/02)
60 dnl source http://www.gnu.org/software/ac-archive/Miscellaneous/ac_define_dir.html
62 AC_DEFUN([AC_DEFINE_DIR], [
63 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
64 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
65 ac_define_dir=`eval echo [$]$2`
66 ac_define_dir=`eval echo [$]ac_define_dir`
68 AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
69 AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
72 dnl See whether we need a declaration for a function.
73 dnl The result is highly dependent on the INCLUDES passed in, so make sure
74 dnl to use a different cache variable name in this macro if it is invoked
75 dnl in a different context somewhere else.
76 dnl gcc_AC_CHECK_DECL(SYMBOL,
77 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
80 [AC_MSG_CHECKING([whether $1 is declared])
82 [gcc_cv_have_decl_$1],
87 char *(*pfn) = (char *(*)) $1 ;
90 [eval "gcc_cv_have_decl_$1=yes"],
91 [eval "gcc_cv_have_decl_$1=no"]
94 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
95 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
97 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
101 dnl Check multiple functions to see whether each needs a declaration.
102 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
103 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
104 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
105 AC_DEFUN([gcc_AC_CHECK_DECLS],
109 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
111 gcc_AC_CHECK_DECL($ac_func,
112 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
113 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
114 dnl It is possible that the include files passed in here are local headers
115 dnl which supply a backup declaration for the relevant prototype based on
116 dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
117 dnl will always return success. E.g. see libiberty.h's handling of
118 dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
119 dnl 1 so that any local headers used do not provide their own prototype
120 dnl during this test.
122 #define $ac_tr_decl 1
126 dnl Automatically generate config.h entries via autoheader.
128 patsubst(translit([$1], [a-z], [A-Z]), [\w+],
129 [AC_DEFINE([HAVE_DECL_\&], 1,
130 [Define to 1 if we found this declaration otherwise define to 0.])])dnl
134 dnl Find the location of the private Tcl headers
135 dnl When Tcl is installed, this is TCL_INCLUDE_SPEC/tcl-private/generic
136 dnl When Tcl is in the build tree, this is not needed.
138 dnl Note: you must use first use SC_LOAD_TCLCONFIG!
139 AC_DEFUN([CY_AC_TCL_PRIVATE_HEADERS], [
140 AC_MSG_CHECKING([for Tcl private headers])
142 dir=`echo ${TCL_INCLUDE_SPEC}/tcl-private/generic | sed -e s/-I//`
143 if test -f ${dir}/tclInt.h ; then
147 if test x"${private_dir}" = x; then
148 AC_MSG_ERROR(could not find private Tcl headers)
150 TCL_PRIVATE_INCLUDE="-I${private_dir}"
151 AC_MSG_RESULT(${private_dir})
155 dnl Find the location of the private Tk headers
156 dnl When Tk is installed, this is TK_INCLUDE_SPEC/tk-private/generic
157 dnl When Tk is in the build tree, this not needed.
159 dnl Note: you must first use SC_LOAD_TKCONFIG
160 AC_DEFUN([CY_AC_TK_PRIVATE_HEADERS], [
161 AC_MSG_CHECKING([for Tk private headers])
163 dir=`echo ${TK_INCLUDE_SPEC}/tk-private/generic | sed -e s/-I//`
164 if test -f ${dir}/tkInt.h; then
168 if test x"${private_dir}" = x; then
169 AC_MSG_ERROR(could not find Tk private headers)
171 TK_PRIVATE_INCLUDE="-I${private_dir}"
172 AC_MSG_RESULT(${private_dir})
176 dnl GDB_AC_DEFINE_RELOCATABLE([VARIABLE], [ARG-NAME], [SHELL-VARIABLE])
177 dnl For use in processing directory values for --with-foo.
178 dnl If the path in SHELL_VARIABLE is relative to the prefix, then the
179 dnl result is relocatable, then this will define the C macro
180 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
181 AC_DEFUN([GDB_AC_DEFINE_RELOCATABLE], [
182 if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
183 if test "x$prefix" = xNONE; then
184 test_prefix=/usr/local
189 test_prefix=$exec_prefix
193 "${test_prefix}"|"${test_prefix}/"*|\
194 '${exec_prefix}'|'${exec_prefix}/'*)
198 AC_DEFINE_UNQUOTED([$1]_RELOCATABLE, $value, [Define if the $2 directory should be relocated when GDB is moved.])
201 dnl GDB_AC_WITH_DIR([VARIABLE], [ARG-NAME], [HELP], [DEFAULT])
202 dnl Add a new --with option that defines a directory.
203 dnl The result is stored in VARIABLE. AC_DEFINE_DIR is called
204 dnl on this variable, as is AC_SUBST.
205 dnl ARG-NAME is the base name of the argument (without "--with").
206 dnl HELP is the help text to use.
207 dnl If the user's choice is relative to the prefix, then the
208 dnl result is relocatable, then this will define the C macro
209 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
210 dnl DEFAULT is the default value, which is used if the user
211 dnl does not specify the argument.
212 AC_DEFUN([GDB_AC_WITH_DIR], [
213 AC_ARG_WITH([$2], AS_HELP_STRING([--with-][$2][=PATH], [$3]), [
214 [$1]=$withval], [[$1]=[$4]])
215 AC_DEFINE_DIR([$1], [$1], [$3])
217 GDB_AC_DEFINE_RELOCATABLE([$1], [$2], ${ac_define_dir})
220 dnl GDB_AC_CHECK_BFD([MESSAGE], [CV], [CODE], [HEADER])
221 dnl Check whether BFD provides a feature.
222 dnl MESSAGE is the "checking" message to display.
223 dnl CV is the name of the cache variable where the result is stored.
224 dnl The result will be "yes" or "no".
225 dnl CODE is some code to compile that checks for the feature.
226 dnl A link test is run.
227 dnl HEADER is the name of an extra BFD header to include.
228 AC_DEFUN([GDB_AC_CHECK_BFD], [
233 # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
234 # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
235 # always want our bfd.
236 CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
237 LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
238 # LTLIBINTL because we use libtool as CC below.
239 intl="$(echo "$LTLIBINTL" | sed 's,\$[[{(]top_builddir[)}]]/,,')"
240 LIBS="-lbfd -liberty $intl $LIBS"
241 CC="./libtool --quiet --mode=link $CC"
262 dnl GDB_GUILE_PROGRAM_NAMES([PKG-CONFIG], [VERSION])
264 dnl Define and substitute 'GUILD' to contain the absolute file name of
265 dnl the 'guild' command for VERSION, using PKG-CONFIG. (This is
266 dnl similar to Guile's 'GUILE_PROGS' macro.)
267 AC_DEFUN([GDB_GUILE_PROGRAM_NAMES], [
268 AC_CACHE_CHECK([for the absolute file name of the 'guild' command],
269 [ac_cv_guild_program_name],
270 [ac_cv_guild_program_name="`$1 --variable guild $2`"
272 # In Guile up to 2.0.11 included, guile-2.0.pc would not define
273 # the 'guild' and 'bindir' variables. In that case, try to guess
274 # what the program name is, at the risk of getting it wrong if
275 # Guile was configured with '--program-suffix' or similar.
276 if test "x$ac_cv_guild_program_name" = "x"; then
277 guile_exec_prefix="`$1 --variable exec_prefix $2`"
278 ac_cv_guild_program_name="$guile_exec_prefix/bin/guild"
282 if ! "$ac_cv_guild_program_name" --version >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
283 AC_MSG_ERROR(['$ac_cv_guild_program_name' appears to be unusable])
286 GUILD="$ac_cv_guild_program_name"
290 dnl GDB_GUILD_TARGET_FLAG
292 dnl Compute the value of GUILD_TARGET_FLAG.
293 dnl For native builds this is empty.
294 dnl For cross builds this is --target=<host>.
295 AC_DEFUN([GDB_GUILD_TARGET_FLAG], [
296 if test "$cross_compiling" = no; then
299 GUILD_TARGET_FLAG="--target=$host"
301 AC_SUBST(GUILD_TARGET_FLAG)
304 dnl GDB_TRY_GUILD([SRC-FILE])
306 dnl We precompile the .scm files and install them with gdb, so make sure
307 dnl guild works for this host.
308 dnl The .scm files are precompiled for several reasons:
309 dnl 1) To silence Guile during gdb startup (Guile's auto-compilation output
310 dnl is unnecessarily verbose).
311 dnl 2) Make gdb developers see compilation errors/warnings during the build,
312 dnl and not leave it to later when the user runs gdb.
313 dnl 3) As a convenience for the user, so that one copy of the files is built
314 dnl instead of one copy per user.
316 dnl Make sure guild can handle this host by trying to compile SRC-FILE, and
317 dnl setting ac_cv_guild_ok to yes or no.
318 dnl Note that guild can handle cross-compilation.
319 dnl It could happen that guild can't handle the host, but guile would still
320 dnl work. For the time being we're conservative, and if guild doesn't work
322 AC_DEFUN([GDB_TRY_GUILD], [
323 AC_REQUIRE([GDB_GUILD_TARGET_FLAG])
324 AC_CACHE_CHECK([whether guild supports this host],
326 [echo "$ac_cv_guild_program_name compile $GUILD_TARGET_FLAG -o conftest.go $1" >&AS_MESSAGE_LOG_FD
327 if "$ac_cv_guild_program_name" compile $GUILD_TARGET_FLAG -o conftest.go "$1" >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then