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