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