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