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