OSDN Git Service

* aclocal.m4 (gcc_AC_FUNC_STRSTR): New macro.
[pf3gnuchains/gcc-fork.git] / gcc / aclocal.m4
1 Fdnl See whether we can include both string.h and strings.h.
2 AC_DEFUN(gcc_AC_HEADER_STRING,
3 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
4   gcc_cv_header_string,
5 [AC_TRY_COMPILE([#include <string.h>
6 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
7 if test $gcc_cv_header_string = yes; then
8   AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
9 fi
10 ])
11
12 dnl See whether we need a declaration for a function.
13 dnl The result is highly dependent on the INCLUDES passed in, so make sure
14 dnl to use a different cache variable name in this macro if it is invoked
15 dnl in a different context somewhere else.
16 dnl gcc_AC_CHECK_DECL(SYMBOL,
17 dnl     [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
18 AC_DEFUN(gcc_AC_CHECK_DECL,
19 [AC_MSG_CHECKING([whether $1 is declared])
20 AC_CACHE_VAL(gcc_cv_have_decl_$1,
21 [AC_TRY_COMPILE([$4],
22 [#ifndef $1
23 char *(*pfn) = (char *(*)) $1 ;
24 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
25 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
26   AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
27 else
28   AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
29 fi
30 ])dnl
31
32 dnl Check multiple functions to see whether each needs a declaration.
33 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
34 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
35 dnl     [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
36 AC_DEFUN(gcc_AC_CHECK_DECLS,
37 [for ac_func in $1
38 do
39 changequote(, )dnl
40   ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
41 changequote([, ])dnl
42 gcc_AC_CHECK_DECL($ac_func,
43   [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
44   [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
45   $4
46 )
47 done
48 dnl Automatically generate config.h entries via autoheader.
49 if test x = y ; then
50   patsubst(translit([$1], [a-z], [A-Z]), [\w+],
51     AC_DEFINE([HAVE_DECL_\&], 1,
52       [Define to 1 if we found this declaration otherwise define to 0.]))dnl
53 fi
54 ])
55
56 dnl Check if we have vprintf and possibly _doprnt.
57 dnl Note autoconf checks for vprintf even though we care about vfprintf.
58 AC_DEFUN(gcc_AC_FUNC_VFPRINTF_DOPRNT,
59 [AC_FUNC_VPRINTF
60 vfprintf=
61 doprint=
62 if test $ac_cv_func_vprintf != yes ; then
63   vfprintf=vfprintf.o
64   if test $ac_cv_func__doprnt != yes ; then
65     doprint=doprint.o
66   fi
67 fi
68 AC_SUBST(vfprintf)
69 AC_SUBST(doprint)
70 ])    
71
72 dnl Check if we have strstr.
73 AC_DEFUN([gcc_AC_FUNC_STRSTR],
74   [AC_CHECK_FUNCS([strstr], [strstr=], [strstr=strstr.o])
75    AC_SUBST([strstr])])
76
77 dnl See if the printf functions in libc support %p in format strings.
78 AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
79 [AC_CACHE_CHECK(whether the printf functions support %p,
80   gcc_cv_func_printf_ptr,
81 [AC_TRY_RUN([#include <stdio.h>
82
83 int main()
84 {
85   char buf[64];
86   char *p = buf, *q = NULL;
87   sprintf(buf, "%p", p);
88   sscanf(buf, "%p", &q);
89   return (p != q);
90 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
91         gcc_cv_func_printf_ptr=no)
92 rm -f core core.* *.core])
93 if test $gcc_cv_func_printf_ptr = yes ; then
94   AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
95 fi
96 ])
97
98 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
99 AC_DEFUN(gcc_AC_PROG_LN_S,
100 [AC_MSG_CHECKING(whether ln -s works)
101 AC_CACHE_VAL(gcc_cv_prog_LN_S,
102 [rm -f conftestdata_t
103 echo >conftestdata_f
104 if ln -s conftestdata_f conftestdata_t 2>/dev/null
105 then
106   gcc_cv_prog_LN_S="ln -s"
107 else
108   if ln conftestdata_f conftestdata_t 2>/dev/null
109   then
110     gcc_cv_prog_LN_S=ln
111   else
112     gcc_cv_prog_LN_S=cp
113   fi
114 fi
115 rm -f conftestdata_f conftestdata_t
116 ])dnl
117 LN_S="$gcc_cv_prog_LN_S"
118 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
119   AC_MSG_RESULT(yes)
120 else
121   if test "$gcc_cv_prog_LN_S" = "ln"; then
122     AC_MSG_RESULT([no, using ln])
123   else
124     AC_MSG_RESULT([no, and neither does ln, so using cp])
125   fi
126 fi
127 AC_SUBST(LN_S)dnl
128 ])
129
130 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
131 AC_DEFUN(gcc_AC_PROG_LN,
132 [AC_MSG_CHECKING(whether ln works)
133 AC_CACHE_VAL(gcc_cv_prog_LN,
134 [rm -f conftestdata_t
135 echo >conftestdata_f
136 if ln conftestdata_f conftestdata_t 2>/dev/null
137 then
138   gcc_cv_prog_LN="ln"
139 else
140   if ln -s conftestdata_f conftestdata_t 2>/dev/null
141   then
142     gcc_cv_prog_LN="ln -s"
143   else
144     gcc_cv_prog_LN=cp
145   fi
146 fi
147 rm -f conftestdata_f conftestdata_t
148 ])dnl
149 LN="$gcc_cv_prog_LN"
150 if test "$gcc_cv_prog_LN" = "ln"; then
151   AC_MSG_RESULT(yes)
152 else
153   if test "$gcc_cv_prog_LN" = "ln -s"; then
154     AC_MSG_RESULT([no, using ln -s])
155   else
156     AC_MSG_RESULT([no, and neither does ln -s, so using cp])
157   fi
158 fi
159 AC_SUBST(LN)dnl
160 ])
161
162 dnl See whether the stage1 host compiler accepts the volatile keyword.
163 AC_DEFUN(gcc_AC_C_VOLATILE,
164 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
165 [AC_TRY_COMPILE(, [volatile int foo;],
166         gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
167 if test $gcc_cv_c_volatile = yes ; then
168   AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.])
169 fi
170 ])
171
172 dnl Check whether long double is supported.  This differs from the
173 dnl built-in autoconf test in that it works for cross compiles.
174 AC_DEFUN(gcc_AC_C_LONG_DOUBLE,
175 [AC_CACHE_CHECK(for long double, gcc_cv_c_long_double,
176 [if test "$GCC" = yes; then
177   gcc_cv_c_long_double=yes
178 else
179 AC_TRY_COMPILE(,
180 [/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
181 long double foo = 0.0;
182 /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
183 switch (0) case 0: case (sizeof(long double) >= sizeof(double)):;],
184 gcc_cv_c_long_double=yes, gcc_cv_c_long_double=no)
185 fi])
186 if test $gcc_cv_c_long_double = yes; then
187   AC_DEFINE(HAVE_LONG_DOUBLE)
188 fi
189 ])
190
191 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
192 dnl of the usual 2.
193 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
194 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
195 [AC_TRY_COMPILE([
196 #include <sys/types.h>
197 #ifdef HAVE_SYS_STAT_H
198 # include <sys/stat.h>
199 #endif
200 #ifdef HAVE_UNISTD_H
201 # include <unistd.h>
202 #endif
203 #ifdef HAVE_DIRECT_H
204 # include <direct.h>
205 #endif], [mkdir ("foo", 0);], 
206         gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
207 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
208   AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
209 fi
210 ])
211
212 AC_DEFUN(gcc_AC_PROG_INSTALL,
213 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
214 # Find a good install program.  We prefer a C program (faster),
215 # so one script is as good as another.  But avoid the broken or
216 # incompatible versions:
217 # SysV /etc/install, /usr/sbin/install
218 # SunOS /usr/etc/install
219 # IRIX /sbin/install
220 # AIX /bin/install
221 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
222 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
223 # ./install, which can be erroneously created by make from ./install.sh.
224 AC_MSG_CHECKING(for a BSD compatible install)
225 if test -z "$INSTALL"; then
226 AC_CACHE_VAL(ac_cv_path_install,
227 [  IFS="${IFS=  }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
228   for ac_dir in $PATH; do
229     # Account for people who put trailing slashes in PATH elements.
230     case "$ac_dir/" in
231     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
232     *)
233       # OSF1 and SCO ODT 3.0 have their own names for install.
234       for ac_prog in ginstall scoinst install; do
235         if test -f $ac_dir/$ac_prog; then
236           if test $ac_prog = install &&
237             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
238             # AIX install.  It has an incompatible calling convention.
239             # OSF/1 installbsd also uses dspmsg, but is usable.
240             :
241           else
242             ac_cv_path_install="$ac_dir/$ac_prog -c"
243             break 2
244           fi
245         fi
246       done
247       ;;
248     esac
249   done
250   IFS="$ac_save_IFS"
251 ])dnl
252   if test "${ac_cv_path_install+set}" = set; then
253     INSTALL="$ac_cv_path_install"
254   else
255     # As a last resort, use the slow shell script.  We don't cache a
256     # path for INSTALL within a source directory, because that will
257     # break other packages using the cache if that directory is
258     # removed, or if the path is relative.
259     INSTALL="$ac_install_sh"
260   fi
261 fi
262 dnl We do special magic for INSTALL instead of AC_SUBST, to get
263 dnl relative paths right.
264 AC_MSG_RESULT($INSTALL)
265 AC_SUBST(INSTALL)dnl
266
267 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
268 # It thinks the first close brace ends the variable substitution.
269 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
270 AC_SUBST(INSTALL_PROGRAM)dnl
271
272 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
273 AC_SUBST(INSTALL_DATA)dnl
274 ])
275
276 #serial 1
277 dnl This test replaces the one in autoconf.
278 dnl Currently this macro should have the same name as the autoconf macro
279 dnl because gettext's gettext.m4 (distributed in the automake package)
280 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
281 dnl give these diagnostics:
282 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
283 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
284
285 undefine([AC_ISC_POSIX])
286 AC_DEFUN(AC_ISC_POSIX,
287   [
288     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
289     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
290   ]
291 )
292
293
294 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
295 dnl like AC_PATH_PROG but use other cache variables
296 AC_DEFUN(GCC_PATH_PROG,
297 [# Extract the first word of "$2", so it can be a program name with args.
298 set dummy $2; ac_word=[$]2
299 AC_MSG_CHECKING([for $ac_word])
300 AC_CACHE_VAL(gcc_cv_path_$1,
301 [case "[$]$1" in
302   /*)
303   gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
304   ;;
305   ?:/*)                  
306   gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
307   ;;
308   *)
309   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
310 dnl $ac_dummy forces splitting on constant user-supplied paths.
311 dnl POSIX.2 word splitting is done only on the output of word expansions,
312 dnl not every word.  This closes a longstanding sh security hole.
313   ac_dummy="ifelse([$4], , $PATH, [$4])"
314   for ac_dir in $ac_dummy; do 
315     test -z "$ac_dir" && ac_dir=.
316     if test -f $ac_dir/$ac_word; then
317       gcc_cv_path_$1="$ac_dir/$ac_word"
318       break
319     fi
320   done
321   IFS="$ac_save_ifs"
322 dnl If no 3rd arg is given, leave the cache variable unset,
323 dnl so GCC_PATH_PROGS will keep looking.
324 ifelse([$3], , , [  test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
325 ])dnl
326   ;;
327 esac])dnl
328 $1="$gcc_cv_path_$1"
329 if test -n "[$]$1"; then
330   AC_MSG_RESULT([$]$1)
331 else
332   AC_MSG_RESULT(no)
333 fi
334 AC_SUBST($1)dnl
335 ])
336
337
338
339 # Macro to add for using GNU gettext.
340 # Ulrich Drepper <drepper@cygnus.com>, 1995.
341 #
342 # This file can be copied and used freely without restrictions.  It can
343 # be used in projects which are not available under the GNU Public License
344 # but which still want to provide support for the GNU gettext functionality.
345 # Please note that the actual code is *not* freely available.
346
347 # serial 5
348
349 AC_DEFUN(AM_WITH_NLS,
350   [AC_MSG_CHECKING([whether NLS is requested])
351     dnl Default is enabled NLS
352     AC_ARG_ENABLE(nls,
353       [  --disable-nls           do not use Native Language Support],
354       USE_NLS=$enableval, USE_NLS=yes)
355     AC_MSG_RESULT($USE_NLS)
356     AC_SUBST(USE_NLS)
357
358     USE_INCLUDED_LIBINTL=no
359
360     dnl If we use NLS figure out what method
361     if test "$USE_NLS" = "yes"; then
362       AC_DEFINE(ENABLE_NLS)
363       AC_MSG_CHECKING([whether included gettext is requested])
364       AC_ARG_WITH(included-gettext,
365         [  --with-included-gettext use the GNU gettext library included here],
366         nls_cv_force_use_gnu_gettext=$withval,
367         nls_cv_force_use_gnu_gettext=no)
368       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
369
370       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
371       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
372         dnl User does not insist on using GNU NLS library.  Figure out what
373         dnl to use.  If gettext or catgets are available (in this order) we
374         dnl use this.  Else we have to fall back to GNU NLS library.
375         dnl catgets is only used if permitted by option --with-catgets.
376         nls_cv_header_intl=
377         nls_cv_header_libgt=
378         CATOBJEXT=NONE
379
380         AC_CHECK_HEADER(libintl.h,
381           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
382             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
383                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
384
385            if test "$gt_cv_func_gettext_libc" != "yes"; then
386              AC_CHECK_LIB(intl, bindtextdomain,
387                [AC_CACHE_CHECK([for gettext in libintl],
388                  gt_cv_func_gettext_libintl,
389                  [AC_CHECK_LIB(intl, gettext,
390                   gt_cv_func_gettext_libintl=yes,
391                   gt_cv_func_gettext_libintl=no)],
392                  gt_cv_func_gettext_libintl=no)])
393            fi
394
395            if test "$gt_cv_func_gettext_libc" = "yes" \
396               || test "$gt_cv_func_gettext_libintl" = "yes"; then
397               AC_DEFINE(HAVE_GETTEXT)
398               GCC_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
399                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
400               if test "$MSGFMT" != "no"; then
401                 AC_CHECK_FUNCS(dcgettext)
402                 GCC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
403                 GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
404                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
405                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
406                                return _nl_msg_cat_cntr],
407                   [CATOBJEXT=.gmo
408                    DATADIRNAME=share],
409                   [CATOBJEXT=.mo
410                    DATADIRNAME=lib])
411                 INSTOBJEXT=.mo
412               else
413                 create_catalogs="no"
414               fi
415             fi
416         ])
417
418         if test "$CATOBJEXT" = "NONE"; then
419           AC_MSG_CHECKING([whether catgets can be used])
420           AC_ARG_WITH(catgets,
421             [  --with-catgets          use catgets functions if available],
422             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
423           AC_MSG_RESULT($nls_cv_use_catgets)
424
425           if test "$nls_cv_use_catgets" = "yes"; then
426             dnl No gettext in C library.  Try catgets next.
427             AC_CHECK_LIB(i, main)
428             AC_CHECK_FUNC(catgets,
429               [AC_DEFINE(HAVE_CATGETS)
430                INTLOBJS="\$(CATOBJS)"
431                GCC_PATH_PROG(GENCAT, gencat, no)dnl
432                if test "$GENCAT" != "no"; then
433                  GCC_PATH_PROG(GMSGFMT, gmsgfmt, no)
434                  if test "$GMSGFMT" = "no"; then
435                    GCC_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
436                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
437                    if test "$GMSGFMT" = "msgfmt"; then
438                      create_catalogs="no"
439                    fi
440                  fi
441                  GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
442                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
443                  USE_INCLUDED_LIBINTL=yes
444                  CATOBJEXT=.cat
445                  INSTOBJEXT=.cat
446                  DATADIRNAME=lib
447                  INTLDEPS='$(top_builddir)/intl/libintl.a'
448                  INTLLIBS=$INTLDEPS
449                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
450                  nls_cv_header_intl=intl/libintl.h
451                  nls_cv_header_libgt=intl/libgettext.h
452                fi])
453           fi
454         fi
455
456         if test "$CATOBJEXT" = "NONE"; then
457           dnl Neither gettext nor catgets in included in the C library.
458           dnl Fall back on GNU gettext library.
459           nls_cv_use_gnu_gettext=yes
460         fi
461       fi
462
463       if test "$nls_cv_use_gnu_gettext" = "yes"; then
464         dnl Mark actions used to generate GNU NLS library.
465         INTLOBJS="\$(GETTOBJS)"
466         GCC_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
467           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
468         GCC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
469         dnl If we didn't find either msgfmt or gmsgfmt, don't try to
470         dnl create a catalog.
471         if test "$MSGFMT" = "msgfmt" && test "$GMSGFMT" = "msgfmt"; then
472           create_catalogs="no"
473         fi
474         GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
475           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
476         AC_SUBST(MSGFMT)
477         USE_INCLUDED_LIBINTL=yes
478         CATOBJEXT=.gmo
479         INSTOBJEXT=.mo
480         DATADIRNAME=share
481         INTLDEPS='$(top_builddir)/intl/libintl.a'
482         INTLLIBS=$INTLDEPS
483         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
484         nls_cv_header_intl=intl/libintl.h
485         nls_cv_header_libgt=intl/libgettext.h
486       fi
487
488       dnl Test whether we really found GNU xgettext.
489       if test "$XGETTEXT" != ":"; then
490         dnl If it is no GNU xgettext we define it as : so that the
491         dnl Makefiles still can work.
492         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
493           : ;
494         else
495           AC_MSG_RESULT(
496             [found xgettext program is not GNU xgettext; ignore it])
497           XGETTEXT=":"
498         fi
499       fi
500
501
502
503       # We need to process the po/ directory.
504       POSUB=po
505     else
506       DATADIRNAME=share
507       nls_cv_header_intl=intl/libintl.h
508       nls_cv_header_libgt=intl/libgettext.h
509     fi
510     AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
511     AC_OUTPUT_COMMANDS(
512      [case "$CONFIG_FILES" in *po/Makefile.in*)
513         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
514       esac])
515
516
517     # If this is used in GNU gettext we have to set USE_NLS to `yes'
518     # because some of the sources are only built for this goal.
519     if test "$PACKAGE" = gettext; then
520       USE_NLS=yes
521       USE_INCLUDED_LIBINTL=yes
522     fi
523
524     dnl These rules are solely for the distribution goal.  While doing this
525     dnl we only have to keep exactly one list of the available catalogs
526     dnl in configure.in.
527     for lang in $ALL_LINGUAS; do
528       GMOFILES="$GMOFILES $lang.gmo"
529       POFILES="$POFILES $lang.po"
530     done
531
532     dnl Make all variables we use known to autoconf.
533     AC_SUBST(USE_INCLUDED_LIBINTL)
534     AC_SUBST(CATALOGS)
535     AC_SUBST(CATOBJEXT)
536     AC_SUBST(DATADIRNAME)
537     AC_SUBST(GMOFILES)
538     AC_SUBST(INSTOBJEXT)
539     AC_SUBST(INTLDEPS)
540     AC_SUBST(INTLLIBS)
541     AC_SUBST(INTLOBJS)
542     AC_SUBST(POFILES)
543     AC_SUBST(POSUB)
544   ])
545
546 AC_DEFUN(AM_GNU_GETTEXT,
547   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
548    AC_REQUIRE([AC_PROG_CC])dnl
549    AC_REQUIRE([AC_PROG_RANLIB])dnl
550    AC_REQUIRE([AC_ISC_POSIX])dnl
551    AC_REQUIRE([AC_HEADER_STDC])dnl
552    AC_REQUIRE([AC_C_CONST])dnl
553    AC_REQUIRE([AC_C_INLINE])dnl
554    AC_REQUIRE([AC_TYPE_OFF_T])dnl
555    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
556    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
557
558    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
559 unistd.h sys/param.h])
560    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
561 strdup __argz_count __argz_stringify __argz_next])
562
563    if test "${ac_cv_func_stpcpy+set}" != "set"; then
564      AC_CHECK_FUNCS(stpcpy)
565    fi
566    if test "${ac_cv_func_stpcpy}" = "yes"; then
567      AC_DEFINE(HAVE_STPCPY)
568    fi
569
570    AM_LC_MESSAGES
571    AM_WITH_NLS
572
573    if test "x$create_catalogs" = "xno"; then
574      AC_MSG_WARN([No program for building catalogs found -> building disabled])
575    fi
576
577    if test "x$CATOBJEXT" != "x" && test "x$create_catalogs" != "xno" ; then
578      if test "x$ALL_LINGUAS" = "x"; then
579        LINGUAS=
580      else
581        AC_MSG_CHECKING(for catalogs to be installed)
582        if test "x$LINGUAS" = "x"; then
583          LINGUAS=$ALL_LINGUAS
584        else
585          NEW_LINGUAS=
586          for lang in $ALL_LINGUAS; do
587            case " $LINGUAS " in
588              *" $lang "*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
589            esac
590          done
591          LINGUAS=$NEW_LINGUAS
592        fi
593        AC_MSG_RESULT($LINGUAS)
594      fi
595
596      dnl Construct list of names of catalog files to be constructed.
597      if test -n "$LINGUAS"; then
598        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
599      fi
600    fi
601
602    dnl The reference to <locale.h> in the installed <libintl.h> file
603    dnl must be resolved because we cannot expect the users of this
604    dnl to define HAVE_LOCALE_H.
605    if test $ac_cv_header_locale_h = yes; then
606      INCLUDE_LOCALE_H="#include <locale.h>"
607    else
608      INCLUDE_LOCALE_H="\
609 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
610    fi
611    AC_SUBST(INCLUDE_LOCALE_H)
612
613    dnl Determine which catalog format we have (if any is needed)
614    dnl For now we know about two different formats:
615    dnl   Linux libc-5 and the normal X/Open format
616    test -d intl || mkdir intl
617    if test "$CATOBJEXT" = ".cat"; then
618      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
619
620      dnl Transform the SED scripts while copying because some dumb SEDs
621      dnl cannot handle comments.
622      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
623    fi
624    dnl po2tbl.sed is always needed.
625    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
626      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
627
628    dnl In the intl/Makefile.in we have a special dependency which makes
629    dnl only sense for gettext.  We comment this out for non-gettext
630    dnl packages.
631    if test "$PACKAGE" = "gettext"; then
632      GT_NO="#NO#"
633      GT_YES=
634    else
635      GT_NO=
636      GT_YES="#YES#"
637    fi
638    AC_SUBST(GT_NO)
639    AC_SUBST(GT_YES)
640
641    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
642    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
643    dnl Try to locate is.
644    MKINSTALLDIRS=
645    if test -n "$ac_aux_dir"; then
646      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
647    fi
648    if test -z "$MKINSTALLDIRS"; then
649      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
650    fi
651    AC_SUBST(MKINSTALLDIRS)
652
653    dnl *** For now the libtool support in intl/Makefile is not for real.
654    l=
655    AC_SUBST(l)
656
657    dnl Generate list of files to be processed by xgettext which will
658    dnl be included in po/Makefile.
659    test -d po || mkdir po
660    if test "x$srcdir" != "x."; then
661      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
662        posrcprefix="$srcdir/"
663      else
664        posrcprefix="../$srcdir/"
665      fi
666    else
667      posrcprefix="../"
668    fi
669    rm -f po/POTFILES
670    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
671         < $srcdir/po/POTFILES.in > po/POTFILES
672   ])
673
674 # Check whether LC_MESSAGES is available in <locale.h>.
675 # Ulrich Drepper <drepper@cygnus.com>, 1995.
676 #
677 # This file can be copied and used freely without restrictions.  It can
678 # be used in projects which are not available under the GNU Public License
679 # but which still want to provide support for the GNU gettext functionality.
680 # Please note that the actual code is *not* freely available.
681
682 # serial 1
683
684 AC_DEFUN(AM_LC_MESSAGES,
685   [if test $ac_cv_header_locale_h = yes; then
686     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
687       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
688        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
689     if test $am_cv_val_LC_MESSAGES = yes; then
690       AC_DEFINE(HAVE_LC_MESSAGES)
691     fi
692   fi])
693
694 # Search path for a program which passes the given test.
695 # Ulrich Drepper <drepper@cygnus.com>, 1996.
696 #
697 # This file can be copied and used freely without restrictions.  It can
698 # be used in projects which are not available under the GNU Public License
699 # but which still want to provide support for the GNU gettext functionality.
700 # Please note that the actual code is *not* freely available.
701
702 # serial 1
703
704 dnl GCC_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
705 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
706 AC_DEFUN(GCC_PATH_PROG_WITH_TEST,
707 [# Extract the first word of "$2", so it can be a program name with args.
708 set dummy $2; ac_word=[$]2
709 AC_MSG_CHECKING([for $ac_word])
710 AC_CACHE_VAL(gcc_cv_path_$1,
711 [case "[$]$1" in
712   /*)
713   gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
714   ;;
715   *)
716   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
717   for ac_dir in ifelse([$5], , $PATH, [$5]); do
718     test -z "$ac_dir" && ac_dir=.
719     if test -f $ac_dir/$ac_word; then
720       if [$3]; then
721         gcc_cv_path_$1="$ac_dir/$ac_word"
722         break
723       fi
724     fi
725   done
726   IFS="$ac_save_ifs"
727 dnl If no 4th arg is given, leave the cache variable unset,
728 dnl so GCC_PATH_PROGS will keep looking.
729 ifelse([$4], , , [  test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$4"
730 ])dnl
731   ;;
732 esac])dnl
733 $1="$gcc_cv_path_$1"
734 if test -n "[$]$1"; then
735   AC_MSG_RESULT([$]$1)
736 else
737   AC_MSG_RESULT(no)
738 fi
739 AC_SUBST($1)dnl
740 ])
741
742 # Check whether mmap can map an arbitrary page from /dev/zero or with
743 # MAP_ANONYMOUS, without MAP_FIXED.
744 AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
745 [AC_CHECK_FUNCS(getpagesize)
746 # The test program for the next two tests is the same except for one
747 # set of ifdefs.
748 changequote({{{,}}})dnl
749 {{{cat >ct-mmap.inc <<'EOF'
750 #include <sys/types.h>
751 #include <sys/mman.h>
752 #include <fcntl.h>
753 #include <signal.h>
754 #include <setjmp.h>
755 #include <stdio.h>
756
757 #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
758 # define MAP_ANONYMOUS MAP_ANON
759 #endif
760
761 /* This mess was copied from the GNU getpagesize.h.  */
762 #ifndef HAVE_GETPAGESIZE
763 # ifdef HAVE_UNISTD_H
764 #  include <unistd.h>
765 # endif
766
767 /* Assume that all systems that can run configure have sys/param.h.  */
768 # ifndef HAVE_SYS_PARAM_H
769 #  define HAVE_SYS_PARAM_H 1
770 # endif
771
772 # ifdef _SC_PAGESIZE
773 #  define getpagesize() sysconf(_SC_PAGESIZE)
774 # else /* no _SC_PAGESIZE */
775 #  ifdef HAVE_SYS_PARAM_H
776 #   include <sys/param.h>
777 #   ifdef EXEC_PAGESIZE
778 #    define getpagesize() EXEC_PAGESIZE
779 #   else /* no EXEC_PAGESIZE */
780 #    ifdef NBPG
781 #     define getpagesize() NBPG * CLSIZE
782 #     ifndef CLSIZE
783 #      define CLSIZE 1
784 #     endif /* no CLSIZE */
785 #    else /* no NBPG */
786 #     ifdef NBPC
787 #      define getpagesize() NBPC
788 #     else /* no NBPC */
789 #      ifdef PAGESIZE
790 #       define getpagesize() PAGESIZE
791 #      endif /* PAGESIZE */
792 #     endif /* no NBPC */
793 #    endif /* no NBPG */
794 #   endif /* no EXEC_PAGESIZE */
795 #  else /* no HAVE_SYS_PARAM_H */
796 #   define getpagesize() 8192   /* punt totally */
797 #  endif /* no HAVE_SYS_PARAM_H */
798 # endif /* no _SC_PAGESIZE */
799
800 #endif /* no HAVE_GETPAGESIZE */
801
802 #ifndef MAP_FAILED
803 # define MAP_FAILED -1
804 #endif
805
806 #undef perror_exit
807 #define perror_exit(str, val) \
808   do { perror(str); exit(val); } while (0)
809
810 /* Some versions of cygwin mmap require that munmap is called with the
811    same parameters as mmap.  GCC expects that this is not the case.
812    Test for various forms of this problem.  Warning - icky signal games.  */
813
814 static sigset_t unblock_sigsegv;
815 static jmp_buf r;
816 static size_t pg;
817 static int devzero;
818
819 static char *
820 anonmap (size)
821      size_t size;
822 {
823 #ifdef USE_MAP_ANON
824   return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
825                         MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
826 #else
827   return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
828                         MAP_PRIVATE, devzero, 0);
829 #endif
830 }
831
832 static void
833 sigsegv (unused)
834      int unused;
835 {
836   sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0);
837   longjmp (r, 1);
838 }
839
840 /* Basic functionality test.  */
841 void
842 test_0 ()
843 {
844   char *x = anonmap (pg);
845   if (x == (char *) MAP_FAILED)
846     perror_exit("test 0 mmap", 2);
847
848   *(int *)x += 1;
849
850   if (munmap(x, pg) < 0)
851     perror_exit("test 0 munmap", 3);
852 }
853
854 /* 1. If we map a 2-page region and unmap its second page, the first page
855    must remain.  */
856 static void
857 test_1 ()
858 {
859   char *x = anonmap (pg * 2);
860   if (x == (char *)MAP_FAILED)
861     perror_exit ("test 1 mmap", 4);
862
863   signal (SIGSEGV, sigsegv);
864   if (setjmp (r))
865     perror_exit ("test 1 fault", 5);
866
867   x[0] = 1;
868   x[pg] = 1;
869
870   if (munmap (x + pg, pg) < 0)
871     perror_exit ("test 1 munmap 1", 6);
872   x[0] = 2;
873
874   if (setjmp (r) == 0)
875     {
876       x[pg] = 1;
877       perror_exit ("test 1 no fault", 7);
878     }
879   if (munmap (x, pg) < 0)
880     perror_exit ("test 1 munmap 2", 8);
881 }
882
883 /* 2. If we map a 2-page region and unmap its first page, the second
884    page must remain.  */
885 static void
886 test_2 ()
887 {
888   char *x = anonmap (pg * 2);
889   if (x == (char *)MAP_FAILED)
890     perror_exit ("test 2 mmap", 9);
891
892   signal (SIGSEGV, sigsegv);
893   if (setjmp (r))
894     perror_exit ("test 2 fault", 10);
895
896   x[0] = 1;
897   x[pg] = 1;
898
899   if (munmap (x, pg) < 0)
900     perror_exit ("test 2 munmap 1", 11);
901
902   x[pg] = 2;
903
904   if (setjmp (r) == 0)
905     {
906       x[0] = 1;
907       perror_exit ("test 2 no fault", 12);
908     }
909
910   if (munmap (x+pg, pg) < 0)
911     perror_exit ("test 2 munmap 2", 13);
912 }
913
914 /* 3. If we map two adjacent 1-page regions and unmap them both with
915    one munmap, both must go away.
916
917    Getting two adjacent 1-page regions with two mmap calls is slightly
918    tricky.  All OS's tested skip over already-allocated blocks; therefore
919    we have been careful to unmap all allocated regions in previous tests.
920    HP/UX allocates pages backward in memory.  No OS has yet been observed
921    to be so perverse as to leave unmapped space between consecutive calls
922    to mmap.  */
923
924 static void
925 test_3 ()
926 {
927   char *x, *y, *z;
928
929   x = anonmap (pg);
930   if (x == (char *)MAP_FAILED)
931     perror_exit ("test 3 mmap 1", 14);
932   y = anonmap (pg);
933   if (y == (char *)MAP_FAILED)
934     perror_exit ("test 3 mmap 2", 15);
935
936   if (y != x + pg)
937     {
938       if (y == x - pg)
939         z = y, y = x, x = z;
940       else
941         {
942           fprintf (stderr, "test 3 nonconsecutive pages - %lx, %lx\n",
943                    (unsigned long)x, (unsigned long)y);
944           exit (16);
945         }
946     }
947
948   signal (SIGSEGV, sigsegv);
949   if (setjmp (r))
950     perror_exit ("test 3 fault", 17);
951
952   x[0] = 1;
953   y[0] = 1;
954
955   if (munmap (x, pg*2) < 0)
956     perror_exit ("test 3 munmap", 18);
957
958   if (setjmp (r) == 0)
959     {
960       x[0] = 1;
961       perror_exit ("test 3 no fault 1", 19);
962     }
963   
964   signal (SIGSEGV, sigsegv);
965   if (setjmp (r) == 0)
966     {
967       y[0] = 1;
968       perror_exit ("test 3 no fault 2", 20);
969     }
970 }
971
972 int
973 main ()
974 {
975   sigemptyset (&unblock_sigsegv);
976   sigaddset (&unblock_sigsegv, SIGSEGV);
977   pg = getpagesize ();
978 #ifndef USE_MAP_ANON
979   devzero = open ("/dev/zero", O_RDWR);
980   if (devzero < 0)
981     perror_exit ("open /dev/zero", 1);
982 #endif
983
984   test_0();
985   test_1();
986   test_2();
987   test_3();
988
989   exit(0);
990 }
991 EOF}}}
992 changequote([,])dnl
993
994 AC_CACHE_CHECK(for working mmap from /dev/zero,
995   ac_cv_func_mmap_dev_zero,
996 [AC_TRY_RUN(
997  [#include "ct-mmap.inc"],
998  ac_cv_func_mmap_dev_zero=yes,
999  [if test $? -lt 4
1000  then ac_cv_func_mmap_dev_zero=no
1001  else ac_cv_func_mmap_dev_zero=buggy
1002  fi],
1003  # If this is not cygwin, and /dev/zero is a character device, it's probably
1004  # safe to assume it works.
1005  [case "$host_os" in
1006    cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;;
1007    * ) if test -c /dev/zero
1008        then ac_cv_func_mmap_dev_zero=yes
1009        else ac_cv_func_mmap_dev_zero=no
1010        fi ;;
1011   esac])
1012 ])
1013 if test $ac_cv_func_mmap_dev_zero = yes; then
1014   AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
1015             [Define if mmap can get us zeroed pages from /dev/zero.])
1016 fi
1017
1018 AC_CACHE_CHECK([for working mmap with MAP_ANON(YMOUS)],
1019   ac_cv_func_mmap_anon,
1020 [AC_TRY_RUN(
1021  [#define USE_MAP_ANON
1022 #include "ct-mmap.inc"],
1023  ac_cv_func_mmap_anon=yes,
1024  [if test $? -lt 4
1025  then ac_cv_func_mmap_anon=no
1026  else ac_cv_func_mmap_anon=buggy
1027  fi],
1028  # Unlike /dev/zero, it is not safe to assume MAP_ANON(YMOUS) works
1029  # just because it's there. Some SCO Un*xen define it but don't implement it.
1030  ac_cv_func_mmap_anon=no)
1031 ])
1032 if test $ac_cv_func_mmap_anon = yes; then
1033   AC_DEFINE(HAVE_MMAP_ANON, 1,
1034             [Define if mmap can get us zeroed pages using MAP_ANON(YMOUS).])
1035 fi
1036 rm -f ct-mmap.inc
1037 ])
1038
1039 # Check whether mmap can map a plain file, without MAP_FIXED.
1040 AC_DEFUN([AC_FUNC_MMAP_FILE], 
1041 [AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file,
1042 [# Create a file one thousand bytes long.
1043 for i in 1 2 3 4 5 6 7 8 9 0
1044 do for j in 1 2 3 4 5 6 7 8 9 0
1045 do echo $i $j xxxxx
1046 done
1047 done > conftestdata$$
1048
1049 AC_TRY_RUN([
1050 /* Test by Zack Weinberg.  Modified from MMAP_ANYWHERE test by
1051    Richard Henderson and Alexandre Oliva.
1052    Check whether read-only mmap of a plain file works. */
1053 #include <sys/types.h>
1054 #include <sys/stat.h>
1055 #include <fcntl.h>
1056 #include <sys/mman.h>
1057
1058 int main()
1059 {
1060   char *x;
1061   int fd;
1062   struct stat st;
1063
1064   fd = open("conftestdata$$", O_RDONLY);
1065   if (fd < 0)
1066     exit(1);
1067
1068   if (fstat (fd, &st))
1069     exit(2);
1070
1071   x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
1072   if (x == (char *) -1)
1073     exit(3);
1074
1075   if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
1076     exit(4);
1077
1078   if (munmap(x, st.st_size) < 0)
1079     exit(5);
1080
1081   exit(0);
1082 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
1083 ac_cv_func_mmap_file=no)])
1084 if test $ac_cv_func_mmap_file = yes; then
1085   AC_DEFINE(HAVE_MMAP_FILE, 1,
1086             [Define if read-only mmap of a plain file works.])
1087 fi
1088 ])
1089
1090 dnl Locate a program and check that its version is acceptable.
1091 dnl AC_PROG_CHECK_VER(var, name, version-switch,
1092 dnl                  version-extract-regexp, version-glob)
1093 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
1094 [AC_CHECK_PROG([$1], [$2], [$2])
1095 if test -n "[$]$1"; then
1096   # Found it, now check the version.
1097   AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
1098 [changequote(<<,>>)dnl
1099   ac_prog_version=`<<$>>$1 $3 2>&1 |
1100                    sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
1101   echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
1102   case $ac_prog_version in
1103     '')     gcc_cv_prog_$2_modern=no;;
1104     <<$5>>)
1105             gcc_cv_prog_$2_modern=yes;;
1106     *)      gcc_cv_prog_$2_modern=no;;
1107   esac
1108 changequote([,])dnl
1109 ])
1110 else
1111   gcc_cv_prog_$2_modern=no
1112 fi
1113 ])