2005-02-28 Paolo Bonzini <bonzini@gnu.org>
[deliverable/binutils-gdb.git] / config / acx.m4
CommitLineData
5212e868
NN
1# Autoconf M4 include file defining utility macros for complex Canadian
2# cross builds.
3
dd12c3a8
NN
4dnl ####
5dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
6dnl # $build_alias or canonical $build if blank.
7dnl # Used when we would use $build_alias, but empty is not OK.
8AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_BUILD],
9[AC_REQUIRE([AC_CANONICAL_BUILD]) []dnl
10case ${build_alias} in
11 "") build_noncanonical=${build} ;;
12 *) build_noncanonical=${build_alias} ;;
13esac
14]) []dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
15
16dnl ####
17dnl # _GCC_TOPLEV_NONCANONICAL_HOST
18dnl # $host_alias, or $build_noncanonical if blank.
19dnl # Used when we would use $host_alias, but empty is not OK.
20AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_HOST],
21[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
22case ${host_alias} in
23 "") host_noncanonical=${build_noncanonical} ;;
24 *) host_noncanonical=${host_alias} ;;
25esac
26]) []dnl # _GCC_TOPLEV_NONCANONICAL_HOST
27
28dnl ####
29dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
30dnl # $target_alias or $host_noncanonical if blank.
31dnl # Used when we would use $target_alias, but empty is not OK.
32AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_TARGET],
33[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_HOST]) []dnl
34case ${target_alias} in
35 "") target_noncanonical=${host_noncanonical} ;;
36 *) target_noncanonical=${target_alias} ;;
37esac
38]) []dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
39
118c4fba
NN
40dnl ####
41dnl # ACX_NONCANONICAL_BUILD
42dnl # Like underscored version, but AC_SUBST's.
43AC_DEFUN([ACX_NONCANONICAL_BUILD],
44[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
45AC_SUBST(build_noncanonical)
46]) []dnl # ACX_NONCANONICAL_BUILD
47
48dnl ####
49dnl # ACX_NONCANONICAL_HOST
50dnl # Like underscored version, but AC_SUBST's.
51AC_DEFUN([ACX_NONCANONICAL_HOST],
52[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_HOST]) []dnl
53AC_SUBST(host_noncanonical)
54]) []dnl # ACX_NONCANONICAL_HOST
55
56dnl ####
57dnl # ACX_NONCANONICAL_TARGET
58dnl # Like underscored version, but AC_SUBST's.
59AC_DEFUN([ACX_NONCANONICAL_TARGET],
60[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
61AC_SUBST(target_noncanonical)
62]) []dnl # ACX_NONCANONICAL_TARGET
63
dd12c3a8
NN
64dnl ####
65dnl # GCC_TOPLEV_SUBDIRS
66dnl # GCC & friends build 'build', 'host', and 'target' tools. These must
67dnl # be separated into three well-known subdirectories of the build directory:
68dnl # build_subdir, host_subdir, and target_subdir. The values are determined
69dnl # here so that they can (theoretically) be changed in the future. They
70dnl # were previously reproduced across many different files.
71dnl #
72dnl # This logic really amounts to very little with autoconf 2.13; it will
73dnl # amount to a lot more with autoconf 2.5x.
74AC_DEFUN([GCC_TOPLEV_SUBDIRS],
75[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
76AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
77# Prefix 'build-' so this never conflicts with target_subdir.
78build_subdir="build-${build_noncanonical}"
b00612cc
PB
79# --srcdir=. covers the toplevel, while "test -d" covers the subdirectories
80if ( test $srcdir = . && test -d gcc ) \
81 || test -d $srcdir/../host-${host_noncanonical}; then
82 host_subdir="host-${host_noncanonical}"
83else
84 host_subdir=.
85fi
dd12c3a8
NN
86# No prefix.
87target_subdir=${target_noncanonical}
88AC_SUBST([build_subdir]) []dnl
89AC_SUBST([host_subdir]) []dnl
90AC_SUBST([target_subdir]) []dnl
91]) []dnl # GCC_TOPLEV_SUBDIRS
92
93
5212e868
NN
94####
95# _NCN_TOOL_PREFIXES: Some stuff that oughtta be done in AC_CANONICAL_SYSTEM
96# or AC_INIT.
97# These demand that AC_CANONICAL_SYSTEM be called beforehand.
98AC_DEFUN([_NCN_TOOL_PREFIXES],
99[ncn_tool_prefix=
100test -n "$host_alias" && ncn_tool_prefix=$host_alias-
101ncn_target_tool_prefix=
102test -n "$target_alias" && ncn_target_tool_prefix=$target_alias-
103]) []dnl # _NCN_TOOL_PREFIXES
104
105####
106# NCN_CHECK_TARGET_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
107# Like AC_CHECK_TOOL, but tries a prefix of the target, not the host.
108# Code is pretty much lifted from autoconf2.53.
109
110AC_DEFUN([NCN_CHECK_TARGET_TOOL],
111[AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
112if test -n "$ncn_target_tool_prefix"; then
113 AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}$2],
114 [${ncn_target_tool_prefix}$2], , [$4])
115fi
116if test -z "$ac_cv_prog_$1" ; then
66e7a4d5
AO
117 ncn_cv_$1=$$1
118 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [$3], [$4])
119 $1=$ncn_cv_$1
5212e868
NN
120else
121 $1="$ac_cv_prog_$1"
122fi
123]) []dnl # NCN_CHECK_TARGET_TOOL
124
125
126####
127# NCN_STRICT_CHECK_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
128# Like AC_CHECK_TOOL, but requires the prefix if build!=host.
129
130AC_DEFUN([NCN_STRICT_CHECK_TOOL],
131[AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
132if test -n "$ncn_tool_prefix"; then
133 AC_CHECK_PROG([$1], [${ncn_tool_prefix}$2],
134 [${ncn_tool_prefix}$2], , [$4])
135fi
136if test -z "$ac_cv_prog_$1" ; then
137 if test $build = $host ; then
66e7a4d5
AO
138 ncn_cv_$1=$$1
139 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [ifelse([$3],[],[$2],[$3])], [$4])
140 $1=$ncn_cv_$1
5212e868 141 else
66e7a4d5 142 $1="ifelse([$3],[],[${ncn_tool_prefix}$2],[$3])"
5212e868
NN
143 fi
144else
145 $1="$ac_cv_prog_$1"
146fi
147]) []dnl # NCN_STRICT_CHECK_TOOL
148
149
150####
151# NCN_STRICT_CHECK_TARGET_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
152# Like NCN_CHECK_TARGET_TOOL, but requires the prefix if build!=target.
153
154AC_DEFUN([NCN_STRICT_CHECK_TARGET_TOOL],
155[AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
156if test -n "$ncn_target_tool_prefix"; then
157 AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}$2],
158 [${ncn_target_tool_prefix}$2], , [$4])
159fi
160if test -z "$ac_cv_prog_$1" ; then
161 if test $build = $target ; then
66e7a4d5
AO
162 ncn_cv_$1=$$1
163 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [ifelse([$3],[],[$2],[$3])], [$4])
164 $1=$ncn_cv_$1
5212e868 165 else
66e7a4d5 166 $1="ifelse([$3],[],[${ncn_target_tool_prefix}$2],[$3])"
5212e868
NN
167 fi
168else
169 $1="$ac_cv_prog_$1"
170fi
171]) []dnl # NCN_STRICT_CHECK_TARGET_TOOL
394559cb
DJ
172
173###
174# AC_PROG_CPP_WERROR
175# Used for autoconf 2.5x to force AC_PREPROC_IFELSE to reject code which
176# triggers warnings from the preprocessor. Will be in autoconf 2.58.
177# For now, using this also overrides header checks to use only the
178# preprocessor (matches 2.13 behavior; matching 2.58's behavior is a
179# bit harder from here).
180# Eventually autoconf will default to checking headers with the compiler
181# instead, and we'll have to do this differently.
182
183AC_DEFUN([AC_PROG_CPP_WERROR],
184[AC_REQUIRE([AC_PROG_CPP])dnl
185m4_define([AC_CHECK_HEADER],m4_defn([_AC_CHECK_HEADER_OLD]))
186ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
9e07f89d
NN
187
188# Test for GNAT.
189# We require the gnatbind program, and a compiler driver that
190# understands Ada. We use the user's CC setting, already found.
191#
192# Sets the shell variable have_gnat to yes or no as appropriate, and
193# substitutes GNATBIND.
194AC_DEFUN([ACX_PROG_GNAT],
195[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
196AC_REQUIRE([AC_PROG_CC])
197AC_CHECK_TOOL(GNATBIND, gnatbind, no)
198AC_CACHE_CHECK([whether compiler driver understands Ada],
199 acx_cv_cc_gcc_supports_ada,
200[cat >conftest.adb <<EOF
201procedure conftest is begin null; end conftest;
202EOF
203acx_cv_cc_gcc_supports_ada=no
204# There is a bug in old released versions of GCC which causes the
205# driver to exit successfully when the appropriate language module
206# has not been installed. This is fixed in 2.95.4, 3.0.2, and 3.1.
207# Therefore we must check for the error message as well as an
208# unsuccessful exit.
b8908782
DD
209# Other compilers, like HP Tru64 UNIX cc, exit successfully when
210# given a .adb file, but produce no object file. So we must check
211# if an object file was really produced to guard against this.
9e07f89d 212errors=`(${CC} -c conftest.adb) 2>&1 || echo failure`
b8908782 213if test x"$errors" = x && test -f conftest.$ac_objext; then
9e07f89d
NN
214 acx_cv_cc_gcc_supports_ada=yes
215 break
216fi
217rm -f conftest.*])
218
b8908782 219if test x$GNATBIND != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
9e07f89d
NN
220 have_gnat=yes
221else
222 have_gnat=no
223fi
224])
4b1cb4fe
DD
225
226dnl 'make compare' can be significantly faster, if cmp itself can
227dnl skip bytes instead of using tail. The test being performed is
228dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
229dnl but we need to sink errors and handle broken shells. We also test
230dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
231dnl accepted by cmp on some systems.
232AC_DEFUN([ACX_PROG_CMP_IGNORE_INITIAL],
233[AC_CACHE_CHECK([how to compare bootstrapped objects], gcc_cv_prog_cmp_skip,
234[ echo abfoo >t1
235 echo cdfoo >t2
236 gcc_cv_prog_cmp_skip='tail +16c $$f1 > tmp-foo1; tail +16c $$f2 > tmp-foo2; cmp tmp-foo1 tmp-foo2'
237 if cmp t1 t2 2 2 > /dev/null 2>&1; then
238 if cmp t1 t2 1 1 > /dev/null 2>&1; then
239 :
240 else
241 gcc_cv_prog_cmp_skip='cmp $$f1 $$f2 16 16'
242 fi
243 fi
244 if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
245 if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
246 :
247 else
248 gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
249 fi
250 fi
251 rm t1 t2
252])
253do_compare="$gcc_cv_prog_cmp_skip"
254AC_SUBST(do_compare)
255])
04cf1b77
PB
256
257dnl See whether we can include both string.h and strings.h.
258AC_DEFUN([ACX_HEADER_STRING],
259[AC_CACHE_CHECK([whether string.h and strings.h may both be included],
260 gcc_cv_header_string,
261[AC_TRY_COMPILE([#include <string.h>
262#include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
263if test $gcc_cv_header_string = yes; then
264 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
265fi
266])
267
268dnl See if stdbool.h properly defines bool and true/false.
269dnl Check whether _Bool is built-in.
270AC_DEFUN([ACX_HEADER_STDBOOL],
271[AC_CACHE_CHECK([for working stdbool.h],
272 ac_cv_header_stdbool_h,
273[AC_TRY_COMPILE([#include <stdbool.h>],
274[bool foo = false;],
275ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
276if test $ac_cv_header_stdbool_h = yes; then
277 AC_DEFINE(HAVE_STDBOOL_H, 1,
278 [Define if you have a working <stdbool.h> header file.])
279fi
280AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
281[AC_TRY_COMPILE(,
282[_Bool foo;],
283gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
284])
285if test $gcc_cv_c__bool = yes; then
286 AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
287fi
288])
289
656fdd47
PB
290dnl See if hard links work and if not, try to substitute $1 or simple copy.
291AC_DEFUN([ACX_PROG_LN],
292[AC_MSG_CHECKING(whether ln works)
293AC_CACHE_VAL(acx_cv_prog_LN,
294[rm -f conftestdata_t
295echo >conftestdata_f
296if ln conftestdata_f conftestdata_t 2>/dev/null
297then
298 acx_cv_prog_LN=ln
299else
300 acx_cv_prog_LN=no
301fi
302rm -f conftestdata_f conftestdata_t
303])dnl
304if test $acx_cv_prog_LN = no; then
305 LN="ifelse([$1],,cp,[$1])"
306 AC_MSG_RESULT([no, using $LN])
307else
308 LN="$acx_cv_prog_LN"
309 AC_MSG_RESULT(yes)
310fi
311AC_SUBST(LN)dnl
312])
313
This page took 0.122498 seconds and 4 git commands to generate.