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