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