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