]> git.ipfire.org Git - thirdparty/gcc.git/blame - config/acx.m4
acx.m4: Fix fastcompare support for new-bootstrap.
[thirdparty/gcc.git] / config / acx.m4
CommitLineData
671aa708
NN
1# Autoconf M4 include file defining utility macros for complex Canadian
2# cross builds.
3
8b87bb96
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
40dnl ####
41dnl # GCC_TOPLEV_SUBDIRS
42dnl # GCC & friends build 'build', 'host', and 'target' tools. These must
43dnl # be separated into three well-known subdirectories of the build directory:
44dnl # build_subdir, host_subdir, and target_subdir. The values are determined
45dnl # here so that they can (theoretically) be changed in the future. They
46dnl # were previously reproduced across many different files.
47dnl #
48dnl # This logic really amounts to very little with autoconf 2.13; it will
49dnl # amount to a lot more with autoconf 2.5x.
50AC_DEFUN([GCC_TOPLEV_SUBDIRS],
51[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
52AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
53# Prefix 'build-' so this never conflicts with target_subdir.
54build_subdir="build-${build_noncanonical}"
55# Not really a subdirectory, but here for completeness.
56host_subdir=.
57# No prefix.
58target_subdir=${target_noncanonical}
59AC_SUBST([build_subdir]) []dnl
60AC_SUBST([host_subdir]) []dnl
61AC_SUBST([target_subdir]) []dnl
62]) []dnl # GCC_TOPLEV_SUBDIRS
63
64
671aa708
NN
65####
66# _NCN_TOOL_PREFIXES: Some stuff that oughtta be done in AC_CANONICAL_SYSTEM
67# or AC_INIT.
68# These demand that AC_CANONICAL_SYSTEM be called beforehand.
69AC_DEFUN([_NCN_TOOL_PREFIXES],
70[ncn_tool_prefix=
71test -n "$host_alias" && ncn_tool_prefix=$host_alias-
72ncn_target_tool_prefix=
73test -n "$target_alias" && ncn_target_tool_prefix=$target_alias-
74]) []dnl # _NCN_TOOL_PREFIXES
75
76####
77# NCN_CHECK_TARGET_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
78# Like AC_CHECK_TOOL, but tries a prefix of the target, not the host.
79# Code is pretty much lifted from autoconf2.53.
80
81AC_DEFUN([NCN_CHECK_TARGET_TOOL],
82[AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
83if test -n "$ncn_target_tool_prefix"; then
84 AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}$2],
85 [${ncn_target_tool_prefix}$2], , [$4])
86fi
87if test -z "$ac_cv_prog_$1" ; then
5888b7f2
AO
88 ncn_cv_$1=$$1
89 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [$3], [$4])
90 $1=$ncn_cv_$1
671aa708
NN
91else
92 $1="$ac_cv_prog_$1"
93fi
94]) []dnl # NCN_CHECK_TARGET_TOOL
95
96
97####
98# NCN_STRICT_CHECK_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
99# Like AC_CHECK_TOOL, but requires the prefix if build!=host.
100
101AC_DEFUN([NCN_STRICT_CHECK_TOOL],
102[AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
103if test -n "$ncn_tool_prefix"; then
104 AC_CHECK_PROG([$1], [${ncn_tool_prefix}$2],
105 [${ncn_tool_prefix}$2], , [$4])
106fi
107if test -z "$ac_cv_prog_$1" ; then
108 if test $build = $host ; then
5888b7f2
AO
109 ncn_cv_$1=$$1
110 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [ifelse([$3],[],[$2],[$3])], [$4])
111 $1=$ncn_cv_$1
671aa708 112 else
5888b7f2 113 $1="ifelse([$3],[],[${ncn_tool_prefix}$2],[$3])"
671aa708
NN
114 fi
115else
116 $1="$ac_cv_prog_$1"
117fi
118]) []dnl # NCN_STRICT_CHECK_TOOL
119
120
121####
122# NCN_STRICT_CHECK_TARGET_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
123# Like NCN_CHECK_TARGET_TOOL, but requires the prefix if build!=target.
124
125AC_DEFUN([NCN_STRICT_CHECK_TARGET_TOOL],
126[AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
127if test -n "$ncn_target_tool_prefix"; then
128 AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}$2],
129 [${ncn_target_tool_prefix}$2], , [$4])
130fi
131if test -z "$ac_cv_prog_$1" ; then
132 if test $build = $target ; then
5888b7f2
AO
133 ncn_cv_$1=$$1
134 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [ifelse([$3],[],[$2],[$3])], [$4])
135 $1=$ncn_cv_$1
671aa708 136 else
5888b7f2 137 $1="ifelse([$3],[],[${ncn_target_tool_prefix}$2],[$3])"
671aa708
NN
138 fi
139else
140 $1="$ac_cv_prog_$1"
141fi
142]) []dnl # NCN_STRICT_CHECK_TARGET_TOOL
029e256e
DJ
143
144###
145# AC_PROG_CPP_WERROR
146# Used for autoconf 2.5x to force AC_PREPROC_IFELSE to reject code which
147# triggers warnings from the preprocessor. Will be in autoconf 2.58.
148# For now, using this also overrides header checks to use only the
149# preprocessor (matches 2.13 behavior; matching 2.58's behavior is a
150# bit harder from here).
151# Eventually autoconf will default to checking headers with the compiler
152# instead, and we'll have to do this differently.
153
154AC_DEFUN([AC_PROG_CPP_WERROR],
155[AC_REQUIRE([AC_PROG_CPP])dnl
156m4_define([AC_CHECK_HEADER],m4_defn([_AC_CHECK_HEADER_OLD]))
157ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
e4c9c075
PB
158
159# Test for GNAT.
160# We require the gnatbind program, and a compiler driver that
161# understands Ada. We use the user's CC setting, already found.
162#
163# Sets the shell variable have_gnat to yes or no as appropriate, and
164# substitutes GNATBIND.
165AC_DEFUN([ACX_PROG_GNAT],
166[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
167AC_REQUIRE([AC_PROG_CC])
168AC_CHECK_TOOL(GNATBIND, gnatbind, no)
169AC_CACHE_CHECK([whether compiler driver understands Ada],
170 acx_cv_cc_gcc_supports_ada,
171[cat >conftest.adb <<EOF
172procedure conftest is begin null; end conftest;
173EOF
174acx_cv_cc_gcc_supports_ada=no
175# There is a bug in old released versions of GCC which causes the
176# driver to exit successfully when the appropriate language module
177# has not been installed. This is fixed in 2.95.4, 3.0.2, and 3.1.
178# Therefore we must check for the error message as well as an
179# unsuccessful exit.
1db673ca
RO
180# Other compilers, like HP Tru64 UNIX cc, exit successfully when
181# given a .adb file, but produce no object file. So we must check
182# if an object file was really produced to guard against this.
e4c9c075 183errors=`(${CC} -c conftest.adb) 2>&1 || echo failure`
1db673ca 184if test x"$errors" = x && test -f conftest.$ac_objext; then
e4c9c075
PB
185 acx_cv_cc_gcc_supports_ada=yes
186 break
187fi
188rm -f conftest.*])
189
1db673ca 190if test x$GNATBIND != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
e4c9c075
PB
191 have_gnat=yes
192else
193 have_gnat=no
194fi
195])
6cf1ac42
PB
196
197dnl 'make compare' can be significantly faster, if cmp itself can
198dnl skip bytes instead of using tail. The test being performed is
199dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
200dnl but we need to sink errors and handle broken shells. We also test
201dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
202dnl accepted by cmp on some systems.
203AC_DEFUN([ACX_PROG_CMP_IGNORE_INITIAL],
204[AC_CACHE_CHECK([how to compare bootstrapped objects], gcc_cv_prog_cmp_skip,
205[ echo abfoo >t1
206 echo cdfoo >t2
207 gcc_cv_prog_cmp_skip='tail +16c $$f1 > tmp-foo1; tail +16c $$f2 > tmp-foo2; cmp tmp-foo1 tmp-foo2'
208 if cmp t1 t2 2 2 > /dev/null 2>&1; then
209 if cmp t1 t2 1 1 > /dev/null 2>&1; then
210 :
211 else
212 gcc_cv_prog_cmp_skip='cmp $$f1 $$f2 16 16'
213 fi
214 fi
215 if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
216 if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
217 :
218 else
219 gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
220 fi
221 fi
222 rm t1 t2
223])
224do_compare="$gcc_cv_prog_cmp_skip"
225AC_SUBST(do_compare)
226])