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