]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/gcc/aclocal.m4
This commit was generated by cvs2svn to compensate for changes in r131823,
[FreeBSD/FreeBSD.git] / contrib / 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 See if the printf functions in libc support %p in format strings.
79 AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
80 [AC_CACHE_CHECK(whether the printf functions support %p,
81   gcc_cv_func_printf_ptr,
82 [AC_TRY_RUN([#include <stdio.h>
83
84 int main()
85 {
86   char buf[64];
87   char *p = buf, *q = NULL;
88   sprintf(buf, "%p", p);
89   sscanf(buf, "%p", &q);
90   return (p != q);
91 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
92         gcc_cv_func_printf_ptr=no)
93 rm -f core core.* *.core])
94 if test $gcc_cv_func_printf_ptr = yes ; then
95   AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
96 fi
97 ])
98
99 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
100 AC_DEFUN(gcc_AC_PROG_LN_S,
101 [AC_MSG_CHECKING(whether ln -s works)
102 AC_CACHE_VAL(gcc_cv_prog_LN_S,
103 [rm -f conftestdata_t
104 echo >conftestdata_f
105 if ln -s conftestdata_f conftestdata_t 2>/dev/null
106 then
107   gcc_cv_prog_LN_S="ln -s"
108 else
109   if ln conftestdata_f conftestdata_t 2>/dev/null
110   then
111     gcc_cv_prog_LN_S=ln
112   else
113     gcc_cv_prog_LN_S=cp
114   fi
115 fi
116 rm -f conftestdata_f conftestdata_t
117 ])dnl
118 LN_S="$gcc_cv_prog_LN_S"
119 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
120   AC_MSG_RESULT(yes)
121 else
122   if test "$gcc_cv_prog_LN_S" = "ln"; then
123     AC_MSG_RESULT([no, using ln])
124   else
125     AC_MSG_RESULT([no, and neither does ln, so using cp])
126   fi
127 fi
128 AC_SUBST(LN_S)dnl
129 ])
130
131 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
132 AC_DEFUN(gcc_AC_PROG_LN,
133 [AC_MSG_CHECKING(whether ln works)
134 AC_CACHE_VAL(gcc_cv_prog_LN,
135 [rm -f conftestdata_t
136 echo >conftestdata_f
137 if ln conftestdata_f conftestdata_t 2>/dev/null
138 then
139   gcc_cv_prog_LN="ln"
140 else
141   if ln -s conftestdata_f conftestdata_t 2>/dev/null
142   then
143     gcc_cv_prog_LN="ln -s"
144   else
145     gcc_cv_prog_LN=cp
146   fi
147 fi
148 rm -f conftestdata_f conftestdata_t
149 ])dnl
150 LN="$gcc_cv_prog_LN"
151 if test "$gcc_cv_prog_LN" = "ln"; then
152   AC_MSG_RESULT(yes)
153 else
154   if test "$gcc_cv_prog_LN" = "ln -s"; then
155     AC_MSG_RESULT([no, using ln -s])
156   else
157     AC_MSG_RESULT([no, and neither does ln -s, so using cp])
158   fi
159 fi
160 AC_SUBST(LN)dnl
161 ])
162
163 dnl See whether the stage1 host compiler accepts the volatile keyword.
164 AC_DEFUN(gcc_AC_C_VOLATILE,
165 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
166 [AC_TRY_COMPILE(, [volatile int foo;],
167         gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
168 if test $gcc_cv_c_volatile = yes ; then
169   AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.])
170 fi
171 ])
172
173 dnl Check whether long double is supported.  This differs from the
174 dnl built-in autoconf test in that it works for cross compiles.
175 AC_DEFUN(gcc_AC_C_LONG_DOUBLE,
176 [AC_CACHE_CHECK(for long double, gcc_cv_c_long_double,
177 [if test "$GCC" = yes; then
178   gcc_cv_c_long_double=yes
179 else
180 AC_TRY_COMPILE(,
181 [/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
182 long double foo = 0.0;
183 /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
184 switch (0) case 0: case (sizeof(long double) >= sizeof(double)):;],
185 gcc_cv_c_long_double=yes, gcc_cv_c_long_double=no)
186 fi])
187 if test $gcc_cv_c_long_double = yes; then
188   AC_DEFINE(HAVE_LONG_DOUBLE, 1, 
189       [Define if your compiler supports the \`long double' type.])
190 fi
191 ])
192
193 dnl Check whether _Bool is built-in.
194 AC_DEFUN(gcc_AC_C__BOOL,
195 [AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
196 [AC_TRY_COMPILE(,
197 [_Bool foo;],
198 gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
199 ])
200 if test $gcc_cv_c__bool = yes; then
201   AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
202 fi
203 ])
204
205 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
206 dnl of the usual 2.
207 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
208 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
209 [AC_TRY_COMPILE([
210 #include <sys/types.h>
211 #ifdef HAVE_SYS_STAT_H
212 # include <sys/stat.h>
213 #endif
214 #ifdef HAVE_UNISTD_H
215 # include <unistd.h>
216 #endif
217 #ifdef HAVE_DIRECT_H
218 # include <direct.h>
219 #endif], [mkdir ("foo", 0);], 
220         gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
221 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
222   AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
223 fi
224 ])
225
226 AC_DEFUN(gcc_AC_PROG_INSTALL,
227 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
228 # Find a good install program.  We prefer a C program (faster),
229 # so one script is as good as another.  But avoid the broken or
230 # incompatible versions:
231 # SysV /etc/install, /usr/sbin/install
232 # SunOS /usr/etc/install
233 # IRIX /sbin/install
234 # AIX /bin/install
235 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
236 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
237 # ./install, which can be erroneously created by make from ./install.sh.
238 AC_MSG_CHECKING(for a BSD compatible install)
239 if test -z "$INSTALL"; then
240 AC_CACHE_VAL(ac_cv_path_install,
241 [  IFS="${IFS=  }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
242   for ac_dir in $PATH; do
243     # Account for people who put trailing slashes in PATH elements.
244     case "$ac_dir/" in
245     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
246     *)
247       # OSF1 and SCO ODT 3.0 have their own names for install.
248       for ac_prog in ginstall scoinst install; do
249         if test -f $ac_dir/$ac_prog; then
250           if test $ac_prog = install &&
251             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
252             # AIX install.  It has an incompatible calling convention.
253             # OSF/1 installbsd also uses dspmsg, but is usable.
254             :
255           else
256             ac_cv_path_install="$ac_dir/$ac_prog -c"
257             break 2
258           fi
259         fi
260       done
261       ;;
262     esac
263   done
264   IFS="$ac_save_IFS"
265 ])dnl
266   if test "${ac_cv_path_install+set}" = set; then
267     INSTALL="$ac_cv_path_install"
268   else
269     # As a last resort, use the slow shell script.  We don't cache a
270     # path for INSTALL within a source directory, because that will
271     # break other packages using the cache if that directory is
272     # removed, or if the path is relative.
273     INSTALL="$ac_install_sh"
274   fi
275 fi
276 dnl We do special magic for INSTALL instead of AC_SUBST, to get
277 dnl relative paths right.
278 AC_MSG_RESULT($INSTALL)
279 AC_SUBST(INSTALL)dnl
280
281 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
282 # It thinks the first close brace ends the variable substitution.
283 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
284 AC_SUBST(INSTALL_PROGRAM)dnl
285
286 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
287 AC_SUBST(INSTALL_DATA)dnl
288 ])
289
290 dnl Test for GNAT.
291 dnl We require the gnatbind program, and a compiler driver that
292 dnl understands Ada.  The user may set the driver name explicitly
293 dnl with ADAC; also, the user's CC setting is tried.  Failing that,
294 dnl we try gcc and cc, then a sampling of names known to be used for
295 dnl the Ada driver on various systems.
296 dnl
297 dnl Sets the shell variable have_gnat to yes or no as appropriate, and
298 dnl substitutes GNATBIND and ADAC.
299 AC_DEFUN([gcc_AC_PROG_GNAT],
300 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
301 AC_CHECK_TOOL(GNATBIND, gnatbind, no)
302 AC_CACHE_CHECK([for compiler driver that understands Ada],
303                  gcc_cv_prog_adac,
304 [cat >conftest.adb <<EOF
305 procedure conftest is begin null; end conftest;
306 EOF
307 gcc_cv_prog_adac=no
308 # Have to do ac_tool_prefix and user overrides by hand.
309 for cand in ${ADAC+"$ADAC"} ${CC+"$CC"} \
310             ${ac_tool_prefix}gcc        gcc             \
311             ${ac_tool_prefix}cc         cc              \
312             ${ac_tool_prefix}gnatgcc    gnatgcc         \
313             ${ac_tool_prefix}gnatcc     gnatcc          \
314             ${ac_tool_prefix}adagcc     adagcc          \
315             ${ac_tool_prefix}adacc      adacc           ; do
316   # There is a bug in all released versions of GCC which causes the
317   # driver to exit successfully when the appropriate language module
318   # has not been installed.  This is fixed in 2.95.4, 3.0.2, and 3.1.
319   # Therefore we must check for the error message as well as an
320   # unsuccessful exit.
321   errors=`($cand -c conftest.adb) 2>&1 || echo failure`
322   if test x"$errors" = x; then
323     gcc_cv_prog_adac=$cand
324     break
325   fi
326 done
327 rm -f conftest.*])
328 ADAC=$gcc_cv_prog_adac
329 AC_SUBST(ADAC)
330
331 if test x$GNATBIND != xno && test x$ADAC != xno; then
332   have_gnat=yes
333 else
334   have_gnat=no
335 fi
336 ])
337
338 #serial 1
339 dnl This test replaces the one in autoconf.
340 dnl Currently this macro should have the same name as the autoconf macro
341 dnl because gettext's gettext.m4 (distributed in the automake package)
342 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
343 dnl give these diagnostics:
344 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
345 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
346
347 undefine([AC_ISC_POSIX])
348 AC_DEFUN(AC_ISC_POSIX,
349   [
350     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
351     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
352   ]
353 )
354
355
356 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
357 dnl like AC_PATH_PROG but use other cache variables
358 AC_DEFUN(GCC_PATH_PROG,
359 [# Extract the first word of "$2", so it can be a program name with args.
360 set dummy $2; ac_word=[$]2
361 AC_MSG_CHECKING([for $ac_word])
362 AC_CACHE_VAL(gcc_cv_path_$1,
363 [case "[$]$1" in
364   /*)
365   gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
366   ;;
367   ?:/*)                  
368   gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
369   ;;
370   *)
371   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
372 dnl $ac_dummy forces splitting on constant user-supplied paths.
373 dnl POSIX.2 word splitting is done only on the output of word expansions,
374 dnl not every word.  This closes a longstanding sh security hole.
375   ac_dummy="ifelse([$4], , $PATH, [$4])"
376   for ac_dir in $ac_dummy; do 
377     test -z "$ac_dir" && ac_dir=.
378     if test -f $ac_dir/$ac_word; then
379       gcc_cv_path_$1="$ac_dir/$ac_word"
380       break
381     fi
382   done
383   IFS="$ac_save_ifs"
384 dnl If no 3rd arg is given, leave the cache variable unset,
385 dnl so GCC_PATH_PROGS will keep looking.
386 ifelse([$3], , , [  test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
387 ])dnl
388   ;;
389 esac])dnl
390 $1="$gcc_cv_path_$1"
391 if test -n "[$]$1"; then
392   AC_MSG_RESULT([$]$1)
393 else
394   AC_MSG_RESULT(no)
395 fi
396 AC_SUBST($1)dnl
397 ])
398
399 # mmap(2) blacklisting.  Some platforms provide the mmap library routine
400 # but don't support all of the features we need from it.
401 AC_DEFUN([gcc_AC_FUNC_MMAP_BLACKLIST],
402 [if test $ac_cv_header_sys_mman_h != yes \
403  || test $ac_cv_func_mmap != yes; then
404    gcc_cv_func_mmap_file=no
405    gcc_cv_func_mmap_dev_zero=no
406    gcc_cv_func_mmap_anon=no
407 else
408    AC_CACHE_CHECK([whether read-only mmap of a plain file works], 
409   gcc_cv_func_mmap_file,
410   [# Add a system to this blacklist if 
411    # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
412    # memory area containing the same data that you'd get if you applied
413    # read() to the same fd.  The only system known to have a problem here
414    # is VMS, where text files have record structure.
415    case "$host_os" in
416      vms*) 
417         gcc_cv_func_mmap_file=no ;;
418      *)
419         gcc_cv_func_mmap_file=yes;;
420    esac])
421    AC_CACHE_CHECK([whether mmap from /dev/zero works],
422   gcc_cv_func_mmap_dev_zero,
423   [# Add a system to this blacklist if it has mmap() but /dev/zero
424    # does not exist, or if mmapping /dev/zero does not give anonymous
425    # zeroed pages with both the following properties:
426    # 1. If you map N consecutive pages in with one call, and then
427    #    unmap any subset of those pages, the pages that were not
428    #    explicitly unmapped remain accessible.
429    # 2. If you map two adjacent blocks of memory and then unmap them
430    #    both at once, they must both go away.
431    # Systems known to be in this category are Windows (all variants),
432    # VMS, and Darwin.
433    case "$host_os" in
434      vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
435         gcc_cv_func_mmap_dev_zero=no ;;
436      *)
437         gcc_cv_func_mmap_dev_zero=yes;;
438    esac])
439
440    # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
441    AC_CACHE_CHECK([for MAP_ANON(YMOUS)], gcc_cv_decl_map_anon,
442     [AC_TRY_COMPILE(
443 [#include <sys/types.h>
444 #include <sys/mman.h>
445 #include <unistd.h>
446
447 #ifndef MAP_ANONYMOUS
448 #define MAP_ANONYMOUS MAP_ANON
449 #endif
450 ],
451 [int n = MAP_ANONYMOUS;],
452     gcc_cv_decl_map_anon=yes,
453     gcc_cv_decl_map_anon=no)])
454
455    if test $gcc_cv_decl_map_anon = no; then
456      gcc_cv_func_mmap_anon=no
457    else
458      AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
459      gcc_cv_func_mmap_anon,
460   [# Add a system to this blacklist if it has mmap() and MAP_ANON or
461    # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
462    # doesn't give anonymous zeroed pages with the same properties listed
463    # above for use of /dev/zero.
464    # Systems known to be in this category are Windows, VMS, and SCO Unix.
465    case "$host_os" in
466      vms* | cygwin* | pe | mingw* | sco* | udk* )
467         gcc_cv_func_mmap_anon=no ;;
468      *)
469         gcc_cv_func_mmap_anon=yes;;
470    esac])
471    fi
472 fi
473
474 if test $gcc_cv_func_mmap_file = yes; then
475   AC_DEFINE(HAVE_MMAP_FILE, 1,
476             [Define if read-only mmap of a plain file works.])
477 fi
478 if test $gcc_cv_func_mmap_dev_zero = yes; then
479   AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
480             [Define if mmap of /dev/zero works.])
481 fi
482 if test $gcc_cv_func_mmap_anon = yes; then
483   AC_DEFINE(HAVE_MMAP_ANON, 1,
484             [Define if mmap with MAP_ANON(YMOUS) works.])
485 fi
486 ])
487
488 dnl Locate a program and check that its version is acceptable.
489 dnl AC_PROG_CHECK_VER(var, name, version-switch,
490 dnl                  version-extract-regexp, version-glob)
491 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
492 [AC_CHECK_PROG([$1], [$2], [$2])
493 if test -n "[$]$1"; then
494   # Found it, now check the version.
495   AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
496 [changequote(<<,>>)dnl
497   ac_prog_version=`<<$>>$1 $3 2>&1 |
498                    sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
499 changequote([,])dnl
500   echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
501 changequote(<<,>>)dnl
502   case $ac_prog_version in
503     '')     gcc_cv_prog_$2_modern=no;;
504     <<$5>>)
505             gcc_cv_prog_$2_modern=yes;;
506     *)      gcc_cv_prog_$2_modern=no;;
507   esac
508 changequote([,])dnl
509 ])
510 else
511   gcc_cv_prog_$2_modern=no
512 fi
513 ])
514
515 dnl Determine if enumerated bitfields are unsigned.   ISO C says they can 
516 dnl be either signed or unsigned.
517 dnl
518 AC_DEFUN(gcc_AC_C_ENUM_BF_UNSIGNED,
519 [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
520 [AC_TRY_RUN(#include <stdlib.h>
521 enum t { BLAH = 128 } ;
522 struct s_t { enum t member : 8; } s ;
523 int main(void)
524 {            
525         s.member = BLAH;
526         if (s.member < 0) exit(1);
527         exit(0);
528
529 }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
530 if test $gcc_cv_enum_bf_unsigned = yes; then
531   AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
532     [Define if enumerated bitfields are treated as unsigned values.])
533 fi])
534
535 dnl Host type sizes probe.
536 dnl By Kaveh R. Ghazi.  One typo fixed since.
537 dnl
538 AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF],
539 [changequote(<<, >>)dnl
540 dnl The name to #define.
541 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
542 dnl The cache variable name.
543 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
544 changequote([, ])dnl
545 AC_MSG_CHECKING(size of $1)
546 AC_CACHE_VAL(AC_CV_NAME,
547 [for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
548   AC_TRY_COMPILE([#include "confdefs.h"
549 #include <sys/types.h>
550 $2
551 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
552   if test x$AC_CV_NAME != x ; then break; fi
553 done
554 ])
555 if test x$AC_CV_NAME = x ; then
556   AC_MSG_ERROR([cannot determine a size for $1])
557 fi
558 AC_MSG_RESULT($AC_CV_NAME)
559 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
560 undefine([AC_TYPE_NAME])dnl
561 undefine([AC_CV_NAME])dnl
562 ])
563
564 dnl Probe number of bits in a byte.
565 dnl Note C89 requires CHAR_BIT >= 8.
566 dnl
567 AC_DEFUN(gcc_AC_C_CHAR_BIT,
568 [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
569 [AC_EGREP_CPP(found,
570 [#ifdef HAVE_LIMITS_H
571 #include <limits.h>
572 #endif
573 #ifdef CHAR_BIT
574 found
575 #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
576 ])
577 if test $gcc_cv_decl_char_bit = no; then
578   AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
579 [i=8
580  gcc_cv_c_nbby=
581  while test $i -lt 65; do
582    AC_TRY_COMPILE(,
583      [switch(0) {
584   case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
585   case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
586   ; }], 
587      [gcc_cv_c_nbby=$i; break])
588    i=`expr $i + 1`
589  done
590  test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
591 ])
592 if test $gcc_cv_c_nbby = failed; then
593   AC_MSG_ERROR(cannot determine number of bits in a byte)
594 else
595   AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
596   [Define as the number of bits in a byte, if \`limits.h' doesn't.])
597 fi
598 fi])
599
600 dnl Checking for long long.
601 dnl By Caolan McNamara <caolan@skynet.ie>
602 dnl Added check for __int64, Zack Weinberg <zackw@stanford.edu>
603 dnl
604 AC_DEFUN([gcc_AC_C_LONG_LONG],
605 [AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
606   [AC_TRY_COMPILE(,[long long int i;],
607          ac_cv_c_long_long=yes,
608          ac_cv_c_long_long=no)])
609   if test $ac_cv_c_long_long = yes; then
610     AC_DEFINE(HAVE_LONG_LONG, 1,
611       [Define if your compiler supports the \`long long' type.])
612   fi
613 AC_CACHE_CHECK(for __int64, ac_cv_c___int64,
614   [AC_TRY_COMPILE(,[__int64 i;],
615         ac_cv_c___int64=yes,
616         ac_cv_c___int64=no)])
617   if test $ac_cv_c___int64 = yes; then
618     AC_DEFINE(HAVE___INT64, 1,
619       [Define if your compiler supports the \`__int64' type.])
620   fi
621 ])
622
623 dnl Host character set probe.
624 dnl The EBCDIC values match the table in config/i370/i370.c;
625 dnl there are other versions of EBCDIC but GCC won't work with them.
626 dnl
627 AC_DEFUN([gcc_AC_C_CHARSET],
628 [AC_CACHE_CHECK(execution character set, ac_cv_c_charset,
629   [AC_EGREP_CPP(ASCII,
630 [#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
631    && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
632 ASCII
633 #endif], ac_cv_c_charset=ASCII)
634   if test x${ac_cv_c_charset+set} != xset; then
635     AC_EGREP_CPP(EBCDIC,
636 [#if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
637    && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
638 EBCDIC
639 #endif], ac_cv_c_charset=EBCDIC)
640   fi
641   if test x${ac_cv_c_charset+set} != xset; then
642     ac_cv_c_charset=unknown
643   fi])
644 if test $ac_cv_c_charset = unknown; then
645   AC_MSG_ERROR([*** Cannot determine host character set.])
646 elif test $ac_cv_c_charset = EBCDIC; then
647   AC_DEFINE(HOST_EBCDIC, 1,
648   [Define if the host execution character set is EBCDIC.])
649 fi])
650
651 dnl Utility macro used by next two tests.
652 dnl AC_EXAMINE_OBJECT(C source code,
653 dnl     commands examining object file,
654 dnl     [commands to run if compile failed]):
655 dnl
656 dnl Compile the source code to an object file; then convert it into a
657 dnl printable representation.  All unprintable characters and
658 dnl asterisks (*) are replaced by dots (.).  All white space is
659 dnl deleted.  Newlines (ASCII 0x10) in the input are preserved in the
660 dnl output, but runs of newlines are compressed to a single newline.
661 dnl Finally, line breaks are forcibly inserted so that no line is
662 dnl longer than 80 columns and the file ends with a newline.  The
663 dnl result of all this processing is in the file conftest.dmp, which
664 dnl may be examined by the commands in the second argument.
665 dnl
666 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
667 [AC_LANG_SAVE
668 AC_LANG_C
669 dnl Next bit cribbed from AC_TRY_COMPILE.
670 cat > conftest.$ac_ext <<EOF
671 [#line __oline__ "configure"
672 #include "confdefs.h"
673 $1
674 ]EOF
675 if AC_TRY_EVAL(ac_compile); then
676   od -c conftest.o |
677     sed ['s/^[0-7]*[    ]*/ /
678           s/\*/./g
679           s/ \\n/*/g
680           s/ [0-9][0-9][0-9]/./g
681           s/  \\[^ ]/./g'] |
682     tr -d '
683  ' | tr -s '*' '
684 ' | fold | sed '$a\
685 ' > conftest.dmp
686   $2
687 ifelse($3, , , else
688   $3
689 )dnl
690 fi
691 rm -rf conftest*
692 AC_LANG_RESTORE])
693
694 dnl Host endianness probe.
695 dnl This tests byte-within-word endianness.  GCC actually needs
696 dnl to know word-within-larger-object endianness.  They are the
697 dnl same on all presently supported hosts.
698 dnl Differs from AC_C_BIGENDIAN in that it does not require
699 dnl running a program on the host, and it defines the macro we
700 dnl want to see.
701 dnl
702 AC_DEFUN([gcc_AC_C_COMPILE_ENDIAN],
703 [AC_CACHE_CHECK(byte ordering, ac_cv_c_compile_endian,
704 [ac_cv_c_compile_endian=unknown
705 gcc_AC_EXAMINE_OBJECT([
706 #ifdef HAVE_LIMITS_H
707 # include <limits.h>
708 #endif
709 /* This structure must have no internal padding.  */
710   struct {
711     char prefix[sizeof "\nendian:" - 1];
712     short word;
713     char postfix[2];
714  } tester = {
715     "\nendian:",
716 #if SIZEOF_SHORT == 4
717     ('A' << (CHAR_BIT * 3)) | ('B' << (CHAR_BIT * 2)) |
718 #endif
719     ('A' << CHAR_BIT) | 'B',
720     'X', '\n'
721 };],
722  [if   grep 'endian:AB' conftest.dmp >/dev/null 2>&1; then
723     ac_cv_c_compile_endian=big-endian
724   elif grep 'endian:BA' conftest.dmp >/dev/null 2>&1; then
725     ac_cv_c_compile_endian=little-endian
726   fi])
727 ])
728 if test $ac_cv_c_compile_endian = unknown; then
729   AC_MSG_ERROR([*** unable to determine endianness])
730 elif test $ac_cv_c_compile_endian = big-endian; then
731   AC_DEFINE(HOST_WORDS_BIG_ENDIAN, 1,
732   [Define if the host machine stores words of multi-word integers in
733    big-endian order.])
734 fi
735 ])
736
737 dnl Floating point format probe.
738 dnl The basic concept is the same as the above: grep the object
739 dnl file for an interesting string.  We have to watch out for
740 dnl rounding changing the values in the object, however; this is
741 dnl handled by ignoring the least significant byte of the float.
742 dnl
743 dnl Does not know about VAX G-float or C4x idiosyncratic format.
744 dnl It does know about PDP-10 idiosyncratic format, but this is
745 dnl not presently supported by GCC.  S/390 "binary floating point"
746 dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
747 dnl as ASCII?)
748 dnl
749 AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
750 [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
751 [gcc_AC_EXAMINE_OBJECT(
752 [/* This will not work unless sizeof(double) == 8.  */
753 extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
754
755 /* This structure must have no internal padding.  */
756 struct possibility {
757   char prefix[8];
758   double candidate;
759   char postfix[8];
760 };
761
762 #define C(cand) { "\nformat:", cand, ":tamrof\n" }
763 struct possibility table [] =
764 {
765   C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
766   C( 3.53802595280598432000e+18), /* D__float - VAX */
767   C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
768   C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
769   C(-5.22995989424860458374e+10)  /* IBMHEXFP - s/390 format, EBCDIC */
770 };],
771  [if   grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
772     ac_cv_c_float_format='IEEE (big-endian)'
773   elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
774     ac_cv_c_float_format='IEEE (big-endian)'
775   elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
776     ac_cv_c_float_format='IEEE (little-endian)'
777   elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
778     ac_cv_c_float_format='IEEE (little-endian)'
779   elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
780     ac_cv_c_float_format='VAX D-float'
781   elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
782     ac_cv_c_float_format='PDP-10'
783   elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
784     ac_cv_c_float_format='IBM 370 hex'
785   else
786     AC_MSG_ERROR(Unknown floating point format)
787   fi],
788   [AC_MSG_ERROR(compile failed)])
789 ])
790 # IEEE is the default format.  If the float endianness isn't the same
791 # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
792 # (which is a tristate: yes, no, default).  This is only an issue with
793 # IEEE; the other formats are only supported by a few machines each,
794 # all with the same endianness.
795 format=
796 fbigend=
797 case $ac_cv_c_float_format in
798     'IEEE (big-endian)' )
799         if test $ac_cv_c_compile_endian = little-endian; then
800             fbigend=1
801         fi
802         ;;
803     'IEEE (little-endian)' )
804         if test $ac_cv_c_compile_endian = big-endian; then
805             fbigend=0
806         fi
807         ;;
808     'VAX D-float' )
809         format=VAX_FLOAT_FORMAT
810         ;;
811     'PDP-10' )
812         format=PDP10_FLOAT_FORMAT
813         ;;
814     'IBM 370 hex' )
815         format=IBM_FLOAT_FORMAT
816         ;;
817 esac
818 if test -n "$format"; then
819         AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
820   [Define to the floating point format of the host machine, if not IEEE.])
821 fi
822 if test -n "$fbigend"; then
823         AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
824   [Define to 1 if the host machine stores floating point numbers in
825    memory with the word containing the sign bit at the lowest address,
826    or to 0 if it does it the other way around.
827
828    This macro should not be defined if the ordering is the same as for
829    multi-word integers.])
830 fi
831 ])
832
833 #serial AM2
834
835 dnl From Bruno Haible.
836
837 AC_DEFUN([AM_ICONV],
838 [
839   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
840   dnl those with the standalone portable GNU libiconv installed).
841
842   am_cv_lib_iconv_ldpath=
843   AC_ARG_WITH([libiconv-prefix],
844 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
845     for dir in `echo "$withval" | tr : ' '`; do
846       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
847       if test -d $dir/lib; then am_cv_lib_iconv_ldpath="-L$dir/lib"; fi
848     done
849    ])
850
851   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
852     am_cv_func_iconv="no, consider installing GNU libiconv"
853     am_cv_lib_iconv=no
854     AC_TRY_LINK([#include <stdlib.h>
855 #include <iconv.h>],
856       [iconv_t cd = iconv_open("","");
857        iconv(cd,NULL,NULL,NULL,NULL);
858        iconv_close(cd);],
859       am_cv_func_iconv=yes)
860     if test "$am_cv_func_iconv" != yes; then
861       am_save_LIBS="$LIBS"
862       LIBS="$LIBS $am_cv_libiconv_ldpath -liconv"
863       AC_TRY_LINK([#include <stdlib.h>
864 #include <iconv.h>],
865         [iconv_t cd = iconv_open("","");
866          iconv(cd,NULL,NULL,NULL,NULL);
867          iconv_close(cd);],
868         am_cv_lib_iconv=yes
869         am_cv_func_iconv=yes)
870       LIBS="$am_save_LIBS"
871     fi
872   ])
873   if test "$am_cv_func_iconv" = yes; then
874     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
875     AC_MSG_CHECKING([for iconv declaration])
876     AC_CACHE_VAL(am_cv_proto_iconv, [
877       AC_TRY_COMPILE([
878 #include <stdlib.h>
879 #include <iconv.h>
880 extern
881 #ifdef __cplusplus
882 "C"
883 #endif
884 #if defined(__STDC__) || defined(__cplusplus)
885 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
886 #else
887 size_t iconv();
888 #endif
889 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
890       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);"])
891     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
892     AC_MSG_RESULT([$]{ac_t:-
893          }[$]am_cv_proto_iconv)
894     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
895       [Define as const if the declaration of iconv() needs const.])
896   fi
897   LIBICONV=
898   if test "$am_cv_lib_iconv" = yes; then
899     LIBICONV="$am_cv_lib_iconv_ldpath -liconv"
900   fi
901   AC_SUBST(LIBICONV)
902 ])
903
904 ### Gettext macros begin here.
905 ### Changes for GCC marked by 'dnl GCC LOCAL'.
906 ### Note iconv.m4 appears above, as it's used for other reasons.
907
908 #serial AM1
909
910 dnl From Bruno Haible.
911
912 AC_DEFUN([AM_LANGINFO_CODESET],
913 [
914   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
915     [AC_TRY_LINK([#include <langinfo.h>],
916       [char* cs = nl_langinfo(CODESET);],
917       am_cv_langinfo_codeset=yes,
918       am_cv_langinfo_codeset=no)
919     ])
920   if test $am_cv_langinfo_codeset = yes; then
921     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
922       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
923   fi
924 ])
925
926 #serial 1
927 # This test replaces the one in autoconf.
928 # Currently this macro should have the same name as the autoconf macro
929 # because gettext's gettext.m4 (distributed in the automake package)
930 # still uses it.  Otherwise, the use in gettext.m4 makes autoheader
931 # give these diagnostics:
932 #   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
933 #   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
934
935 undefine([AC_ISC_POSIX])
936
937 AC_DEFUN([AC_ISC_POSIX],
938   [
939     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
940     dnl GCC LOCAL: Use AC_SEARCH_LIBS.
941     AC_SEARCH_LIBS(strerror, cposix)
942   ]
943 )
944
945 #serial 2
946
947 # Test for the GNU C Library, version 2.1 or newer.
948 # From Bruno Haible.
949
950 AC_DEFUN([jm_GLIBC21],
951   [
952     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
953       ac_cv_gnu_library_2_1,
954       [AC_EGREP_CPP([Lucky GNU user],
955         [
956 #include <features.h>
957 #ifdef __GNU_LIBRARY__
958  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
959   Lucky GNU user
960  #endif
961 #endif
962         ],
963         ac_cv_gnu_library_2_1=yes,
964         ac_cv_gnu_library_2_1=no)
965       ]
966     )
967     AC_SUBST(GLIBC21)
968     GLIBC21="$ac_cv_gnu_library_2_1"
969   ]
970 )
971
972 # Check whether LC_MESSAGES is available in <locale.h>.
973 # Ulrich Drepper <drepper@cygnus.com>, 1995.
974 #
975 # This file can be copied and used freely without restrictions.  It can
976 # be used in projects which are not available under the GNU General Public
977 # License or the GNU Library General Public License but which still want
978 # to provide support for the GNU gettext functionality.
979 # Please note that the actual code of the GNU gettext library is covered
980 # by the GNU Library General Public License, and the rest of the GNU
981 # gettext package package is covered by the GNU General Public License.
982 # They are *not* in the public domain.
983
984 # serial 2
985
986 AC_DEFUN([AM_LC_MESSAGES],
987   [if test $ac_cv_header_locale_h = yes; then
988     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
989       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
990        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
991     if test $am_cv_val_LC_MESSAGES = yes; then
992       AC_DEFINE(HAVE_LC_MESSAGES, 1,
993         [Define if your <locale.h> file defines LC_MESSAGES.])
994     fi
995   fi])
996
997 # Search path for a program which passes the given test.
998 # Ulrich Drepper <drepper@cygnus.com>, 1996.
999 #
1000 # This file can be copied and used freely without restrictions.  It can
1001 # be used in projects which are not available under the GNU General Public
1002 # License or the GNU Library General Public License but which still want
1003 # to provide support for the GNU gettext functionality.
1004 # Please note that the actual code of the GNU gettext library is covered
1005 # by the GNU Library General Public License, and the rest of the GNU
1006 # gettext package package is covered by the GNU General Public License.
1007 # They are *not* in the public domain.
1008
1009 # serial 2
1010
1011 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1012 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1013 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
1014 [# Extract the first word of "$2", so it can be a program name with args.
1015 set dummy $2; ac_word=[$]2
1016 AC_MSG_CHECKING([for $ac_word])
1017 AC_CACHE_VAL(ac_cv_path_$1,
1018 [case "[$]$1" in
1019   /*)
1020   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1021   ;;
1022   *)
1023   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1024   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1025     test -z "$ac_dir" && ac_dir=.
1026     if test -f $ac_dir/$ac_word; then
1027       if [$3]; then
1028         ac_cv_path_$1="$ac_dir/$ac_word"
1029         break
1030       fi
1031     fi
1032   done
1033   IFS="$ac_save_ifs"
1034 dnl If no 4th arg is given, leave the cache variable unset,
1035 dnl so AC_PATH_PROGS will keep looking.
1036 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1037 ])dnl
1038   ;;
1039 esac])dnl
1040 $1="$ac_cv_path_$1"
1041 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
1042   AC_MSG_RESULT([$]$1)
1043 else
1044   AC_MSG_RESULT(no)
1045 fi
1046 AC_SUBST($1)dnl
1047 ])
1048
1049 # Macro to add for using GNU gettext.
1050 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1051 #
1052 # This file can be copied and used freely without restrictions.  It can
1053 # be used in projects which are not available under the GNU General Public
1054 # License or the GNU Library General Public License but which still want
1055 # to provide support for the GNU gettext functionality.
1056 # Please note that the actual code of the GNU gettext library is covered
1057 # by the GNU Library General Public License, and the rest of the GNU
1058 # gettext package package is covered by the GNU General Public License.
1059 # They are *not* in the public domain.
1060
1061 # serial 10
1062
1063 dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]).
1064 dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
1065 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
1066 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
1067 dnl    AM-DISABLE-SHARED). Otherwise, a static library
1068 dnl    $(top_builddir)/intl/libintl.a will be created.
1069 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
1070 dnl    implementations (in libc or libintl) without the ngettext() function
1071 dnl    will be ignored.
1072 dnl LIBDIR is used to find the intl libraries.  If empty,
1073 dnl    the value `$(top_builddir)/intl/' is used.
1074 dnl
1075 dnl The result of the configuration is one of three cases:
1076 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
1077 dnl    and used.
1078 dnl    Catalog format: GNU --> install in $(datadir)
1079 dnl    Catalog extension: .mo after installation, .gmo in source tree
1080 dnl 2) GNU gettext has been found in the system's C library.
1081 dnl    Catalog format: GNU --> install in $(datadir)
1082 dnl    Catalog extension: .mo after installation, .gmo in source tree
1083 dnl 3) No internationalization, always use English msgid.
1084 dnl    Catalog format: none
1085 dnl    Catalog extension: none
1086 dnl The use of .gmo is historical (it was needed to avoid overwriting the
1087 dnl GNU format catalogs when building on a platform with an X/Open gettext),
1088 dnl but we keep it in order not to force irrelevant filename changes on the
1089 dnl maintainers.
1090 dnl
1091 AC_DEFUN([AM_WITH_NLS],
1092   [AC_MSG_CHECKING([whether NLS is requested])
1093     dnl Default is enabled NLS
1094     AC_ARG_ENABLE(nls,
1095       [  --disable-nls           do not use Native Language Support],
1096       USE_NLS=$enableval, USE_NLS=yes)
1097     AC_MSG_RESULT($USE_NLS)
1098     AC_SUBST(USE_NLS)
1099
1100     BUILD_INCLUDED_LIBINTL=no
1101     USE_INCLUDED_LIBINTL=no
1102 dnl GCC LOCAL: Separate concept of link command line from dependencies.
1103     INTLLIBS=
1104     INTLDEPS=
1105
1106     dnl If we use NLS figure out what method
1107     if test "$USE_NLS" = "yes"; then
1108       AC_DEFINE(ENABLE_NLS, 1,
1109         [Define to 1 if translation of program messages to the user's native language
1110    is requested.])
1111       AC_MSG_CHECKING([whether included gettext is requested])
1112       AC_ARG_WITH(included-gettext,
1113         [  --with-included-gettext use the GNU gettext library included here],
1114         nls_cv_force_use_gnu_gettext=$withval,
1115         nls_cv_force_use_gnu_gettext=no)
1116       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
1117
1118       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
1119       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
1120         dnl User does not insist on using GNU NLS library.  Figure out what
1121         dnl to use.  If GNU gettext is available we use this.  Else we have
1122         dnl to fall back to GNU NLS library.
1123         CATOBJEXT=NONE
1124
1125         dnl Add a version number to the cache macros.
1126         define(gt_cv_func_gnugettext_libc, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libc])
1127         define(gt_cv_func_gnugettext_libintl, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libintl])
1128
1129 dnl GCC LOCAL: Expose presence of libintl.h to C code.
1130         AC_CHECK_HEADER(libintl.h,
1131           [AC_DEFINE([HAVE_LIBINTL_H], 1,
1132                 [Define if you have the <libintl.h> header file.])
1133            AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
1134             [AC_TRY_LINK([#include <libintl.h>
1135 extern int _nl_msg_cat_cntr;],
1136                [bindtextdomain ("", "");
1137 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
1138                gt_cv_func_gnugettext_libc=yes,
1139                gt_cv_func_gnugettext_libc=no)])
1140
1141            if test "$gt_cv_func_gnugettext_libc" != "yes"; then
1142              AC_CACHE_CHECK([for GNU gettext in libintl],
1143                gt_cv_func_gnugettext_libintl,
1144                [gt_save_LIBS="$LIBS"
1145                 LIBS="$LIBS -lintl $LIBICONV"
1146                 AC_TRY_LINK([#include <libintl.h>
1147 extern int _nl_msg_cat_cntr;],
1148                   [bindtextdomain ("", "");
1149 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
1150                   gt_cv_func_gnugettext_libintl=yes,
1151                   gt_cv_func_gnugettext_libintl=no)
1152                 LIBS="$gt_save_LIBS"])
1153            fi
1154
1155            dnl If an already present or preinstalled GNU gettext() is found,
1156            dnl use it.  But if this macro is used in GNU gettext, and GNU
1157            dnl gettext is already preinstalled in libintl, we update this
1158            dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
1159            if test "$gt_cv_func_gnugettext_libc" = "yes" \
1160               || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
1161                    && test "$PACKAGE" != gettext; }; then
1162              AC_DEFINE(HAVE_GETTEXT, 1,
1163                [Define if the GNU gettext() function is already present or preinstalled.])
1164
1165              if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
1166                dnl If iconv() is in a separate libiconv library, then anyone
1167                dnl linking with libintl{.a,.so} also needs to link with
1168                dnl libiconv.
1169                INTLLIBS="-lintl $LIBICONV"
1170              fi
1171
1172              gt_save_LIBS="$LIBS"
1173              LIBS="$LIBS $INTLLIBS"
1174              AC_CHECK_FUNCS(dcgettext)
1175              LIBS="$gt_save_LIBS"
1176
1177              dnl Search for GNU msgfmt in the PATH.
1178              AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1179                [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
1180              AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1181
1182              dnl Search for GNU xgettext in the PATH.
1183              AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1184                [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
1185
1186              CATOBJEXT=.gmo
1187            fi
1188         ])
1189
1190         if test "$CATOBJEXT" = "NONE"; then
1191           dnl GNU gettext is not found in the C library.
1192           dnl Fall back on GNU gettext library.
1193           nls_cv_use_gnu_gettext=yes
1194         fi
1195       fi
1196
1197       if test "$nls_cv_use_gnu_gettext" = "yes"; then
1198         dnl Mark actions used to generate GNU NLS library.
1199         INTLOBJS="\$(GETTOBJS)"
1200         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1201           [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
1202         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1203         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1204           [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
1205         AC_SUBST(MSGFMT)
1206         BUILD_INCLUDED_LIBINTL=yes
1207         USE_INCLUDED_LIBINTL=yes
1208         CATOBJEXT=.gmo
1209         INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
1210         INTLDEPS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a"
1211         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
1212       fi
1213
1214       dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1215       dnl Test whether we really found GNU msgfmt.
1216       if test "$GMSGFMT" != ":"; then
1217         dnl If it is no GNU msgfmt we define it as : so that the
1218         dnl Makefiles still can work.
1219         if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
1220           : ;
1221         else
1222           AC_MSG_RESULT(
1223             [found msgfmt program is not GNU msgfmt; ignore it])
1224           GMSGFMT=":"
1225         fi
1226       fi
1227
1228       dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1229       dnl Test whether we really found GNU xgettext.
1230       if test "$XGETTEXT" != ":"; then
1231         dnl If it is no GNU xgettext we define it as : so that the
1232         dnl Makefiles still can work.
1233         if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
1234           : ;
1235         else
1236           AC_MSG_RESULT(
1237             [found xgettext program is not GNU xgettext; ignore it])
1238           XGETTEXT=":"
1239         fi
1240       fi
1241
1242       dnl We need to process the po/ directory.
1243       POSUB=po
1244     fi
1245     AC_OUTPUT_COMMANDS(
1246      [for ac_file in $CONFIG_FILES; do
1247         # Support "outfile[:infile[:infile...]]"
1248         case "$ac_file" in
1249           *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
1250         esac
1251         # PO directories have a Makefile.in generated from Makefile.in.in.
1252         case "$ac_file" in */Makefile.in)
1253           # Adjust a relative srcdir.
1254           ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
1255           ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
1256           ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
1257           # In autoconf-2.13 it is called $ac_given_srcdir.
1258           # In autoconf-2.50 it is called $srcdir.
1259           test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
1260           case "$ac_given_srcdir" in
1261             .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
1262             /*) top_srcdir="$ac_given_srcdir" ;;
1263             *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
1264           esac
1265           if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
1266             rm -f "$ac_dir/POTFILES"
1267             test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
1268             sed -e "/^#/d" -e "/^[      ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
1269             test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
1270             sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
1271           fi
1272           ;;
1273         esac
1274       done])
1275
1276
1277     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
1278     dnl to 'yes' because some of the testsuite requires it.
1279     if test "$PACKAGE" = gettext; then
1280       BUILD_INCLUDED_LIBINTL=yes
1281     fi
1282
1283     dnl intl/plural.c is generated from intl/plural.y. It requires bison,
1284     dnl because plural.y uses bison specific features. It requires at least
1285     dnl bison-1.26 because earlier versions generate a plural.c that doesn't
1286     dnl compile.
1287     dnl bison is only needed for the maintainer (who touches plural.y). But in
1288     dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
1289     dnl the rule in general Makefile. Now, some people carelessly touch the
1290     dnl files or have a broken "make" program, hence the plural.c rule will
1291     dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
1292     dnl present or too old.
1293     AC_CHECK_PROGS([INTLBISON], [bison])
1294     if test -z "$INTLBISON"; then
1295       ac_verc_fail=yes
1296     else
1297       dnl Found it, now check the version.
1298       AC_MSG_CHECKING([version of bison])
1299 changequote(<<,>>)dnl
1300       ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
1301       case $ac_prog_version in
1302         '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
1303         1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
1304 changequote([,])dnl
1305            ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
1306         *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
1307       esac
1308       AC_MSG_RESULT([$ac_prog_version])
1309     fi
1310     if test $ac_verc_fail = yes; then
1311       INTLBISON=:
1312     fi
1313
1314     dnl GCC LOCAL: GMOFILES/POFILES removed as unnecessary.
1315
1316     dnl Make all variables we use known to autoconf.
1317     AC_SUBST(BUILD_INCLUDED_LIBINTL)
1318     AC_SUBST(USE_INCLUDED_LIBINTL)
1319     AC_SUBST(CATALOGS)
1320     AC_SUBST(CATOBJEXT)
1321     AC_SUBST(INTLLIBS)
1322     AC_SUBST(INTLDEPS)
1323     AC_SUBST(INTLOBJS)
1324     AC_SUBST(POSUB)
1325 dnl GCC LOCAL: Make USE_INCLUDED_LIBINTL visible to C code.
1326     if test $USE_INCLUDED_LIBINTL = yes; then
1327       AC_DEFINE([USE_INCLUDED_LIBINTL], 1,
1328   [Define to use the libintl included with this package instead of any
1329    version in the system libraries.])
1330     fi
1331
1332     dnl For backward compatibility. Some configure.ins may be using this.
1333     nls_cv_header_intl=
1334     nls_cv_header_libgt=
1335
1336     dnl For backward compatibility. Some Makefiles may be using this.
1337     DATADIRNAME=share
1338     AC_SUBST(DATADIRNAME)
1339
1340     dnl For backward compatibility. Some Makefiles may be using this.
1341     INSTOBJEXT=.mo
1342     AC_SUBST(INSTOBJEXT)
1343
1344     dnl For backward compatibility. Some Makefiles may be using this.
1345     GENCAT=gencat
1346     AC_SUBST(GENCAT)
1347   ])
1348
1349 dnl Usage: Just like AM_WITH_NLS, which see.
1350 AC_DEFUN([AM_GNU_GETTEXT],
1351   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1352    AC_REQUIRE([AC_PROG_CC])dnl
1353    AC_REQUIRE([AC_CANONICAL_HOST])dnl
1354    AC_REQUIRE([AC_PROG_RANLIB])dnl
1355    AC_REQUIRE([AC_ISC_POSIX])dnl
1356    AC_REQUIRE([AC_HEADER_STDC])dnl
1357    AC_REQUIRE([AC_C_CONST])dnl
1358    AC_REQUIRE([AC_C_INLINE])dnl
1359    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1360    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1361    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1362 dnl GCC LOCAL: Do not refer to AC_FUNC_MMAP, we have special needs.
1363 dnl   AC_REQUIRE([AC_FUNC_MMAP])dnl
1364    AC_REQUIRE([jm_GLIBC21])dnl
1365
1366    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
1367 stdlib.h string.h unistd.h sys/param.h])
1368    AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
1369 getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
1370 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
1371
1372    AM_ICONV
1373    AM_LANGINFO_CODESET
1374    AM_LC_MESSAGES
1375    AM_WITH_NLS([$1],[$2],[$3])
1376
1377    dnl GCC LOCAL: The LINGUAS/ALL_LINGUAS/CATALOGS mess that was here
1378    dnl has been torn out and replaced with this more sensible scheme.
1379    if test "x$CATOBJEXT" != x; then
1380      AC_MSG_CHECKING(for catalogs to be installed)
1381      # Look for .po and .gmo files in the source directory.
1382      CATALOGS=
1383      XLINGUAS=
1384      for cat in $srcdir/po/*$CATOBJEXT $srcdir/po/*.po; do
1385         # If there aren't any .gmo files the shell will give us the
1386         # literal string "../path/to/srcdir/po/*.gmo" which has to be
1387         # weeded out.
1388         case "$cat" in *\**)
1389             continue;;
1390         esac
1391         # The quadruple backslash is collapsed to a double backslash
1392         # by the backticks, then collapsed again by the double quotes,
1393         # leaving us with one backslash in the sed expression (right
1394         # before the dot that mustn't act as a wildcard).  The dot to
1395         # be escaped in the second expression is hiding inside CATOBJEXT.
1396         cat=`echo $cat | sed -e "s!$srcdir/!!" -e "s!\\\\.po!$CATOBJEXT!"`
1397         lang=`echo $cat | sed -e 's!po/!!' -e "s!\\\\$CATOBJEXT!!"`
1398         # The user is allowed to set LINGUAS to a list of languages to
1399         # install catalogs for.  If it's empty that means "all of them."
1400         if test "x$LINGUAS" = x; then
1401             CATALOGS="$CATALOGS $cat"
1402             XLINGUAS="$XLINGUAS $lang"
1403         else
1404           case "$LINGUAS" in *$lang*)
1405             CATALOGS="$CATALOGS $cat"
1406             XLINGUAS="$XLINGUAS $lang"
1407             ;;
1408           esac
1409         fi
1410      done
1411      LINGUAS="$XLINGUAS"
1412      AC_MSG_RESULT($LINGUAS)
1413    fi
1414
1415    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1416    dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
1417    dnl Try to locate is.
1418    MKINSTALLDIRS=
1419    if test -n "$ac_aux_dir"; then
1420      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1421    fi
1422    if test -z "$MKINSTALLDIRS"; then
1423      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1424    fi
1425    AC_SUBST(MKINSTALLDIRS)
1426
1427    dnl Enable libtool support if the surrounding package wishes it.
1428    INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
1429    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
1430   ])
1431
1432 AC_DEFUN(gcc_AC_INITFINI_ARRAY,
1433 [AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
1434                  gcc_cv_initfinit_array, [dnl
1435   cat > conftest.c <<EOF
1436 static int x = -1;
1437 int main (void) { return x; }
1438 int foo (void) { x = 0; }
1439 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
1440 EOF
1441   if AC_TRY_COMMAND([${CC-cc} -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1442   then
1443     if ./conftest; then
1444       gcc_cv_initfinit_array=yes
1445     else
1446       gcc_cv_initfinit_array=no
1447     fi
1448   else
1449     gcc_cv_initfinit_array=no
1450   fi
1451   rm -f conftest*])
1452   AC_SUBST(gcc_cv_initfinit_array)
1453   if test $gcc_cv_initfinit_array = yes; then
1454     AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
1455       [Define .init_array/.fini_array sections are available and working.])
1456   fi])