1 # Autoconf M4 include file defining utility macros for complex Canadian
5 dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
6 dnl # $build_alias or canonical $build if blank.
7 dnl # Used when we would use $build_alias, but empty is not OK.
8 AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_BUILD],
9 [AC_REQUIRE([AC_CANONICAL_BUILD]) []dnl
10 case ${build_alias} in
11 "") build_noncanonical=${build} ;;
12 *) build_noncanonical=${build_alias} ;;
14 ]) []dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
17 dnl # _GCC_TOPLEV_NONCANONICAL_HOST
18 dnl # $host_alias, or $build_noncanonical if blank.
19 dnl # Used when we would use $host_alias, but empty is not OK.
20 AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_HOST],
21 [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
23 "") host_noncanonical=${build_noncanonical} ;;
24 *) host_noncanonical=${host_alias} ;;
26 ]) []dnl # _GCC_TOPLEV_NONCANONICAL_HOST
29 dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
30 dnl # $target_alias or $host_noncanonical if blank.
31 dnl # Used when we would use $target_alias, but empty is not OK.
32 AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_TARGET],
33 [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_HOST]) []dnl
34 case ${target_alias} in
35 "") target_noncanonical=${host_noncanonical} ;;
36 *) target_noncanonical=${target_alias} ;;
38 ]) []dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
41 dnl # GCC_TOPLEV_SUBDIRS
42 dnl # GCC & friends build 'build', 'host', and 'target' tools. These must
43 dnl # be separated into three well-known subdirectories of the build directory:
44 dnl # build_subdir, host_subdir, and target_subdir. The values are determined
45 dnl # here so that they can (theoretically) be changed in the future. They
46 dnl # were previously reproduced across many different files.
48 dnl # This logic really amounts to very little with autoconf 2.13; it will
49 dnl # amount to a lot more with autoconf 2.5x.
50 AC_DEFUN([GCC_TOPLEV_SUBDIRS],
51 [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
52 AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
53 # Prefix 'build-' so this never conflicts with target_subdir.
54 build_subdir="build-${build_noncanonical}"
55 # Not really a subdirectory, but here for completeness.
58 target_subdir=${target_noncanonical}
59 AC_SUBST([build_subdir]) []dnl
60 AC_SUBST([host_subdir]) []dnl
61 AC_SUBST([target_subdir]) []dnl
62 ]) []dnl # GCC_TOPLEV_SUBDIRS
66 # _NCN_TOOL_PREFIXES: Some stuff that oughtta be done in AC_CANONICAL_SYSTEM
68 # These demand that AC_CANONICAL_SYSTEM be called beforehand.
69 AC_DEFUN([_NCN_TOOL_PREFIXES],
71 test -n "$host_alias" && ncn_tool_prefix=$host_alias-
72 ncn_target_tool_prefix=
73 test -n "$target_alias" && ncn_target_tool_prefix=$target_alias-
74 ]) []dnl # _NCN_TOOL_PREFIXES
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.
81 AC_DEFUN([NCN_CHECK_TARGET_TOOL],
82 [AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
83 if test -n "$ncn_target_tool_prefix"; then
84 AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}$2],
85 [${ncn_target_tool_prefix}$2], , [$4])
87 if test -z "$ac_cv_prog_$1" ; then
89 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [$3], [$4])
94 ]) []dnl # NCN_CHECK_TARGET_TOOL
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.
101 AC_DEFUN([NCN_STRICT_CHECK_TOOL],
102 [AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
103 if test -n "$ncn_tool_prefix"; then
104 AC_CHECK_PROG([$1], [${ncn_tool_prefix}$2],
105 [${ncn_tool_prefix}$2], , [$4])
107 if test -z "$ac_cv_prog_$1" ; then
108 if test $build = $host ; then
110 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [ifelse([$3],[],[$2],[$3])], [$4])
113 $1="ifelse([$3],[],[${ncn_tool_prefix}$2],[$3])"
118 ]) []dnl # NCN_STRICT_CHECK_TOOL
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.
125 AC_DEFUN([NCN_STRICT_CHECK_TARGET_TOOL],
126 [AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
127 if test -n "$ncn_target_tool_prefix"; then
128 AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}$2],
129 [${ncn_target_tool_prefix}$2], , [$4])
131 if test -z "$ac_cv_prog_$1" ; then
132 if test $build = $target ; then
134 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [ifelse([$3],[],[$2],[$3])], [$4])
137 $1="ifelse([$3],[],[${ncn_target_tool_prefix}$2],[$3])"
142 ]) []dnl # NCN_STRICT_CHECK_TARGET_TOOL
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.
154 AC_DEFUN([AC_PROG_CPP_WERROR],
155 [AC_REQUIRE([AC_PROG_CPP])dnl
156 m4_define([AC_CHECK_HEADER],m4_defn([_AC_CHECK_HEADER_OLD]))
157 ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
160 # We require the gnatbind program, and a compiler driver that
161 # understands Ada. We use the user's CC setting, already found.
163 # Sets the shell variable have_gnat to yes or no as appropriate, and
164 # substitutes GNATBIND.
165 AC_DEFUN([ACX_PROG_GNAT],
166 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
167 AC_REQUIRE([AC_PROG_CC])
168 AC_CHECK_TOOL(GNATBIND, gnatbind, no)
169 AC_CACHE_CHECK([whether compiler driver understands Ada],
170 acx_cv_cc_gcc_supports_ada,
171 [cat >conftest.adb <<EOF
172 procedure conftest is begin null; end conftest;
174 acx_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
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.
183 errors=`(${CC} -c conftest.adb) 2>&1 || echo failure`
184 if test x"$errors" = x && test -f conftest.$ac_objext; then
185 acx_cv_cc_gcc_supports_ada=yes
190 if test x$GNATBIND != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
197 dnl 'make compare' can be significantly faster, if cmp itself can
198 dnl skip bytes instead of using tail. The test being performed is
199 dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
200 dnl but we need to sink errors and handle broken shells. We also test
201 dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
202 dnl accepted by cmp on some systems.
203 AC_DEFUN([ACX_PROG_CMP_IGNORE_INITIAL],
204 [AC_CACHE_CHECK([how to compare bootstrapped objects], gcc_cv_prog_cmp_skip,
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
212 gcc_cv_prog_cmp_skip='cmp $$f1 $$f2 16 16'
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
219 gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
224 do_compare="$gcc_cv_prog_cmp_skip"
228 dnl See whether we can include both string.h and strings.h.
229 AC_DEFUN([ACX_HEADER_STRING],
230 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
231 gcc_cv_header_string,
232 [AC_TRY_COMPILE([#include <string.h>
233 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
234 if test $gcc_cv_header_string = yes; then
235 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
239 dnl See if stdbool.h properly defines bool and true/false.
240 dnl Check whether _Bool is built-in.
241 AC_DEFUN([ACX_HEADER_STDBOOL],
242 [AC_CACHE_CHECK([for working stdbool.h],
243 ac_cv_header_stdbool_h,
244 [AC_TRY_COMPILE([#include <stdbool.h>],
246 ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
247 if test $ac_cv_header_stdbool_h = yes; then
248 AC_DEFINE(HAVE_STDBOOL_H, 1,
249 [Define if you have a working <stdbool.h> header file.])
251 AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
254 gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
256 if test $gcc_cv_c__bool = yes; then
257 AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
261 dnl See if hard links work and if not, try to substitute $1 or simple copy.
262 AC_DEFUN([ACX_PROG_LN],
263 [AC_MSG_CHECKING(whether ln works)
264 AC_CACHE_VAL(acx_cv_prog_LN,
265 [rm -f conftestdata_t
267 if ln conftestdata_f conftestdata_t 2>/dev/null
273 rm -f conftestdata_f conftestdata_t
275 if test $acx_cv_prog_LN = no; then
276 LN="ifelse([$1],,cp,[$1])"
277 AC_MSG_RESULT([no, using $LN])