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