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