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 sinclude(acx_configure_dir.m4)
9 # This gets GDB_AC_TRANSFORM.
10 sinclude(transform.m4)
12 # This gets AM_GDB_WARNINGS.
18 # This gets GDB_AC_SELFTEST.
21 dnl gdb/configure.in uses BFD_NEED_DECLARATION, so get its definition.
22 sinclude(../bfd/bfd.m4)
24 dnl This gets the standard macros.
25 sinclude(../config/acinclude.m4)
27 dnl This gets AC_PLUGINS, needed by ACX_LARGEFILE.
28 sinclude(../config/plugins.m4)
30 dnl For ACX_LARGEFILE.
31 sinclude(../config/largefile.m4)
33 dnl For AM_SET_LEADING_DOT.
34 sinclude(../config/lead-dot.m4)
36 dnl This gets autoconf bugfixes.
37 sinclude(../config/override.m4)
39 dnl For ZW_GNU_GETTEXT_SISTER_DIR.
40 sinclude(../config/gettext-sister.m4)
42 dnl For AC_LIB_HAVE_LINKFLAGS.
43 sinclude(../config/lib-ld.m4)
44 sinclude(../config/lib-prefix.m4)
45 sinclude(../config/lib-link.m4)
47 dnl For ACX_PKGVERSION and ACX_BUGURL.
48 sinclude(../config/acx.m4)
50 dnl for TCL definitions
51 sinclude(../config/tcl.m4)
53 dnl For dependency tracking macros.
54 sinclude([../config/depstand.m4])
56 dnl For AM_LC_MESSAGES
57 sinclude([../config/lcmessage.m4])
59 dnl For AM_LANGINFO_CODESET.
60 sinclude([../config/codeset.m4])
62 sinclude([../config/iconv.m4])
64 sinclude([../config/zlib.m4])
66 m4_include([gdbsupport/common.m4])
68 dnl For libiberty_INIT.
69 m4_include(libiberty.m4)
71 dnl For GDB_AC_PTRACE.
74 m4_include(ax_cxx_compile_stdcxx.m4)
76 ## ----------------------------------------- ##
77 ## ANSIfy the C compiler whenever possible. ##
78 ## From Franc,ois Pinard ##
79 ## ----------------------------------------- ##
81 # Copyright (C) 1996-2019 Free Software Foundation, Inc.
83 # This program is free software; you can redistribute it and/or modify
84 # it under the terms of the GNU General Public License as published by
85 # the Free Software Foundation; either version 2, or (at your option)
88 # This program is distributed in the hope that it will be useful,
89 # but WITHOUT ANY WARRANTY; without even the implied warranty of
90 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91 # GNU General Public License for more details.
93 # You should have received a copy of the GNU General Public License
94 # along with this program; if not, see <http://www.gnu.org/licenses/>.
98 # @defmac AC_PROG_CC_STDC
99 # @maindex PROG_CC_STDC
101 # If the C compiler in not in ANSI C mode by default, try to add an option
102 # to output variable @code{CC} to make it so. This macro tries various
103 # options that select ANSI C on some system or another. It considers the
104 # compiler to be in ANSI C mode if it handles function prototypes correctly.
106 # If you use this macro, you should check after calling it whether the C
107 # compiler has been set to accept ANSI C; if not, the shell variable
108 # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
109 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
110 # program @code{ansi2knr}, which comes with Ghostscript.
113 AC_DEFUN([AM_PROG_CC_STDC],
114 [AC_REQUIRE([AC_PROG_CC])
115 AC_BEFORE([$0], [AC_C_INLINE])
116 AC_BEFORE([$0], [AC_C_CONST])
117 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
118 dnl a magic option to avoid problems with ANSI preprocessor commands
120 dnl FIXME: can't do this because then AC_AIX won't work due to a
121 dnl circular dependency.
122 dnl AC_BEFORE([$0], [AC_PROG_CPP])
123 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
124 AC_CACHE_VAL(am_cv_prog_cc_stdc,
125 [am_cv_prog_cc_stdc=no
127 # Don't try gcc -ansi; that turns off useful extensions and
128 # breaks some systems' header files.
130 # Ultrix and OSF/1 -std1
131 # HP-UX 10.20 and later -Ae
132 # HP-UX older versions -Aa -D_HPUX_SOURCE
133 # SVR4 -Xc -D__EXTENSIONS__
134 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
136 CC="$ac_save_CC $ac_arg"
140 #include <sys/types.h>
141 #include <sys/stat.h>
142 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
143 struct buf { int x; };
144 FILE * (*rcsopen) (struct buf *, struct stat *, int);
145 static char *e (p, i)
151 static char *f (char * (*g) (char **, int), char **p, ...)
156 s = g (p, va_arg (v,int));
160 int test (int i, double x);
161 struct s1 {int (*f) (int a);};
162 struct s2 {int (*f) (double a);};
163 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
167 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
169 [am_cv_prog_cc_stdc="$ac_arg"; break])
173 if test -z "$am_cv_prog_cc_stdc"; then
174 AC_MSG_RESULT([none needed])
176 AC_MSG_RESULT([$am_cv_prog_cc_stdc])
178 case "x$am_cv_prog_cc_stdc" in
180 *) CC="$CC $am_cv_prog_cc_stdc" ;;
184 dnl written by Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva
185 dnl Version 1.3 (2001/03/02)
186 dnl source http://www.gnu.org/software/ac-archive/Miscellaneous/ac_define_dir.html
188 AC_DEFUN([AC_DEFINE_DIR], [
189 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
190 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
191 ac_define_dir=`eval echo [$]$2`
192 ac_define_dir=`eval echo [$]ac_define_dir`
194 AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
195 AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
198 dnl See whether we need a declaration for a function.
199 dnl The result is highly dependent on the INCLUDES passed in, so make sure
200 dnl to use a different cache variable name in this macro if it is invoked
201 dnl in a different context somewhere else.
202 dnl gcc_AC_CHECK_DECL(SYMBOL,
203 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
204 AC_DEFUN([gcc_AC_CHECK_DECL],
205 [AC_MSG_CHECKING([whether $1 is declared])
206 AC_CACHE_VAL(gcc_cv_have_decl_$1,
207 [AC_TRY_COMPILE([$4],
209 char *(*pfn) = (char *(*)) $1 ;
210 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
211 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
212 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
214 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
218 dnl Check multiple functions to see whether each needs a declaration.
219 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
220 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
221 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
222 AC_DEFUN([gcc_AC_CHECK_DECLS],
226 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
228 gcc_AC_CHECK_DECL($ac_func,
229 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
230 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
231 dnl It is possible that the include files passed in here are local headers
232 dnl which supply a backup declaration for the relevant prototype based on
233 dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
234 dnl will always return success. E.g. see libiberty.h's handling of
235 dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
236 dnl 1 so that any local headers used do not provide their own prototype
237 dnl during this test.
239 #define $ac_tr_decl 1
243 dnl Automatically generate config.h entries via autoheader.
245 patsubst(translit([$1], [a-z], [A-Z]), [\w+],
246 [AC_DEFINE([HAVE_DECL_\&], 1,
247 [Define to 1 if we found this declaration otherwise define to 0.])])dnl
251 dnl Find the location of the private Tcl headers
252 dnl When Tcl is installed, this is TCL_INCLUDE_SPEC/tcl-private/generic
253 dnl When Tcl is in the build tree, this is not needed.
255 dnl Note: you must use first use SC_LOAD_TCLCONFIG!
256 AC_DEFUN([CY_AC_TCL_PRIVATE_HEADERS], [
257 AC_MSG_CHECKING([for Tcl private headers])
259 dir=`echo ${TCL_INCLUDE_SPEC}/tcl-private/generic | sed -e s/-I//`
260 if test -f ${dir}/tclInt.h ; then
264 if test x"${private_dir}" = x; then
265 AC_ERROR(could not find private Tcl headers)
267 TCL_PRIVATE_INCLUDE="-I${private_dir}"
268 AC_MSG_RESULT(${private_dir})
272 dnl Find the location of the private Tk headers
273 dnl When Tk is installed, this is TK_INCLUDE_SPEC/tk-private/generic
274 dnl When Tk is in the build tree, this not needed.
276 dnl Note: you must first use SC_LOAD_TKCONFIG
277 AC_DEFUN([CY_AC_TK_PRIVATE_HEADERS], [
278 AC_MSG_CHECKING([for Tk private headers])
280 dir=`echo ${TK_INCLUDE_SPEC}/tk-private/generic | sed -e s/-I//`
281 if test -f ${dir}/tkInt.h; then
285 if test x"${private_dir}" = x; then
286 AC_ERROR(could not find Tk private headers)
288 TK_PRIVATE_INCLUDE="-I${private_dir}"
289 AC_MSG_RESULT(${private_dir})
293 dnl GDB_AC_DEFINE_RELOCATABLE([VARIABLE], [ARG-NAME], [SHELL-VARIABLE])
294 dnl For use in processing directory values for --with-foo.
295 dnl If the path in SHELL_VARIABLE is relative to the prefix, then the
296 dnl result is relocatable, then this will define the C macro
297 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
298 AC_DEFUN([GDB_AC_DEFINE_RELOCATABLE], [
299 if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
300 if test "x$prefix" = xNONE; then
301 test_prefix=/usr/local
306 test_prefix=$exec_prefix
310 "${test_prefix}"|"${test_prefix}/"*|\
311 '${exec_prefix}'|'${exec_prefix}/'*)
315 AC_DEFINE_UNQUOTED([$1]_RELOCATABLE, $value, [Define if the $2 directory should be relocated when GDB is moved.])
318 dnl GDB_AC_WITH_DIR([VARIABLE], [ARG-NAME], [HELP], [DEFAULT])
319 dnl Add a new --with option that defines a directory.
320 dnl The result is stored in VARIABLE. AC_DEFINE_DIR is called
321 dnl on this variable, as is AC_SUBST.
322 dnl ARG-NAME is the base name of the argument (without "--with").
323 dnl HELP is the help text to use.
324 dnl If the user's choice is relative to the prefix, then the
325 dnl result is relocatable, then this will define the C macro
326 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
327 dnl DEFAULT is the default value, which is used if the user
328 dnl does not specify the argument.
329 AC_DEFUN([GDB_AC_WITH_DIR], [
330 AC_ARG_WITH([$2], AS_HELP_STRING([--with-][$2][=PATH], [$3]), [
331 [$1]=$withval], [[$1]=[$4]])
332 AC_DEFINE_DIR([$1], [$1], [$3])
334 GDB_AC_DEFINE_RELOCATABLE([$1], [$2], ${ac_define_dir})
337 dnl GDB_AC_CHECK_BFD([MESSAGE], [CV], [CODE], [HEADER])
338 dnl Check whether BFD provides a feature.
339 dnl MESSAGE is the "checking" message to display.
340 dnl CV is the name of the cache variable where the result is stored.
341 dnl The result will be "yes" or "no".
342 dnl CODE is some code to compile that checks for the feature.
343 dnl A link test is run.
344 dnl HEADER is the name of an extra BFD header to include.
345 AC_DEFUN([GDB_AC_CHECK_BFD], [
349 # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
350 # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
351 # always want our bfd.
352 CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
353 ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
354 LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
355 intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
356 LIBS="-lbfd -liberty -lz $intl $LIBS"
357 AC_CACHE_CHECK([$1], [$2],
363 [return $3;], [[$2]=yes], [[$2]=no])])
368 dnl GDB_GUILE_PROGRAM_NAMES([PKG-CONFIG], [VERSION])
370 dnl Define and substitute 'GUILD' to contain the absolute file name of
371 dnl the 'guild' command for VERSION, using PKG-CONFIG. (This is
372 dnl similar to Guile's 'GUILE_PROGS' macro.)
373 AC_DEFUN([GDB_GUILE_PROGRAM_NAMES], [
374 AC_CACHE_CHECK([for the absolute file name of the 'guild' command],
375 [ac_cv_guild_program_name],
376 [ac_cv_guild_program_name="`$1 --variable guild $2`"
378 # In Guile up to 2.0.11 included, guile-2.0.pc would not define
379 # the 'guild' and 'bindir' variables. In that case, try to guess
380 # what the program name is, at the risk of getting it wrong if
381 # Guile was configured with '--program-suffix' or similar.
382 if test "x$ac_cv_guild_program_name" = "x"; then
383 guile_exec_prefix="`$1 --variable exec_prefix $2`"
384 ac_cv_guild_program_name="$guile_exec_prefix/bin/guild"
388 if ! "$ac_cv_guild_program_name" --version >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
389 AC_MSG_ERROR(['$ac_cv_guild_program_name' appears to be unusable])
392 GUILD="$ac_cv_guild_program_name"
396 dnl GDB_GUILD_TARGET_FLAG
398 dnl Compute the value of GUILD_TARGET_FLAG.
399 dnl For native builds this is empty.
400 dnl For cross builds this is --target=<host>.
401 AC_DEFUN([GDB_GUILD_TARGET_FLAG], [
402 if test "$cross_compiling" = no; then
405 GUILD_TARGET_FLAG="--target=$host"
407 AC_SUBST(GUILD_TARGET_FLAG)
410 dnl GDB_TRY_GUILD([SRC-FILE])
412 dnl We precompile the .scm files and install them with gdb, so make sure
413 dnl guild works for this host.
414 dnl The .scm files are precompiled for several reasons:
415 dnl 1) To silence Guile during gdb startup (Guile's auto-compilation output
416 dnl is unnecessarily verbose).
417 dnl 2) Make gdb developers see compilation errors/warnings during the build,
418 dnl and not leave it to later when the user runs gdb.
419 dnl 3) As a convenience for the user, so that one copy of the files is built
420 dnl instead of one copy per user.
422 dnl Make sure guild can handle this host by trying to compile SRC-FILE, and
423 dnl setting ac_cv_guild_ok to yes or no.
424 dnl Note that guild can handle cross-compilation.
425 dnl It could happen that guild can't handle the host, but guile would still
426 dnl work. For the time being we're conservative, and if guild doesn't work
428 AC_DEFUN([GDB_TRY_GUILD], [
429 AC_REQUIRE([GDB_GUILD_TARGET_FLAG])
430 AC_CACHE_CHECK([whether guild supports this host],
432 [echo "$ac_cv_guild_program_name compile $GUILD_TARGET_FLAG -o conftest.go $1" >&AS_MESSAGE_LOG_FD
433 if "$ac_cv_guild_program_name" compile $GUILD_TARGET_FLAG -o conftest.go "$1" >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then