]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/acinclude.m4
173e40b440afdaca10769b6b09b0c895589d73cf
[thirdparty/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 dnl NB: When possible, try to avoid explicit includes of ../config/ files.
8 dnl They're normally found by aclocal automatically and recorded in aclocal.m4.
9 dnl However, some are kept here explicitly to silence harmless warnings from
10 dnl aclocal when it finds AM_xxx macros via local search paths instead of
11 dnl system search paths.
12
13 m4_include(acx_configure_dir.m4)
14
15 # This gets GDB_AC_TRANSFORM.
16 m4_include(transform.m4)
17
18 # This get AM_GDB_COMPILER_TYPE.
19 m4_include(../gdbsupport/compiler-type.m4)
20
21 # This gets AM_GDB_WARNINGS.
22 m4_include(../gdbsupport/warning.m4)
23
24 # AM_GDB_UBSAN
25 m4_include(sanitize.m4)
26
27 # This gets GDB_AC_SELFTEST.
28 m4_include(../gdbsupport/selftest.m4)
29
30 dnl gdb/configure.in uses BFD_NEED_DECLARATION, so get its definition.
31 m4_include(../bfd/bfd.m4)
32
33 dnl For AM_LC_MESSAGES
34 m4_include([../config/lcmessage.m4])
35
36 dnl For AM_LANGINFO_CODESET.
37 m4_include([../config/codeset.m4])
38
39 dnl We need to explicitly include these before iconv.m4 to avoid warnings.
40 m4_include([../config/lib-ld.m4])
41 m4_include([../config/lib-prefix.m4])
42 m4_include([../config/lib-link.m4])
43 m4_include([../config/iconv.m4])
44
45 m4_include([../config/zlib.m4])
46 m4_include([../config/zstd.m4])
47
48 m4_include([../gdbsupport/common.m4])
49
50 dnl For libiberty_INIT.
51 m4_include(libiberty.m4)
52
53 dnl For GDB_AC_PTRACE.
54 m4_include(../gdbsupport/ptrace.m4)
55
56 m4_include(ax_cxx_compile_stdcxx.m4)
57
58 dnl written by Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva
59 dnl Version 1.3 (2001/03/02)
60 dnl source http://www.gnu.org/software/ac-archive/Miscellaneous/ac_define_dir.html
61
62 AC_DEFUN([AC_DEFINE_DIR], [
63 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
64 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
65 ac_define_dir=`eval echo [$]$2`
66 ac_define_dir=`eval echo [$]ac_define_dir`
67 ifelse($3, ,
68 AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
69 AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
70 ])
71
72 dnl See whether we need a declaration for a function.
73 dnl The result is highly dependent on the INCLUDES passed in, so make sure
74 dnl to use a different cache variable name in this macro if it is invoked
75 dnl in a different context somewhere else.
76 dnl gcc_AC_CHECK_DECL(SYMBOL,
77 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
78 AC_DEFUN(
79 [gcc_AC_CHECK_DECL],
80 [AC_MSG_CHECKING([whether $1 is declared])
81 AC_CACHE_VAL(
82 [gcc_cv_have_decl_$1],
83 [AC_COMPILE_IFELSE(
84 [AC_LANG_PROGRAM(
85 [$4],
86 [#ifndef $1
87 char *(*pfn) = (char *(*)) $1 ;
88 #endif]
89 )],
90 [eval "gcc_cv_have_decl_$1=yes"],
91 [eval "gcc_cv_have_decl_$1=no"]
92 )]
93 )
94 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
95 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
96 else
97 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
98 fi
99 ])dnl
100
101 dnl Check multiple functions to see whether each needs a declaration.
102 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
103 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
104 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
105 AC_DEFUN([gcc_AC_CHECK_DECLS],
106 [for ac_func in $1
107 do
108 changequote(, )dnl
109 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
110 changequote([, ])dnl
111 gcc_AC_CHECK_DECL($ac_func,
112 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
113 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
114 dnl It is possible that the include files passed in here are local headers
115 dnl which supply a backup declaration for the relevant prototype based on
116 dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
117 dnl will always return success. E.g. see libiberty.h's handling of
118 dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
119 dnl 1 so that any local headers used do not provide their own prototype
120 dnl during this test.
121 #undef $ac_tr_decl
122 #define $ac_tr_decl 1
123 $4
124 )
125 done
126 dnl Automatically generate config.h entries via autoheader.
127 if test x = y ; then
128 patsubst(translit([$1], [a-z], [A-Z]), [\w+],
129 [AC_DEFINE([HAVE_DECL_\&], 1,
130 [Define to 1 if we found this declaration otherwise define to 0.])])dnl
131 fi
132 ])
133
134 dnl Find the location of the private Tcl headers
135 dnl When Tcl is installed, this is TCL_INCLUDE_SPEC/tcl-private/generic
136 dnl When Tcl is in the build tree, this is not needed.
137 dnl
138 dnl Note: you must use first use SC_LOAD_TCLCONFIG!
139 AC_DEFUN([CY_AC_TCL_PRIVATE_HEADERS], [
140 AC_MSG_CHECKING([for Tcl private headers])
141 private_dir=""
142 dir=`echo ${TCL_INCLUDE_SPEC}/tcl-private/generic | sed -e s/-I//`
143 if test -f ${dir}/tclInt.h ; then
144 private_dir=${dir}
145 fi
146
147 if test x"${private_dir}" = x; then
148 AC_MSG_ERROR(could not find private Tcl headers)
149 else
150 TCL_PRIVATE_INCLUDE="-I${private_dir}"
151 AC_MSG_RESULT(${private_dir})
152 fi
153 ])
154
155 dnl Find the location of the private Tk headers
156 dnl When Tk is installed, this is TK_INCLUDE_SPEC/tk-private/generic
157 dnl When Tk is in the build tree, this not needed.
158 dnl
159 dnl Note: you must first use SC_LOAD_TKCONFIG
160 AC_DEFUN([CY_AC_TK_PRIVATE_HEADERS], [
161 AC_MSG_CHECKING([for Tk private headers])
162 private_dir=""
163 dir=`echo ${TK_INCLUDE_SPEC}/tk-private/generic | sed -e s/-I//`
164 if test -f ${dir}/tkInt.h; then
165 private_dir=${dir}
166 fi
167
168 if test x"${private_dir}" = x; then
169 AC_MSG_ERROR(could not find Tk private headers)
170 else
171 TK_PRIVATE_INCLUDE="-I${private_dir}"
172 AC_MSG_RESULT(${private_dir})
173 fi
174 ])
175
176 dnl GDB_AC_DEFINE_RELOCATABLE([VARIABLE], [ARG-NAME], [SHELL-VARIABLE])
177 dnl For use in processing directory values for --with-foo.
178 dnl If the path in SHELL_VARIABLE is relative to the prefix, then the
179 dnl result is relocatable, then this will define the C macro
180 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
181 AC_DEFUN([GDB_AC_DEFINE_RELOCATABLE], [
182 if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
183 if test "x$prefix" = xNONE; then
184 test_prefix=/usr/local
185 else
186 test_prefix=$prefix
187 fi
188 else
189 test_prefix=$exec_prefix
190 fi
191 value=0
192 case [$3] in
193 "${test_prefix}"|"${test_prefix}/"*|\
194 '${exec_prefix}'|'${exec_prefix}/'*)
195 value=1
196 ;;
197 esac
198 AC_DEFINE_UNQUOTED([$1]_RELOCATABLE, $value, [Define if the $2 directory should be relocated when GDB is moved.])
199 ])
200
201 dnl GDB_AC_WITH_DIR([VARIABLE], [ARG-NAME], [HELP], [DEFAULT])
202 dnl Add a new --with option that defines a directory.
203 dnl The result is stored in VARIABLE. AC_DEFINE_DIR is called
204 dnl on this variable, as is AC_SUBST.
205 dnl ARG-NAME is the base name of the argument (without "--with").
206 dnl HELP is the help text to use.
207 dnl If the user's choice is relative to the prefix, then the
208 dnl result is relocatable, then this will define the C macro
209 dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0.
210 dnl DEFAULT is the default value, which is used if the user
211 dnl does not specify the argument.
212 AC_DEFUN([GDB_AC_WITH_DIR], [
213 AC_ARG_WITH([$2], AS_HELP_STRING([--with-][$2][=PATH], [$3]), [
214 [$1]=$withval], [[$1]=[$4]])
215 AC_DEFINE_DIR([$1], [$1], [$3])
216 AC_SUBST([$1])
217 GDB_AC_DEFINE_RELOCATABLE([$1], [$2], ${ac_define_dir})
218 ])
219
220 dnl GDB_AC_CHECK_BFD([MESSAGE], [CV], [CODE], [HEADER])
221 dnl Check whether BFD provides a feature.
222 dnl MESSAGE is the "checking" message to display.
223 dnl CV is the name of the cache variable where the result is stored.
224 dnl The result will be "yes" or "no".
225 dnl CODE is some code to compile that checks for the feature.
226 dnl A link test is run.
227 dnl HEADER is the name of an extra BFD header to include.
228 AC_DEFUN([GDB_AC_CHECK_BFD], [
229 OLD_CFLAGS=$CFLAGS
230 OLD_LDFLAGS=$LDFLAGS
231 OLD_LIBS=$LIBS
232 OLD_CC=$CC
233 # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
234 # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
235 # always want our bfd.
236 CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
237 LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
238 intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
239 LIBS="-lbfd -liberty $intl $LIBS"
240 CC="./libtool --quiet --mode=link $CC"
241 AC_CACHE_CHECK(
242 [$1],
243 [$2],
244 [AC_LINK_IFELSE(
245 [AC_LANG_PROGRAM(
246 [#include <stdlib.h>
247 #include <string.h>
248 #include "bfd.h"
249 #include "$4"],
250 [return $3;]
251 )],
252 [[$2]=yes],
253 [[$2]=no]
254 )]
255 )
256 CC=$OLD_CC
257 CFLAGS=$OLD_CFLAGS
258 LDFLAGS=$OLD_LDFLAGS
259 LIBS=$OLD_LIBS])
260
261 dnl GDB_GUILE_PROGRAM_NAMES([PKG-CONFIG], [VERSION])
262 dnl
263 dnl Define and substitute 'GUILD' to contain the absolute file name of
264 dnl the 'guild' command for VERSION, using PKG-CONFIG. (This is
265 dnl similar to Guile's 'GUILE_PROGS' macro.)
266 AC_DEFUN([GDB_GUILE_PROGRAM_NAMES], [
267 AC_CACHE_CHECK([for the absolute file name of the 'guild' command],
268 [ac_cv_guild_program_name],
269 [ac_cv_guild_program_name="`$1 --variable guild $2`"
270
271 # In Guile up to 2.0.11 included, guile-2.0.pc would not define
272 # the 'guild' and 'bindir' variables. In that case, try to guess
273 # what the program name is, at the risk of getting it wrong if
274 # Guile was configured with '--program-suffix' or similar.
275 if test "x$ac_cv_guild_program_name" = "x"; then
276 guile_exec_prefix="`$1 --variable exec_prefix $2`"
277 ac_cv_guild_program_name="$guile_exec_prefix/bin/guild"
278 fi
279 ])
280
281 if ! "$ac_cv_guild_program_name" --version >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
282 AC_MSG_ERROR(['$ac_cv_guild_program_name' appears to be unusable])
283 fi
284
285 GUILD="$ac_cv_guild_program_name"
286 AC_SUBST([GUILD])
287 ])
288
289 dnl GDB_GUILD_TARGET_FLAG
290 dnl
291 dnl Compute the value of GUILD_TARGET_FLAG.
292 dnl For native builds this is empty.
293 dnl For cross builds this is --target=<host>.
294 AC_DEFUN([GDB_GUILD_TARGET_FLAG], [
295 if test "$cross_compiling" = no; then
296 GUILD_TARGET_FLAG=
297 else
298 GUILD_TARGET_FLAG="--target=$host"
299 fi
300 AC_SUBST(GUILD_TARGET_FLAG)
301 ])
302
303 dnl GDB_TRY_GUILD([SRC-FILE])
304 dnl
305 dnl We precompile the .scm files and install them with gdb, so make sure
306 dnl guild works for this host.
307 dnl The .scm files are precompiled for several reasons:
308 dnl 1) To silence Guile during gdb startup (Guile's auto-compilation output
309 dnl is unnecessarily verbose).
310 dnl 2) Make gdb developers see compilation errors/warnings during the build,
311 dnl and not leave it to later when the user runs gdb.
312 dnl 3) As a convenience for the user, so that one copy of the files is built
313 dnl instead of one copy per user.
314 dnl
315 dnl Make sure guild can handle this host by trying to compile SRC-FILE, and
316 dnl setting ac_cv_guild_ok to yes or no.
317 dnl Note that guild can handle cross-compilation.
318 dnl It could happen that guild can't handle the host, but guile would still
319 dnl work. For the time being we're conservative, and if guild doesn't work
320 dnl we punt.
321 AC_DEFUN([GDB_TRY_GUILD], [
322 AC_REQUIRE([GDB_GUILD_TARGET_FLAG])
323 AC_CACHE_CHECK([whether guild supports this host],
324 [ac_cv_guild_ok],
325 [echo "$ac_cv_guild_program_name compile $GUILD_TARGET_FLAG -o conftest.go $1" >&AS_MESSAGE_LOG_FD
326 if "$ac_cv_guild_program_name" compile $GUILD_TARGET_FLAG -o conftest.go "$1" >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
327 ac_cv_guild_ok=yes
328 else
329 ac_cv_guild_ok=no
330 fi])
331 ])