aclocal.m4: Fixed typo.
[gcc.git] / gcc / aclocal.m4
1 dnl See if stdbool.h properly defines bool and true/false.
2 AC_DEFUN(gcc_AC_HEADER_STDBOOL,
3 [AC_CACHE_CHECK([for working stdbool.h],
4 ac_cv_header_stdbool_h,
5 [AC_TRY_COMPILE([#include <stdbool.h>],
6 [bool foo = false;],
7 ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
8 if test $ac_cv_header_stdbool_h = yes; then
9 AC_DEFINE(HAVE_STDBOOL_H, 1,
10 [Define if you have a working <stdbool.h> header file.])
11 fi
12 ])
13
14 dnl See whether we can include both string.h and strings.h.
15 AC_DEFUN(gcc_AC_HEADER_STRING,
16 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
17 gcc_cv_header_string,
18 [AC_TRY_COMPILE([#include <string.h>
19 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
20 if test $gcc_cv_header_string = yes; then
21 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
22 fi
23 ])
24
25 dnl See whether we need a declaration for a function.
26 dnl The result is highly dependent on the INCLUDES passed in, so make sure
27 dnl to use a different cache variable name in this macro if it is invoked
28 dnl in a different context somewhere else.
29 dnl gcc_AC_CHECK_DECL(SYMBOL,
30 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
31 AC_DEFUN(gcc_AC_CHECK_DECL,
32 [AC_MSG_CHECKING([whether $1 is declared])
33 AC_CACHE_VAL(gcc_cv_have_decl_$1,
34 [AC_TRY_COMPILE([$4],
35 [#ifndef $1
36 char *(*pfn) = (char *(*)) $1 ;
37 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
38 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
39 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
40 else
41 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
42 fi
43 ])dnl
44
45 dnl Check multiple functions to see whether each needs a declaration.
46 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
47 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
48 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
49 AC_DEFUN(gcc_AC_CHECK_DECLS,
50 [for ac_func in $1
51 do
52 changequote(, )dnl
53 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
54 changequote([, ])dnl
55 gcc_AC_CHECK_DECL($ac_func,
56 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
57 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
58 dnl It is possible that the include files passed in here are local headers
59 dnl which supply a backup declaration for the relevant prototype based on
60 dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
61 dnl will always return success. E.g. see libiberty.h's handling of
62 dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
63 dnl 1 so that any local headers used do not provide their own prototype
64 dnl during this test.
65 #undef $ac_tr_decl
66 #define $ac_tr_decl 1
67 $4
68 )
69 done
70 dnl Automatically generate config.h entries via autoheader.
71 if test x = y ; then
72 patsubst(translit([$1], [a-z], [A-Z]), [\w+],
73 AC_DEFINE([HAVE_DECL_\&], 1,
74 [Define to 1 if we found this declaration otherwise define to 0.]))dnl
75 fi
76 ])
77
78 dnl Check if we have vprintf and possibly _doprnt.
79 dnl Note autoconf checks for vprintf even though we care about vfprintf.
80 AC_DEFUN(gcc_AC_FUNC_VFPRINTF_DOPRNT,
81 [AC_FUNC_VPRINTF
82 vfprintf=
83 doprint=
84 if test $ac_cv_func_vprintf != yes ; then
85 vfprintf=vfprintf.o
86 if test $ac_cv_func__doprnt != yes ; then
87 doprint=doprint.o
88 fi
89 fi
90 AC_SUBST(vfprintf)
91 AC_SUBST(doprint)
92 ])
93
94 dnl Check if we have strstr.
95 AC_DEFUN([gcc_AC_FUNC_STRSTR],
96 [AC_CHECK_FUNCS([strstr], [strstr=], [strstr=strstr.o])
97 AC_SUBST([strstr])])
98
99 dnl See if the printf functions in libc support %p in format strings.
100 AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
101 [AC_CACHE_CHECK(whether the printf functions support %p,
102 gcc_cv_func_printf_ptr,
103 [AC_TRY_RUN([#include <stdio.h>
104
105 int main()
106 {
107 char buf[64];
108 char *p = buf, *q = NULL;
109 sprintf(buf, "%p", p);
110 sscanf(buf, "%p", &q);
111 return (p != q);
112 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
113 gcc_cv_func_printf_ptr=no)
114 rm -f core core.* *.core])
115 if test $gcc_cv_func_printf_ptr = yes ; then
116 AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
117 fi
118 ])
119
120 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
121 AC_DEFUN(gcc_AC_PROG_LN_S,
122 [AC_MSG_CHECKING(whether ln -s works)
123 AC_CACHE_VAL(gcc_cv_prog_LN_S,
124 [rm -f conftestdata_t
125 echo >conftestdata_f
126 if ln -s conftestdata_f conftestdata_t 2>/dev/null
127 then
128 gcc_cv_prog_LN_S="ln -s"
129 else
130 if ln conftestdata_f conftestdata_t 2>/dev/null
131 then
132 gcc_cv_prog_LN_S=ln
133 else
134 gcc_cv_prog_LN_S=cp
135 fi
136 fi
137 rm -f conftestdata_f conftestdata_t
138 ])dnl
139 LN_S="$gcc_cv_prog_LN_S"
140 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
141 AC_MSG_RESULT(yes)
142 else
143 if test "$gcc_cv_prog_LN_S" = "ln"; then
144 AC_MSG_RESULT([no, using ln])
145 else
146 AC_MSG_RESULT([no, and neither does ln, so using cp])
147 fi
148 fi
149 AC_SUBST(LN_S)dnl
150 ])
151
152 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
153 AC_DEFUN(gcc_AC_PROG_LN,
154 [AC_MSG_CHECKING(whether ln works)
155 AC_CACHE_VAL(gcc_cv_prog_LN,
156 [rm -f conftestdata_t
157 echo >conftestdata_f
158 if ln conftestdata_f conftestdata_t 2>/dev/null
159 then
160 gcc_cv_prog_LN="ln"
161 else
162 if ln -s conftestdata_f conftestdata_t 2>/dev/null
163 then
164 gcc_cv_prog_LN="ln -s"
165 else
166 gcc_cv_prog_LN=cp
167 fi
168 fi
169 rm -f conftestdata_f conftestdata_t
170 ])dnl
171 LN="$gcc_cv_prog_LN"
172 if test "$gcc_cv_prog_LN" = "ln"; then
173 AC_MSG_RESULT(yes)
174 else
175 if test "$gcc_cv_prog_LN" = "ln -s"; then
176 AC_MSG_RESULT([no, using ln -s])
177 else
178 AC_MSG_RESULT([no, and neither does ln -s, so using cp])
179 fi
180 fi
181 AC_SUBST(LN)dnl
182 ])
183
184 dnl See whether the stage1 host compiler accepts the volatile keyword.
185 AC_DEFUN(gcc_AC_C_VOLATILE,
186 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
187 [AC_TRY_COMPILE(, [volatile int foo;],
188 gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
189 if test $gcc_cv_c_volatile = yes ; then
190 AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.])
191 fi
192 ])
193
194 dnl Check whether long double is supported. This differs from the
195 dnl built-in autoconf test in that it works for cross compiles.
196 AC_DEFUN(gcc_AC_C_LONG_DOUBLE,
197 [AC_CACHE_CHECK(for long double, gcc_cv_c_long_double,
198 [if test "$GCC" = yes; then
199 gcc_cv_c_long_double=yes
200 else
201 AC_TRY_COMPILE(,
202 [/* The Stardent Vistra knows sizeof(long double), but does not support it. */
203 long double foo = 0.0;
204 /* On Ultrix 4.3 cc, long double is 4 and double is 8. */
205 switch (0) case 0: case (sizeof(long double) >= sizeof(double)):;],
206 gcc_cv_c_long_double=yes, gcc_cv_c_long_double=no)
207 fi])
208 if test $gcc_cv_c_long_double = yes; then
209 AC_DEFINE(HAVE_LONG_DOUBLE)
210 fi
211 ])
212
213 dnl Check whether _Bool is built-in.
214 AC_DEFUN(gcc_AC_C__BOOL,
215 [AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
216 [AC_TRY_COMPILE(,
217 [_Bool foo;],
218 gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
219 ])
220 if test $gcc_cv_c__bool = yes; then
221 AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
222 fi
223 ])
224
225 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
226 dnl of the usual 2.
227 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
228 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
229 [AC_TRY_COMPILE([
230 #include <sys/types.h>
231 #ifdef HAVE_SYS_STAT_H
232 # include <sys/stat.h>
233 #endif
234 #ifdef HAVE_UNISTD_H
235 # include <unistd.h>
236 #endif
237 #ifdef HAVE_DIRECT_H
238 # include <direct.h>
239 #endif], [mkdir ("foo", 0);],
240 gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
241 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
242 AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
243 fi
244 ])
245
246 AC_DEFUN(gcc_AC_PROG_INSTALL,
247 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
248 # Find a good install program. We prefer a C program (faster),
249 # so one script is as good as another. But avoid the broken or
250 # incompatible versions:
251 # SysV /etc/install, /usr/sbin/install
252 # SunOS /usr/etc/install
253 # IRIX /sbin/install
254 # AIX /bin/install
255 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
256 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
257 # ./install, which can be erroneously created by make from ./install.sh.
258 AC_MSG_CHECKING(for a BSD compatible install)
259 if test -z "$INSTALL"; then
260 AC_CACHE_VAL(ac_cv_path_install,
261 [ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
262 for ac_dir in $PATH; do
263 # Account for people who put trailing slashes in PATH elements.
264 case "$ac_dir/" in
265 /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
266 *)
267 # OSF1 and SCO ODT 3.0 have their own names for install.
268 for ac_prog in ginstall scoinst install; do
269 if test -f $ac_dir/$ac_prog; then
270 if test $ac_prog = install &&
271 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
272 # AIX install. It has an incompatible calling convention.
273 # OSF/1 installbsd also uses dspmsg, but is usable.
274 :
275 else
276 ac_cv_path_install="$ac_dir/$ac_prog -c"
277 break 2
278 fi
279 fi
280 done
281 ;;
282 esac
283 done
284 IFS="$ac_save_IFS"
285 ])dnl
286 if test "${ac_cv_path_install+set}" = set; then
287 INSTALL="$ac_cv_path_install"
288 else
289 # As a last resort, use the slow shell script. We don't cache a
290 # path for INSTALL within a source directory, because that will
291 # break other packages using the cache if that directory is
292 # removed, or if the path is relative.
293 INSTALL="$ac_install_sh"
294 fi
295 fi
296 dnl We do special magic for INSTALL instead of AC_SUBST, to get
297 dnl relative paths right.
298 AC_MSG_RESULT($INSTALL)
299 AC_SUBST(INSTALL)dnl
300
301 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
302 # It thinks the first close brace ends the variable substitution.
303 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
304 AC_SUBST(INSTALL_PROGRAM)dnl
305
306 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
307 AC_SUBST(INSTALL_DATA)dnl
308 ])
309
310 #serial 1
311 dnl This test replaces the one in autoconf.
312 dnl Currently this macro should have the same name as the autoconf macro
313 dnl because gettext's gettext.m4 (distributed in the automake package)
314 dnl still uses it. Otherwise, the use in gettext.m4 makes autoheader
315 dnl give these diagnostics:
316 dnl configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
317 dnl configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
318
319 undefine([AC_ISC_POSIX])
320 AC_DEFUN(AC_ISC_POSIX,
321 [
322 dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
323 AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
324 ]
325 )
326
327
328 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
329 dnl like AC_PATH_PROG but use other cache variables
330 AC_DEFUN(GCC_PATH_PROG,
331 [# Extract the first word of "$2", so it can be a program name with args.
332 set dummy $2; ac_word=[$]2
333 AC_MSG_CHECKING([for $ac_word])
334 AC_CACHE_VAL(gcc_cv_path_$1,
335 [case "[$]$1" in
336 /*)
337 gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
338 ;;
339 ?:/*)
340 gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
341 ;;
342 *)
343 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
344 dnl $ac_dummy forces splitting on constant user-supplied paths.
345 dnl POSIX.2 word splitting is done only on the output of word expansions,
346 dnl not every word. This closes a longstanding sh security hole.
347 ac_dummy="ifelse([$4], , $PATH, [$4])"
348 for ac_dir in $ac_dummy; do
349 test -z "$ac_dir" && ac_dir=.
350 if test -f $ac_dir/$ac_word; then
351 gcc_cv_path_$1="$ac_dir/$ac_word"
352 break
353 fi
354 done
355 IFS="$ac_save_ifs"
356 dnl If no 3rd arg is given, leave the cache variable unset,
357 dnl so GCC_PATH_PROGS will keep looking.
358 ifelse([$3], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
359 ])dnl
360 ;;
361 esac])dnl
362 $1="$gcc_cv_path_$1"
363 if test -n "[$]$1"; then
364 AC_MSG_RESULT([$]$1)
365 else
366 AC_MSG_RESULT(no)
367 fi
368 AC_SUBST($1)dnl
369 ])
370
371
372
373 # Macro to add for using GNU gettext.
374 # Ulrich Drepper <drepper@cygnus.com>, 1995.
375 #
376 # This file can be copied and used freely without restrictions. It can
377 # be used in projects which are not available under the GNU Public License
378 # but which still want to provide support for the GNU gettext functionality.
379 # Please note that the actual code is *not* freely available.
380
381 # serial 5
382
383 AC_DEFUN(AM_WITH_NLS,
384 [AC_MSG_CHECKING([whether NLS is requested])
385 dnl Default is enabled NLS
386 AC_ARG_ENABLE(nls,
387 [ --disable-nls do not use Native Language Support],
388 USE_NLS=$enableval, USE_NLS=yes)
389 AC_MSG_RESULT($USE_NLS)
390 AC_SUBST(USE_NLS)
391
392 USE_INCLUDED_LIBINTL=no
393
394 dnl If we use NLS figure out what method
395 if test "$USE_NLS" = "yes"; then
396 AC_DEFINE(ENABLE_NLS)
397 AC_MSG_CHECKING([whether included gettext is requested])
398 AC_ARG_WITH(included-gettext,
399 [ --with-included-gettext use the GNU gettext library included here],
400 nls_cv_force_use_gnu_gettext=$withval,
401 nls_cv_force_use_gnu_gettext=no)
402 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
403
404 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
405 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
406 dnl User does not insist on using GNU NLS library. Figure out what
407 dnl to use. If gettext or catgets are available (in this order) we
408 dnl use this. Else we have to fall back to GNU NLS library.
409 dnl catgets is only used if permitted by option --with-catgets.
410 nls_cv_header_intl=
411 nls_cv_header_libgt=
412 CATOBJEXT=NONE
413
414 AC_CHECK_HEADER(libintl.h,
415 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
416 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
417 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
418
419 if test "$gt_cv_func_gettext_libc" != "yes"; then
420 AC_CHECK_LIB(intl, bindtextdomain,
421 [AC_CACHE_CHECK([for gettext in libintl],
422 gt_cv_func_gettext_libintl,
423 [AC_CHECK_LIB(intl, gettext,
424 gt_cv_func_gettext_libintl=yes,
425 gt_cv_func_gettext_libintl=no)],
426 gt_cv_func_gettext_libintl=no)])
427 fi
428
429 if test "$gt_cv_func_gettext_libintl" = "yes"; then
430 LIBS="-lintl $LIBS"
431 fi
432
433 if test "$gt_cv_func_gettext_libc" = "yes" \
434 || test "$gt_cv_func_gettext_libintl" = "yes"; then
435 AC_DEFINE(HAVE_GETTEXT)
436 GCC_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
437 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
438 if test "$MSGFMT" != "no"; then
439 AC_CHECK_FUNCS(dcgettext)
440 GCC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
441 GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
442 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
443 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
444 return _nl_msg_cat_cntr],
445 [CATOBJEXT=.gmo
446 DATADIRNAME=share],
447 [CATOBJEXT=.mo
448 DATADIRNAME=lib])
449 INSTOBJEXT=.mo
450 else
451 create_catalogs="no"
452 fi
453 fi
454 ])
455
456 if test "$CATOBJEXT" = "NONE"; then
457 AC_MSG_CHECKING([whether catgets can be used])
458 AC_ARG_WITH(catgets,
459 [ --with-catgets use catgets functions if available],
460 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
461 AC_MSG_RESULT($nls_cv_use_catgets)
462
463 if test "$nls_cv_use_catgets" = "yes"; then
464 dnl No gettext in C library. Try catgets next.
465 AC_CHECK_LIB(i, main)
466 AC_CHECK_FUNC(catgets,
467 [AC_DEFINE(HAVE_CATGETS)
468 INTLOBJS="\$(CATOBJS)"
469 GCC_PATH_PROG(GENCAT, gencat, no)dnl
470 if test "$GENCAT" != "no"; then
471 GCC_PATH_PROG(GMSGFMT, gmsgfmt, no)
472 if test "$GMSGFMT" = "no"; then
473 GCC_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
474 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
475 if test "$GMSGFMT" = "msgfmt"; then
476 create_catalogs="no"
477 fi
478 fi
479 GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
480 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
481 USE_INCLUDED_LIBINTL=yes
482 CATOBJEXT=.cat
483 INSTOBJEXT=.cat
484 DATADIRNAME=lib
485 INTLDEPS='$(top_builddir)/intl/libintl.a'
486 INTLLIBS=$INTLDEPS
487 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
488 nls_cv_header_intl=intl/libintl.h
489 nls_cv_header_libgt=intl/libgettext.h
490 fi])
491 fi
492 fi
493
494 if test "$CATOBJEXT" = "NONE"; then
495 dnl Neither gettext nor catgets in included in the C library.
496 dnl Fall back on GNU gettext library.
497 nls_cv_use_gnu_gettext=yes
498 fi
499 fi
500
501 if test "$nls_cv_use_gnu_gettext" = "yes"; then
502 dnl Mark actions used to generate GNU NLS library.
503 INTLOBJS="\$(GETTOBJS)"
504 GCC_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
505 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
506 GCC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
507 dnl If we didn't find either msgfmt or gmsgfmt, don't try to
508 dnl create a catalog.
509 if test "$MSGFMT" = "msgfmt" && test "$GMSGFMT" = "msgfmt"; then
510 create_catalogs="no"
511 fi
512 GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
513 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
514 AC_SUBST(MSGFMT)
515 USE_INCLUDED_LIBINTL=yes
516 CATOBJEXT=.gmo
517 INSTOBJEXT=.mo
518 DATADIRNAME=share
519 INTLDEPS='$(top_builddir)/intl/libintl.a'
520 INTLLIBS=$INTLDEPS
521 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
522 nls_cv_header_intl=intl/libintl.h
523 nls_cv_header_libgt=intl/libgettext.h
524 fi
525
526 dnl Test whether we really found GNU xgettext.
527 if test "$XGETTEXT" != ":"; then
528 dnl If it is no GNU xgettext we define it as : so that the
529 dnl Makefiles still can work.
530 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
531 : ;
532 else
533 AC_MSG_RESULT(
534 [found xgettext program is not GNU xgettext; ignore it])
535 XGETTEXT=":"
536 fi
537 fi
538
539
540
541 # We need to process the po/ directory.
542 POSUB=po
543 else
544 DATADIRNAME=share
545 nls_cv_header_intl=intl/libintl.h
546 nls_cv_header_libgt=intl/libgettext.h
547 fi
548 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
549 AC_OUTPUT_COMMANDS(
550 [case "$CONFIG_FILES" in *po/Makefile.in*)
551 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
552 esac])
553
554
555 # If this is used in GNU gettext we have to set USE_NLS to `yes'
556 # because some of the sources are only built for this goal.
557 if test "$PACKAGE" = gettext; then
558 USE_NLS=yes
559 USE_INCLUDED_LIBINTL=yes
560 fi
561
562 dnl These rules are solely for the distribution goal. While doing this
563 dnl we only have to keep exactly one list of the available catalogs
564 dnl in configure.in.
565 for lang in $ALL_LINGUAS; do
566 GMOFILES="$GMOFILES $lang.gmo"
567 POFILES="$POFILES $lang.po"
568 done
569
570 dnl Make all variables we use known to autoconf.
571 AC_SUBST(USE_INCLUDED_LIBINTL)
572 AC_SUBST(CATALOGS)
573 AC_SUBST(CATOBJEXT)
574 AC_SUBST(DATADIRNAME)
575 AC_SUBST(GMOFILES)
576 AC_SUBST(INSTOBJEXT)
577 AC_SUBST(INTLDEPS)
578 AC_SUBST(INTLLIBS)
579 AC_SUBST(INTLOBJS)
580 AC_SUBST(POFILES)
581 AC_SUBST(POSUB)
582 ])
583
584 AC_DEFUN(AM_GNU_GETTEXT,
585 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
586 AC_REQUIRE([AC_PROG_CC])dnl
587 AC_REQUIRE([AC_PROG_RANLIB])dnl
588 AC_REQUIRE([AC_ISC_POSIX])dnl
589 AC_REQUIRE([AC_HEADER_STDC])dnl
590 AC_REQUIRE([AC_C_CONST])dnl
591 AC_REQUIRE([AC_C_INLINE])dnl
592 AC_REQUIRE([AC_TYPE_OFF_T])dnl
593 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
594
595 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
596 unistd.h sys/param.h])
597 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
598 strdup __argz_count __argz_stringify __argz_next])
599
600 if test "${ac_cv_func_stpcpy+set}" != "set"; then
601 AC_CHECK_FUNCS(stpcpy)
602 fi
603 if test "${ac_cv_func_stpcpy}" = "yes"; then
604 AC_DEFINE(HAVE_STPCPY)
605 fi
606
607 AM_LC_MESSAGES
608 AM_WITH_NLS
609
610 if test "x$create_catalogs" = "xno"; then
611 AC_MSG_WARN([No program for building catalogs found -> building disabled])
612 fi
613
614 if test "x$CATOBJEXT" != "x" && test "x$create_catalogs" != "xno" ; then
615 if test "x$ALL_LINGUAS" = "x"; then
616 LINGUAS=
617 else
618 AC_MSG_CHECKING(for catalogs to be installed)
619 if test "x$LINGUAS" = "x"; then
620 LINGUAS=$ALL_LINGUAS
621 else
622 NEW_LINGUAS=
623 for lang in $ALL_LINGUAS; do
624 case " $LINGUAS " in
625 *" $lang "*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
626 esac
627 done
628 LINGUAS=$NEW_LINGUAS
629 fi
630 AC_MSG_RESULT($LINGUAS)
631 fi
632
633 dnl Construct list of names of catalog files to be constructed.
634 if test -n "$LINGUAS"; then
635 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
636 fi
637 fi
638
639 dnl The reference to <locale.h> in the installed <libintl.h> file
640 dnl must be resolved because we cannot expect the users of this
641 dnl to define HAVE_LOCALE_H.
642 if test $ac_cv_header_locale_h = yes; then
643 INCLUDE_LOCALE_H="#include <locale.h>"
644 else
645 INCLUDE_LOCALE_H="\
646 /* The system does not provide the header <locale.h>. Take care yourself. */"
647 fi
648 AC_SUBST(INCLUDE_LOCALE_H)
649
650 dnl Determine which catalog format we have (if any is needed)
651 dnl For now we know about two different formats:
652 dnl Linux libc-5 and the normal X/Open format
653 test -d intl || mkdir intl
654 if test "$CATOBJEXT" = ".cat"; then
655 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
656
657 dnl Transform the SED scripts while copying because some dumb SEDs
658 dnl cannot handle comments.
659 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
660 fi
661 dnl po2tbl.sed is always needed.
662 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
663 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
664
665 dnl In the intl/Makefile.in we have a special dependency which makes
666 dnl only sense for gettext. We comment this out for non-gettext
667 dnl packages.
668 if test "$PACKAGE" = "gettext"; then
669 GT_NO="#NO#"
670 GT_YES=
671 else
672 GT_NO=
673 GT_YES="#YES#"
674 fi
675 AC_SUBST(GT_NO)
676 AC_SUBST(GT_YES)
677
678 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
679 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
680 dnl Try to locate is.
681 MKINSTALLDIRS=
682 if test -n "$ac_aux_dir"; then
683 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
684 fi
685 if test -z "$MKINSTALLDIRS"; then
686 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
687 fi
688 AC_SUBST(MKINSTALLDIRS)
689
690 dnl *** For now the libtool support in intl/Makefile is not for real.
691 l=
692 AC_SUBST(l)
693
694 dnl Generate list of files to be processed by xgettext which will
695 dnl be included in po/Makefile.
696 test -d po || mkdir po
697 if test "x$srcdir" != "x."; then
698 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
699 posrcprefix="$srcdir/"
700 else
701 posrcprefix="../$srcdir/"
702 fi
703 else
704 posrcprefix="../"
705 fi
706 rm -f po/POTFILES
707 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
708 < $srcdir/po/POTFILES.in > po/POTFILES
709 ])
710
711 # Check whether LC_MESSAGES is available in <locale.h>.
712 # Ulrich Drepper <drepper@cygnus.com>, 1995.
713 #
714 # This file can be copied and used freely without restrictions. It can
715 # be used in projects which are not available under the GNU Public License
716 # but which still want to provide support for the GNU gettext functionality.
717 # Please note that the actual code is *not* freely available.
718
719 # serial 1
720
721 AC_DEFUN(AM_LC_MESSAGES,
722 [if test $ac_cv_header_locale_h = yes; then
723 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
724 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
725 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
726 if test $am_cv_val_LC_MESSAGES = yes; then
727 AC_DEFINE(HAVE_LC_MESSAGES)
728 fi
729 fi])
730
731 # Search path for a program which passes the given test.
732 # Ulrich Drepper <drepper@cygnus.com>, 1996.
733 #
734 # This file can be copied and used freely without restrictions. It can
735 # be used in projects which are not available under the GNU Public License
736 # but which still want to provide support for the GNU gettext functionality.
737 # Please note that the actual code is *not* freely available.
738
739 # serial 1
740
741 dnl GCC_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
742 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
743 AC_DEFUN(GCC_PATH_PROG_WITH_TEST,
744 [# Extract the first word of "$2", so it can be a program name with args.
745 set dummy $2; ac_word=[$]2
746 AC_MSG_CHECKING([for $ac_word])
747 AC_CACHE_VAL(gcc_cv_path_$1,
748 [case "[$]$1" in
749 /*)
750 gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
751 ;;
752 *)
753 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
754 for ac_dir in ifelse([$5], , $PATH, [$5]); do
755 test -z "$ac_dir" && ac_dir=.
756 if test -f $ac_dir/$ac_word; then
757 if [$3]; then
758 gcc_cv_path_$1="$ac_dir/$ac_word"
759 break
760 fi
761 fi
762 done
763 IFS="$ac_save_ifs"
764 dnl If no 4th arg is given, leave the cache variable unset,
765 dnl so GCC_PATH_PROGS will keep looking.
766 ifelse([$4], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$4"
767 ])dnl
768 ;;
769 esac])dnl
770 $1="$gcc_cv_path_$1"
771 if test -n "[$]$1"; then
772 AC_MSG_RESULT([$]$1)
773 else
774 AC_MSG_RESULT(no)
775 fi
776 AC_SUBST($1)dnl
777 ])
778
779 # Check whether mmap can map an arbitrary page from /dev/zero or with
780 # MAP_ANONYMOUS, without MAP_FIXED.
781 AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
782 [AC_CHECK_FUNCS(getpagesize)
783 # The test program for the next two tests is the same except for one
784 # set of ifdefs.
785 changequote({{{,}}})dnl
786 {{{cat >ct-mmap.inc <<'EOF'
787 #include <sys/types.h>
788 #include <sys/mman.h>
789 #include <fcntl.h>
790 #include <signal.h>
791 #include <setjmp.h>
792 #include <stdio.h>
793
794 #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
795 # define MAP_ANONYMOUS MAP_ANON
796 #endif
797
798 /* This mess was copied from the GNU getpagesize.h. */
799 #ifndef HAVE_GETPAGESIZE
800 # ifdef HAVE_UNISTD_H
801 # include <unistd.h>
802 # endif
803
804 /* Assume that all systems that can run configure have sys/param.h. */
805 # ifndef HAVE_SYS_PARAM_H
806 # define HAVE_SYS_PARAM_H 1
807 # endif
808
809 # ifdef _SC_PAGESIZE
810 # define getpagesize() sysconf(_SC_PAGESIZE)
811 # else /* no _SC_PAGESIZE */
812 # ifdef HAVE_SYS_PARAM_H
813 # include <sys/param.h>
814 # ifdef EXEC_PAGESIZE
815 # define getpagesize() EXEC_PAGESIZE
816 # else /* no EXEC_PAGESIZE */
817 # ifdef NBPG
818 # define getpagesize() NBPG * CLSIZE
819 # ifndef CLSIZE
820 # define CLSIZE 1
821 # endif /* no CLSIZE */
822 # else /* no NBPG */
823 # ifdef NBPC
824 # define getpagesize() NBPC
825 # else /* no NBPC */
826 # ifdef PAGESIZE
827 # define getpagesize() PAGESIZE
828 # endif /* PAGESIZE */
829 # endif /* no NBPC */
830 # endif /* no NBPG */
831 # endif /* no EXEC_PAGESIZE */
832 # else /* no HAVE_SYS_PARAM_H */
833 # define getpagesize() 8192 /* punt totally */
834 # endif /* no HAVE_SYS_PARAM_H */
835 # endif /* no _SC_PAGESIZE */
836
837 #endif /* no HAVE_GETPAGESIZE */
838
839 #ifndef MAP_FAILED
840 # define MAP_FAILED -1
841 #endif
842
843 #undef perror_exit
844 #define perror_exit(str, val) \
845 do { perror(str); exit(val); } while (0)
846
847 /* Some versions of cygwin mmap require that munmap is called with the
848 same parameters as mmap. GCC expects that this is not the case.
849 Test for various forms of this problem. Warning - icky signal games. */
850
851 static sigset_t unblock_sigsegv;
852 static jmp_buf r;
853 static size_t pg;
854 static int devzero;
855
856 static char *
857 anonmap (size)
858 size_t size;
859 {
860 #ifdef USE_MAP_ANON
861 return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
862 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
863 #else
864 return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
865 MAP_PRIVATE, devzero, 0);
866 #endif
867 }
868
869 static void
870 sigsegv (unused)
871 int unused;
872 {
873 sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0);
874 longjmp (r, 1);
875 }
876
877 /* Basic functionality test. */
878 void
879 test_0 ()
880 {
881 char *x = anonmap (pg);
882 if (x == (char *) MAP_FAILED)
883 perror_exit("test 0 mmap", 2);
884
885 *(int *)x += 1;
886
887 if (munmap(x, pg) < 0)
888 perror_exit("test 0 munmap", 3);
889 }
890
891 /* 1. If we map a 2-page region and unmap its second page, the first page
892 must remain. */
893 static void
894 test_1 ()
895 {
896 char *x = anonmap (pg * 2);
897 if (x == (char *)MAP_FAILED)
898 perror_exit ("test 1 mmap", 4);
899
900 signal (SIGSEGV, sigsegv);
901 if (setjmp (r))
902 perror_exit ("test 1 fault", 5);
903
904 x[0] = 1;
905 x[pg] = 1;
906
907 if (munmap (x + pg, pg) < 0)
908 perror_exit ("test 1 munmap 1", 6);
909 x[0] = 2;
910
911 if (setjmp (r) == 0)
912 {
913 x[pg] = 1;
914 perror_exit ("test 1 no fault", 7);
915 }
916 if (munmap (x, pg) < 0)
917 perror_exit ("test 1 munmap 2", 8);
918 }
919
920 /* 2. If we map a 2-page region and unmap its first page, the second
921 page must remain. */
922 static void
923 test_2 ()
924 {
925 char *x = anonmap (pg * 2);
926 if (x == (char *)MAP_FAILED)
927 perror_exit ("test 2 mmap", 9);
928
929 signal (SIGSEGV, sigsegv);
930 if (setjmp (r))
931 perror_exit ("test 2 fault", 10);
932
933 x[0] = 1;
934 x[pg] = 1;
935
936 if (munmap (x, pg) < 0)
937 perror_exit ("test 2 munmap 1", 11);
938
939 x[pg] = 2;
940
941 if (setjmp (r) == 0)
942 {
943 x[0] = 1;
944 perror_exit ("test 2 no fault", 12);
945 }
946
947 if (munmap (x+pg, pg) < 0)
948 perror_exit ("test 2 munmap 2", 13);
949 }
950
951 /* 3. If we map two adjacent 1-page regions and unmap them both with
952 one munmap, both must go away.
953
954 Getting two adjacent 1-page regions with two mmap calls is slightly
955 tricky. All OS's tested skip over already-allocated blocks; therefore
956 we have been careful to unmap all allocated regions in previous tests.
957 HP/UX allocates pages backward in memory. No OS has yet been observed
958 to be so perverse as to leave unmapped space between consecutive calls
959 to mmap. */
960
961 static void
962 test_3 ()
963 {
964 char *x, *y, *z;
965
966 x = anonmap (pg);
967 if (x == (char *)MAP_FAILED)
968 perror_exit ("test 3 mmap 1", 14);
969 y = anonmap (pg);
970 if (y == (char *)MAP_FAILED)
971 perror_exit ("test 3 mmap 2", 15);
972
973 if (y != x + pg)
974 {
975 if (y == x - pg)
976 z = y, y = x, x = z;
977 else
978 {
979 fprintf (stderr, "test 3 nonconsecutive pages - %lx, %lx\n",
980 (unsigned long)x, (unsigned long)y);
981 exit (16);
982 }
983 }
984
985 signal (SIGSEGV, sigsegv);
986 if (setjmp (r))
987 perror_exit ("test 3 fault", 17);
988
989 x[0] = 1;
990 y[0] = 1;
991
992 if (munmap (x, pg*2) < 0)
993 perror_exit ("test 3 munmap", 18);
994
995 if (setjmp (r) == 0)
996 {
997 x[0] = 1;
998 perror_exit ("test 3 no fault 1", 19);
999 }
1000
1001 signal (SIGSEGV, sigsegv);
1002 if (setjmp (r) == 0)
1003 {
1004 y[0] = 1;
1005 perror_exit ("test 3 no fault 2", 20);
1006 }
1007 }
1008
1009 int
1010 main ()
1011 {
1012 sigemptyset (&unblock_sigsegv);
1013 sigaddset (&unblock_sigsegv, SIGSEGV);
1014 pg = getpagesize ();
1015 #ifndef USE_MAP_ANON
1016 devzero = open ("/dev/zero", O_RDWR);
1017 if (devzero < 0)
1018 perror_exit ("open /dev/zero", 1);
1019 #endif
1020
1021 test_0();
1022 test_1();
1023 test_2();
1024 test_3();
1025
1026 exit(0);
1027 }
1028 EOF}}}
1029 changequote([,])dnl
1030
1031 AC_CACHE_CHECK(for working mmap from /dev/zero,
1032 ac_cv_func_mmap_dev_zero,
1033 [AC_TRY_RUN(
1034 [#include "ct-mmap.inc"],
1035 ac_cv_func_mmap_dev_zero=yes,
1036 [if test $? -lt 4
1037 then ac_cv_func_mmap_dev_zero=no
1038 else ac_cv_func_mmap_dev_zero=buggy
1039 fi],
1040 # If this is not cygwin, and /dev/zero is a character device, it's probably
1041 # safe to assume it works.
1042 [case "$host_os" in
1043 cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;;
1044 * ) if test -c /dev/zero
1045 then ac_cv_func_mmap_dev_zero=yes
1046 else ac_cv_func_mmap_dev_zero=no
1047 fi ;;
1048 esac])
1049 ])
1050 if test $ac_cv_func_mmap_dev_zero = yes; then
1051 AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
1052 [Define if mmap can get us zeroed pages from /dev/zero.])
1053 fi
1054
1055 AC_CACHE_CHECK([for working mmap with MAP_ANON(YMOUS)],
1056 ac_cv_func_mmap_anon,
1057 [AC_TRY_RUN(
1058 [#define USE_MAP_ANON
1059 #include "ct-mmap.inc"],
1060 ac_cv_func_mmap_anon=yes,
1061 [if test $? -lt 4
1062 then ac_cv_func_mmap_anon=no
1063 else ac_cv_func_mmap_anon=buggy
1064 fi],
1065 # Unlike /dev/zero, it is not safe to assume MAP_ANON(YMOUS) works
1066 # just because it's there. Some SCO Un*xen define it but don't implement it.
1067 ac_cv_func_mmap_anon=no)
1068 ])
1069 if test $ac_cv_func_mmap_anon = yes; then
1070 AC_DEFINE(HAVE_MMAP_ANON, 1,
1071 [Define if mmap can get us zeroed pages using MAP_ANON(YMOUS).])
1072 fi
1073 rm -f ct-mmap.inc
1074 ])
1075
1076 # Check whether mmap can map a plain file, without MAP_FIXED.
1077 AC_DEFUN([AC_FUNC_MMAP_FILE],
1078 [AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file,
1079 [# Create a file one thousand bytes long.
1080 for i in 1 2 3 4 5 6 7 8 9 0
1081 do for j in 1 2 3 4 5 6 7 8 9 0
1082 do echo $i $j xxxxx
1083 done
1084 done > conftestdata$$
1085
1086 AC_TRY_RUN([
1087 /* Test by Zack Weinberg. Modified from MMAP_ANYWHERE test by
1088 Richard Henderson and Alexandre Oliva.
1089 Check whether read-only mmap of a plain file works. */
1090 #include <sys/types.h>
1091 #include <sys/stat.h>
1092 #include <fcntl.h>
1093 #include <sys/mman.h>
1094
1095 int main()
1096 {
1097 char *x;
1098 int fd;
1099 struct stat st;
1100
1101 fd = open("conftestdata$$", O_RDONLY);
1102 if (fd < 0)
1103 exit(1);
1104
1105 if (fstat (fd, &st))
1106 exit(2);
1107
1108 x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
1109 if (x == (char *) -1)
1110 exit(3);
1111
1112 if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
1113 exit(4);
1114
1115 if (munmap(x, st.st_size) < 0)
1116 exit(5);
1117
1118 exit(0);
1119 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
1120 ac_cv_func_mmap_file=no)])
1121 if test $ac_cv_func_mmap_file = yes; then
1122 AC_DEFINE(HAVE_MMAP_FILE, 1,
1123 [Define if read-only mmap of a plain file works.])
1124 fi
1125 ])
1126
1127 dnl Locate a program and check that its version is acceptable.
1128 dnl AC_PROG_CHECK_VER(var, name, version-switch,
1129 dnl version-extract-regexp, version-glob)
1130 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
1131 [AC_CHECK_PROG([$1], [$2], [$2])
1132 if test -n "[$]$1"; then
1133 # Found it, now check the version.
1134 AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
1135 [changequote(<<,>>)dnl
1136 ac_prog_version=`<<$>>$1 $3 2>&1 |
1137 sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
1138 echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
1139 case $ac_prog_version in
1140 '') gcc_cv_prog_$2_modern=no;;
1141 <<$5>>)
1142 gcc_cv_prog_$2_modern=yes;;
1143 *) gcc_cv_prog_$2_modern=no;;
1144 esac
1145 changequote([,])dnl
1146 ])
1147 else
1148 gcc_cv_prog_$2_modern=no
1149 fi
1150 ])
1151
1152 dnl Determine if enumerated bitfields are unsigned. ISO C says they can
1153 dnl be either signed or unsigned.
1154 dnl
1155 AC_DEFUN(gcc_AC_C_ENUM_BF_UNSIGNED,
1156 [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
1157 [AC_TRY_RUN(#include <stdlib.h>
1158 enum t { BLAH = 128 } ;
1159 struct s_t { enum t member : 8; } s ;
1160 int main(void)
1161 {
1162 s.member = BLAH;
1163 if (s.member < 0) exit(1);
1164 exit(0);
1165
1166 }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
1167 if test $gcc_cv_enum_bf_unsigned = yes; then
1168 AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
1169 [Define if enumerated bitfields are treated as unsigned values.])
1170 fi])
1171
1172 dnl Host type sizes probe.
1173 dnl By Kaveh R. Ghazi. One typo fixed since.
1174 dnl
1175 AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF],
1176 [changequote(<<, >>)dnl
1177 dnl The name to #define.
1178 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
1179 dnl The cache variable name.
1180 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
1181 changequote([, ])dnl
1182 AC_MSG_CHECKING(size of $1)
1183 AC_CACHE_VAL(AC_CV_NAME,
1184 [for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
1185 AC_TRY_COMPILE([#include "confdefs.h"
1186 #include <sys/types.h>
1187 $2
1188 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
1189 if test x$AC_CV_NAME != x ; then break; fi
1190 done
1191 ])
1192 if test x$AC_CV_NAME = x ; then
1193 AC_MSG_ERROR([cannot determine a size for $1])
1194 fi
1195 AC_MSG_RESULT($AC_CV_NAME)
1196 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
1197 undefine([AC_TYPE_NAME])dnl
1198 undefine([AC_CV_NAME])dnl
1199 ])
1200
1201 dnl Probe number of bits in a byte.
1202 dnl Note C89 requires CHAR_BIT >= 8.
1203 dnl
1204 AC_DEFUN(gcc_AC_C_CHAR_BIT,
1205 [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
1206 [AC_EGREP_CPP(found,
1207 [#ifdef HAVE_LIMITS_H
1208 #include <limits.h>
1209 #endif
1210 #ifdef CHAR_BIT
1211 found
1212 #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
1213 ])
1214 if test $gcc_cv_decl_char_bit = no; then
1215 AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
1216 [i=8
1217 gcc_cv_c_nbby=
1218 while test $i -lt 65; do
1219 AC_TRY_COMPILE(,
1220 [switch(0) {
1221 case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
1222 case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
1223 ; }],
1224 [gcc_cv_c_nbby=$i; break])
1225 i=`expr $i + 1`
1226 done
1227 test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
1228 ])
1229 if test $gcc_cv_c_nbby = failed; then
1230 AC_MSG_ERROR(cannot determine number of bits in a byte)
1231 else
1232 AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
1233 [Define as the number of bits in a byte, if \`limits.h' doesn't.])
1234 fi
1235 fi])
1236
1237 dnl Checking for long long.
1238 dnl By Caolan McNamara <caolan@skynet.ie>
1239 dnl Added check for __int64, Zack Weinberg <zackw@stanford.edu>
1240 dnl
1241 AC_DEFUN([gcc_AC_C_LONG_LONG],
1242 [AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
1243 [AC_TRY_COMPILE(,[long long int i;],
1244 ac_cv_c_long_long=yes,
1245 ac_cv_c_long_long=no)])
1246 if test $ac_cv_c_long_long = yes; then
1247 AC_DEFINE(HAVE_LONG_LONG, 1,
1248 [Define if your compiler supports the \`long long' type.])
1249 fi
1250 AC_CACHE_CHECK(for __int64, ac_cv_c___int64,
1251 [AC_TRY_COMPILE(,[__int64 i;],
1252 ac_cv_c___int64=yes,
1253 ac_cv_c___int64=no)])
1254 if test $ac_cv_c___int64 = yes; then
1255 AC_DEFINE(HAVE___INT64, 1,
1256 [Define if your compiler supports the \`__int64' type.])
1257 fi
1258 ])
1259
1260 dnl Host character set probe.
1261 dnl The EBCDIC values match the table in config/i370/i370.c;
1262 dnl there are other versions of EBCDIC but GCC won't work with them.
1263 dnl
1264 AC_DEFUN([gcc_AC_C_CHARSET],
1265 [AC_CACHE_CHECK(execution character set, ac_cv_c_charset,
1266 [AC_EGREP_CPP(ASCII,
1267 [#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
1268 && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
1269 ASCII
1270 #endif], ac_cv_c_charset=ASCII)
1271 if test x${ac_cv_c_charset+set} != xset; then
1272 AC_EGREP_CPP(EBCDIC,
1273 [#if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
1274 && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
1275 EBCDIC
1276 #endif], ac_cv_c_charset=EBCDIC)
1277 fi
1278 if test x${ac_cv_c_charset+set} != xset; then
1279 ac_cv_c_charset=unknown
1280 fi])
1281 if test $ac_cv_c_charset = unknown; then
1282 AC_MSG_ERROR([*** Cannot determine host character set.])
1283 elif test $ac_cv_c_charset = EBCDIC; then
1284 AC_DEFINE(HOST_EBCDIC, 1,
1285 [Define if the host execution character set is EBCDIC.])
1286 fi])
1287
1288 dnl Utility macro used by next two tests.
1289 dnl AC_EXAMINE_OBJECT(C source code,
1290 dnl commands examining object file,
1291 dnl [commands to run if compile failed]):
1292 dnl
1293 dnl Compile the source code to an object file; then convert it into a
1294 dnl printable representation. All unprintable characters and
1295 dnl asterisks (*) are replaced by dots (.). All white space is
1296 dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
1297 dnl output, but runs of newlines are compressed to a single newline.
1298 dnl Finally, line breaks are forcibly inserted so that no line is
1299 dnl longer than 80 columns and the file ends with a newline. The
1300 dnl result of all this processing is in the file conftest.dmp, which
1301 dnl may be examined by the commands in the second argument.
1302 dnl
1303 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1304 [AC_LANG_SAVE
1305 AC_LANG_C
1306 dnl Next bit cribbed from AC_TRY_COMPILE.
1307 cat > conftest.$ac_ext <<EOF
1308 [#line __oline__ "configure"
1309 #include "confdefs.h"
1310 $1
1311 ]EOF
1312 if AC_TRY_EVAL(ac_compile); then
1313 od -c conftest.o |
1314 sed ['s/^[0-7]*[ ]*/ /
1315 s/\*/./g
1316 s/ \\n/*/g
1317 s/ [0-9][0-9][0-9]/./g
1318 s/ \\[^ ]/./g'] |
1319 tr -d '
1320 ' | tr -s '*' '
1321 ' | fold | sed '$a\
1322 ' > conftest.dmp
1323 $2
1324 ifelse($3, , , else
1325 $3
1326 )dnl
1327 fi
1328 rm -rf conftest*
1329 AC_LANG_RESTORE])
1330
1331 dnl Host endianness probe.
1332 dnl This tests byte-within-word endianness. GCC actually needs
1333 dnl to know word-within-larger-object endianness. They are the
1334 dnl same on all presently supported hosts.
1335 dnl Differs from AC_C_BIGENDIAN in that it does not require
1336 dnl running a program on the host, and it defines the macro we
1337 dnl want to see.
1338 dnl
1339 AC_DEFUN([gcc_AC_C_COMPILE_ENDIAN],
1340 [AC_CACHE_CHECK(byte ordering, ac_cv_c_compile_endian,
1341 [ac_cv_c_compile_endian=unknown
1342 gcc_AC_EXAMINE_OBJECT([
1343 #ifdef HAVE_LIMITS_H
1344 # include <limits.h>
1345 #endif
1346 /* This structure must have no internal padding. */
1347 struct {
1348 char prefix[sizeof "\nendian:" - 1];
1349 short word;
1350 char postfix[2];
1351 } tester = {
1352 "\nendian:",
1353 #if SIZEOF_SHORT == 4
1354 ('A' << (CHAR_BIT * 3)) | ('B' << (CHAR_BIT * 2)) |
1355 #endif
1356 ('A' << CHAR_BIT) | 'B',
1357 'X', '\n'
1358 };],
1359 [if grep 'endian:AB' conftest.dmp >/dev/null 2>&1; then
1360 ac_cv_c_compile_endian=big-endian
1361 elif grep 'endian:BA' conftest.dmp >/dev/null 2>&1; then
1362 ac_cv_c_compile_endian=little-endian
1363 fi])
1364 ])
1365 if test $ac_cv_c_compile_endian = unknown; then
1366 AC_MSG_ERROR([*** unable to determine endianness])
1367 elif test $ac_cv_c_compile_endian = big-endian; then
1368 AC_DEFINE(HOST_WORDS_BIG_ENDIAN, 1,
1369 [Define if the host machine stores words of multi-word integers in
1370 big-endian order.])
1371 fi
1372 ])
1373
1374 dnl Floating point format probe.
1375 dnl The basic concept is the same as the above: grep the object
1376 dnl file for an interesting string. We have to watch out for
1377 dnl rounding changing the values in the object, however; this is
1378 dnl handled by ignoring the least significant byte of the float.
1379 dnl
1380 dnl Does not know about VAX G-float or C4x idiosyncratic format.
1381 dnl It does know about PDP-10 idiosyncratic format, but this is
1382 dnl not presently supported by GCC. S/390 "binary floating point"
1383 dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1384 dnl as ASCII?)
1385 dnl
1386 AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1387 [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1388 [gcc_AC_EXAMINE_OBJECT(
1389 [/* This will not work unless sizeof(double) == 8. */
1390 extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1391
1392 /* This structure must have no internal padding. */
1393 struct possibility {
1394 char prefix[8];
1395 double candidate;
1396 char postfix[8];
1397 };
1398
1399 #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1400 struct possibility table [] =
1401 {
1402 C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1403 C( 3.53802595280598432000e+18), /* D__float - VAX */
1404 C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1405 C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1406 C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1407 };],
1408 [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1409 ac_cv_c_float_format='IEEE (big-endian)'
1410 elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1411 ac_cv_c_float_format='IEEE (big-endian)'
1412 elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1413 ac_cv_c_float_format='IEEE (little-endian)'
1414 elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1415 ac_cv_c_float_format='IEEE (little-endian)'
1416 elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1417 ac_cv_c_float_format='VAX D-float'
1418 elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1419 ac_cv_c_float_format='PDP-10'
1420 elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1421 ac_cv_c_float_format='IBM 370 hex'
1422 else
1423 AC_MSG_ERROR(Unknown floating point format)
1424 fi],
1425 [AC_MSG_ERROR(compile failed)])
1426 ])
1427 # IEEE is the default format. If the float endianness isn't the same
1428 # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1429 # (which is a tristate: yes, no, default). This is only an issue with
1430 # IEEE; the other formats are only supported by a few machines each,
1431 # all with the same endianness.
1432 format=
1433 fbigend=
1434 case $ac_cv_c_float_format in
1435 'IEEE (big-endian)' )
1436 if test $ac_cv_c_compile_endian = little-endian; then
1437 fbigend=1
1438 fi
1439 ;;
1440 'IEEE (little-endian)' )
1441 if test $ac_cv_c_compile_endian = big-endian; then
1442 fbigend=0
1443 fi
1444 ;;
1445 'VAX D-float' )
1446 format=VAX_FLOAT_FORMAT
1447 ;;
1448 'PDP-10' )
1449 format=PDP10_FLOAT_FORMAT
1450 ;;
1451 'IBM 370 hex' )
1452 format=IBM_FLOAT_FORMAT
1453 ;;
1454 esac
1455 if test -n "$format"; then
1456 AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1457 [Define to the floating point format of the host machine, if not IEEE.])
1458 fi
1459 if test -n "$fbigend"; then
1460 AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1461 [Define to 1 if the host machine stores floating point numbers in
1462 memory with the word containing the sign bit at the lowest address,
1463 or to 0 if it does it the other way around.
1464
1465 This macro should not be defined if the ordering is the same as for
1466 multi-word integers.])
1467 fi
1468 ])