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