Re: Optimise away eh_frame advance_loc 0
[deliverable/binutils-gdb.git] / gdb / acinclude.m4
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 m4_include(acx_configure_dir.m4)
8
9 # This gets GDB_AC_TRANSFORM.
10 m4_include(transform.m4)
11
12 # This gets AM_GDB_WARNINGS.
13 m4_include(warning.m4)
14
15 # AM_GDB_UBSAN
16 m4_include(sanitize.m4)
17
18 # This gets GDB_AC_SELFTEST.
19 m4_include(selftest.m4)
20
21 dnl gdb/configure.in uses BFD_NEED_DECLARATION, so get its definition.
22 m4_include(../bfd/bfd.m4)
23
24 dnl This gets the standard macros.
25 m4_include(../config/acinclude.m4)
26
27 dnl This gets AC_PLUGINS, needed by ACX_LARGEFILE.
28 m4_include(../config/plugins.m4)
29
30 dnl For ACX_LARGEFILE.
31 m4_include(../config/largefile.m4)
32
33 dnl For AM_SET_LEADING_DOT.
34 m4_include(../config/lead-dot.m4)
35
36 dnl This gets autoconf bugfixes.
37 m4_include(../config/override.m4)
38
39 dnl For ZW_GNU_GETTEXT_SISTER_DIR.
40 m4_include(../config/gettext-sister.m4)
41
42 dnl For AC_LIB_HAVE_LINKFLAGS.
43 m4_include(../config/lib-ld.m4)
44 m4_include(../config/lib-prefix.m4)
45 m4_include(../config/lib-link.m4)
46
47 dnl For ACX_PKGVERSION and ACX_BUGURL.
48 m4_include(../config/acx.m4)
49
50 dnl for TCL definitions
51 m4_include(../config/tcl.m4)
52
53 dnl For dependency tracking macros.
54 m4_include([../config/depstand.m4])
55
56 dnl For AM_LC_MESSAGES
57 m4_include([../config/lcmessage.m4])
58
59 dnl For AM_LANGINFO_CODESET.
60 m4_include([../config/codeset.m4])
61
62 m4_include([../config/iconv.m4])
63
64 m4_include([../config/zlib.m4])
65
66 m4_include([gdbsupport/common.m4])
67
68 dnl For libiberty_INIT.
69 m4_include(libiberty.m4)
70
71 dnl For GDB_AC_PTRACE.
72 m4_include(ptrace.m4)
73
74 m4_include(ax_cxx_compile_stdcxx.m4)
75
76 ## ----------------------------------------- ##
77 ## ANSIfy the C compiler whenever possible. ##
78 ## From Franc,ois Pinard ##
79 ## ----------------------------------------- ##
80
81 # Copyright (C) 1996-2019 Free Software Foundation, Inc.
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
94 # along with this program; if not, see <http://www.gnu.org/licenses/>.
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
113 AC_DEFUN([AM_PROG_CC_STDC],
114 [AC_REQUIRE([AC_PROG_CC])
115 AC_BEFORE([$0], [AC_C_INLINE])
116 AC_BEFORE([$0], [AC_C_CONST])
117 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
118 dnl a magic option to avoid problems with ANSI preprocessor commands
119 dnl like #elif.
120 dnl FIXME: can't do this because then AC_AIX won't work due to a
121 dnl circular dependency.
122 dnl AC_BEFORE([$0], [AC_PROG_CPP])
123 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
124 AC_CACHE_VAL(am_cv_prog_cc_stdc,
125 [am_cv_prog_cc_stdc=no
126 ac_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__
134 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
135 do
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. */
143 struct buf { int x; };
144 FILE * (*rcsopen) (struct buf *, struct stat *, int);
145 static char *e (p, i)
146 char **p;
147 int i;
148 {
149 return p[i];
150 }
151 static 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 }
160 int test (int i, double x);
161 struct s1 {int (*f) (int a);};
162 struct s2 {int (*f) (double a);};
163 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
164 int argc;
165 char **argv;
166 ], [
167 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
168 ],
169 [am_cv_prog_cc_stdc="$ac_arg"; break])
170 done
171 CC="$ac_save_CC"
172 ])
173 if test -z "$am_cv_prog_cc_stdc"; then
174 AC_MSG_RESULT([none needed])
175 else
176 AC_MSG_RESULT([$am_cv_prog_cc_stdc])
177 fi
178 case "x$am_cv_prog_cc_stdc" in
179 x|xno) ;;
180 *) CC="$CC $am_cv_prog_cc_stdc" ;;
181 esac
182 ])
183
184 dnl written by Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva
185 dnl Version 1.3 (2001/03/02)
186 dnl source http://www.gnu.org/software/ac-archive/Miscellaneous/ac_define_dir.html
187
188 AC_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
198 dnl See whether we need a declaration for a function.
199 dnl The result is highly dependent on the INCLUDES passed in, so make sure
200 dnl to use a different cache variable name in this macro if it is invoked
201 dnl in a different context somewhere else.
202 dnl gcc_AC_CHECK_DECL(SYMBOL,
203 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
204 AC_DEFUN([gcc_AC_CHECK_DECL],
205 [AC_MSG_CHECKING([whether $1 is declared])
206 AC_CACHE_VAL(gcc_cv_have_decl_$1,
207 [AC_TRY_COMPILE([$4],
208 [#ifndef $1
209 char *(*pfn) = (char *(*)) $1 ;
210 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
211 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
212 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
213 else
214 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
215 fi
216 ])dnl
217
218 dnl Check multiple functions to see whether each needs a declaration.
219 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
220 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
221 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
222 AC_DEFUN([gcc_AC_CHECK_DECLS],
223 [for ac_func in $1
224 do
225 changequote(, )dnl
226 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
227 changequote([, ])dnl
228 gcc_AC_CHECK_DECL($ac_func,
229 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
230 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
231 dnl It is possible that the include files passed in here are local headers
232 dnl which supply a backup declaration for the relevant prototype based on
233 dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
234 dnl will always return success. E.g. see libiberty.h's handling of
235 dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
236 dnl 1 so that any local headers used do not provide their own prototype
237 dnl during this test.
238 #undef $ac_tr_decl
239 #define $ac_tr_decl 1
240 $4
241 )
242 done
243 dnl Automatically generate config.h entries via autoheader.
244 if 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
248 fi
249 ])
250
251 dnl Find the location of the private Tcl headers
252 dnl When Tcl is installed, this is TCL_INCLUDE_SPEC/tcl-private/generic
253 dnl When Tcl is in the build tree, this is not needed.
254 dnl
255 dnl Note: you must use first use SC_LOAD_TCLCONFIG!
256 AC_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
272 dnl Find the location of the private Tk headers
273 dnl When Tk is installed, this is TK_INCLUDE_SPEC/tk-private/generic
274 dnl When Tk is in the build tree, this not needed.
275 dnl
276 dnl Note: you must first use SC_LOAD_TKCONFIG
277 AC_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 ])
292
293 dnl GDB_AC_DEFINE_RELOCATABLE([VARIABLE], [ARG-NAME], [SHELL-VARIABLE])
294 dnl For use in processing directory values for --with-foo.
295 dnl If the path in SHELL_VARIABLE is relative to the prefix, then the
296 dnl result is relocatable, then this will define the C macro
297 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
298 AC_DEFUN([GDB_AC_DEFINE_RELOCATABLE], [
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
309 case [$3] in
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.])
316 ])
317
318 dnl GDB_AC_WITH_DIR([VARIABLE], [ARG-NAME], [HELP], [DEFAULT])
319 dnl Add a new --with option that defines a directory.
320 dnl The result is stored in VARIABLE. AC_DEFINE_DIR is called
321 dnl on this variable, as is AC_SUBST.
322 dnl ARG-NAME is the base name of the argument (without "--with").
323 dnl HELP is the help text to use.
324 dnl If the user's choice is relative to the prefix, then the
325 dnl result is relocatable, then this will define the C macro
326 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
327 dnl DEFAULT is the default value, which is used if the user
328 dnl does not specify the argument.
329 AC_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})
335 ])
336
337 dnl GDB_AC_CHECK_BFD([MESSAGE], [CV], [CODE], [HEADER])
338 dnl Check whether BFD provides a feature.
339 dnl MESSAGE is the "checking" message to display.
340 dnl CV is the name of the cache variable where the result is stored.
341 dnl The result will be "yes" or "no".
342 dnl CODE is some code to compile that checks for the feature.
343 dnl A link test is run.
344 dnl HEADER is the name of an extra BFD header to include.
345 AC_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"
353 ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
354 LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
355 intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
356 LIBS="-lbfd -liberty -lz $intl $LIBS"
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])
367
368 dnl GDB_GUILE_PROGRAM_NAMES([PKG-CONFIG], [VERSION])
369 dnl
370 dnl Define and substitute 'GUILD' to contain the absolute file name of
371 dnl the 'guild' command for VERSION, using PKG-CONFIG. (This is
372 dnl similar to Guile's 'GUILE_PROGS' macro.)
373 AC_DEFUN([GDB_GUILE_PROGRAM_NAMES], [
374 AC_CACHE_CHECK([for the absolute file name of the 'guild' command],
375 [ac_cv_guild_program_name],
376 [ac_cv_guild_program_name="`$1 --variable guild $2`"
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
383 guile_exec_prefix="`$1 --variable exec_prefix $2`"
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
396 dnl GDB_GUILD_TARGET_FLAG
397 dnl
398 dnl Compute the value of GUILD_TARGET_FLAG.
399 dnl For native builds this is empty.
400 dnl For cross builds this is --target=<host>.
401 AC_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
410 dnl GDB_TRY_GUILD([SRC-FILE])
411 dnl
412 dnl We precompile the .scm files and install them with gdb, so make sure
413 dnl guild works for this host.
414 dnl The .scm files are precompiled for several reasons:
415 dnl 1) To silence Guile during gdb startup (Guile's auto-compilation output
416 dnl is unnecessarily verbose).
417 dnl 2) Make gdb developers see compilation errors/warnings during the build,
418 dnl and not leave it to later when the user runs gdb.
419 dnl 3) As a convenience for the user, so that one copy of the files is built
420 dnl instead of one copy per user.
421 dnl
422 dnl Make sure guild can handle this host by trying to compile SRC-FILE, and
423 dnl setting ac_cv_guild_ok to yes or no.
424 dnl Note that guild can handle cross-compilation.
425 dnl It could happen that guild can't handle the host, but guile would still
426 dnl work. For the time being we're conservative, and if guild doesn't work
427 dnl we punt.
428 AC_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 0.063228 seconds and 4 git commands to generate.