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