OSDN Git Service

ddfc65131f653e63780c1c1492d77d4a36f9ccee
[pf3gnuchains/gcc-fork.git] / gcc / aclocal.m4
1 dnl 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_NEED_DECLARATION(FUNCTION, INCLUDES,
17 dnl     [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED]])
18 AC_DEFUN(gcc_AC_NEED_DECLARATION,
19 [AC_MSG_CHECKING([whether $1 must be declared])
20 AC_CACHE_VAL(gcc_cv_decl_needed_$1,
21 [AC_TRY_COMPILE([$2],
22 [#ifndef $1
23 char *(*pfn) = (char *(*)) $1 ;
24 #endif], eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
25 if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
26   AC_MSG_RESULT(yes) ; ifelse([$3], , :, [$3])
27 else
28   AC_MSG_RESULT(no) ; ifelse([$4], , :, [$4])
29 fi
30 ])dnl
31
32 dnl Check multiple functions to see whether each needs a declaration.
33 dnl Arrange to define NEED_DECLARATION_<FUNCTION> if appropriate.
34 dnl gcc_AC_NEED_DECLARATIONS(FUNCTION... , INCLUDES,
35 dnl     [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED]])
36 AC_DEFUN(gcc_AC_NEED_DECLARATIONS,
37 [for ac_func in $1
38 do
39 gcc_AC_NEED_DECLARATION($ac_func, [$2],
40 [changequote(, )dnl
41   ac_tr_decl=NEED_DECLARATION_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
42 changequote([, ])dnl
43   AC_DEFINE_UNQUOTED($ac_tr_decl) $3], $4)
44 done
45 dnl Automatically generate config.h entries via autoheader.
46 if test x = y ; then
47   patsubst(translit([$1], [a-z], [A-Z]), [\w+],
48     AC_DEFINE([NEED_DECLARATION_\&], 1,
49       [Define if you need to provide a declaration for this function.]))dnl
50 fi
51 ])
52
53 dnl Check if we have vprintf and possibly _doprnt.
54 dnl Note autoconf checks for vprintf even though we care about vfprintf.
55 AC_DEFUN(gcc_AC_FUNC_VFPRINTF_DOPRNT,
56 [AC_FUNC_VPRINTF
57 vfprintf=
58 doprint=
59 if test $ac_cv_func_vprintf != yes ; then
60   vfprintf=vfprintf.o
61   if test $ac_cv_func__doprnt != yes ; then
62     doprint=doprint.o
63   fi
64 fi
65 AC_SUBST(vfprintf)
66 AC_SUBST(doprint)
67 ])    
68
69 dnl See if the printf functions in libc support %p in format strings.
70 AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
71 [AC_CACHE_CHECK(whether the printf functions support %p,
72   gcc_cv_func_printf_ptr,
73 [AC_TRY_RUN([#include <stdio.h>
74
75 int main()
76 {
77   char buf[64];
78   char *p = buf, *q = NULL;
79   sprintf(buf, "%p", p);
80   sscanf(buf, "%p", &q);
81   return (p != q);
82 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
83         gcc_cv_func_printf_ptr=no)
84 rm -f core core.* *.core])
85 if test $gcc_cv_func_printf_ptr = yes ; then
86   AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
87 fi
88 ])
89
90 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
91 AC_DEFUN(gcc_AC_PROG_LN_S,
92 [AC_MSG_CHECKING(whether ln -s works)
93 AC_CACHE_VAL(gcc_cv_prog_LN_S,
94 [rm -f conftestdata_t
95 echo >conftestdata_f
96 if ln -s conftestdata_f conftestdata_t 2>/dev/null
97 then
98   gcc_cv_prog_LN_S="ln -s"
99 else
100   if ln conftestdata_f conftestdata_t 2>/dev/null
101   then
102     gcc_cv_prog_LN_S=ln
103   else
104     gcc_cv_prog_LN_S=cp
105   fi
106 fi
107 rm -f conftestdata_f conftestdata_t
108 ])dnl
109 LN_S="$gcc_cv_prog_LN_S"
110 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
111   AC_MSG_RESULT(yes)
112 else
113   if test "$gcc_cv_prog_LN_S" = "ln"; then
114     AC_MSG_RESULT([no, using ln])
115   else
116     AC_MSG_RESULT([no, and neither does ln, so using cp])
117   fi
118 fi
119 AC_SUBST(LN_S)dnl
120 ])
121
122 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
123 AC_DEFUN(gcc_AC_PROG_LN,
124 [AC_MSG_CHECKING(whether ln works)
125 AC_CACHE_VAL(gcc_cv_prog_LN,
126 [rm -f conftestdata_t
127 echo >conftestdata_f
128 if ln conftestdata_f conftestdata_t 2>/dev/null
129 then
130   gcc_cv_prog_LN="ln"
131 else
132   if ln -s conftestdata_f conftestdata_t 2>/dev/null
133   then
134     gcc_cv_prog_LN="ln -s"
135   else
136     gcc_cv_prog_LN=cp
137   fi
138 fi
139 rm -f conftestdata_f conftestdata_t
140 ])dnl
141 LN="$gcc_cv_prog_LN"
142 if test "$gcc_cv_prog_LN" = "ln"; then
143   AC_MSG_RESULT(yes)
144 else
145   if test "$gcc_cv_prog_LN" = "ln -s"; then
146     AC_MSG_RESULT([no, using ln -s])
147   else
148     AC_MSG_RESULT([no, and neither does ln -s, so using cp])
149   fi
150 fi
151 AC_SUBST(LN)dnl
152 ])
153
154 dnl See whether the stage1 host compiler accepts the volatile keyword.
155 AC_DEFUN(gcc_AC_C_VOLATILE,
156 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
157 [AC_TRY_COMPILE(, [volatile int foo;],
158         gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
159 if test $gcc_cv_c_volatile = yes ; then
160   AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.])
161 fi
162 ])
163
164 dnl Check whether long double is supported.  This differs from the
165 dnl built-in autoconf test in that it works for cross compiles.
166 AC_DEFUN(gcc_AC_C_LONG_DOUBLE,
167 [AC_CACHE_CHECK(for long double, gcc_cv_c_long_double,
168 [if test "$GCC" = yes; then
169   gcc_cv_c_long_double=yes
170 else
171 AC_TRY_COMPILE(,
172 [/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
173 long double foo = 0.0;
174 /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
175 switch (0) case 0: case (sizeof(long double) >= sizeof(double)):;],
176 gcc_cv_c_long_double=yes, gcc_cv_c_long_double=no)
177 fi])
178 if test $gcc_cv_c_long_double = yes; then
179   AC_DEFINE(HAVE_LONG_DOUBLE)
180 fi
181 ])
182
183 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
184 dnl of the usual 2.
185 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
186 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
187 [AC_TRY_COMPILE([
188 #include <sys/types.h>
189 #ifdef HAVE_SYS_STAT_H
190 # include <sys/stat.h>
191 #endif
192 #ifdef HAVE_UNISTD_H
193 # include <unistd.h>
194 #endif
195 #ifdef HAVE_DIRECT_H
196 # include <direct.h>
197 #endif], [mkdir ("foo", 0);], 
198         gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
199 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
200   AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
201 fi
202 ])
203
204 AC_DEFUN(gcc_AC_PROG_INSTALL,
205 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
206 # Find a good install program.  We prefer a C program (faster),
207 # so one script is as good as another.  But avoid the broken or
208 # incompatible versions:
209 # SysV /etc/install, /usr/sbin/install
210 # SunOS /usr/etc/install
211 # IRIX /sbin/install
212 # AIX /bin/install
213 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
214 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
215 # ./install, which can be erroneously created by make from ./install.sh.
216 AC_MSG_CHECKING(for a BSD compatible install)
217 if test -z "$INSTALL"; then
218 AC_CACHE_VAL(ac_cv_path_install,
219 [  IFS="${IFS=  }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
220   for ac_dir in $PATH; do
221     # Account for people who put trailing slashes in PATH elements.
222     case "$ac_dir/" in
223     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
224     *)
225       # OSF1 and SCO ODT 3.0 have their own names for install.
226       for ac_prog in ginstall scoinst install; do
227         if test -f $ac_dir/$ac_prog; then
228           if test $ac_prog = install &&
229             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
230             # AIX install.  It has an incompatible calling convention.
231             # OSF/1 installbsd also uses dspmsg, but is usable.
232             :
233           else
234             ac_cv_path_install="$ac_dir/$ac_prog -c"
235             break 2
236           fi
237         fi
238       done
239       ;;
240     esac
241   done
242   IFS="$ac_save_IFS"
243 ])dnl
244   if test "${ac_cv_path_install+set}" = set; then
245     INSTALL="$ac_cv_path_install"
246   else
247     # As a last resort, use the slow shell script.  We don't cache a
248     # path for INSTALL within a source directory, because that will
249     # break other packages using the cache if that directory is
250     # removed, or if the path is relative.
251     INSTALL="$ac_install_sh"
252   fi
253 fi
254 dnl We do special magic for INSTALL instead of AC_SUBST, to get
255 dnl relative paths right.
256 AC_MSG_RESULT($INSTALL)
257 AC_SUBST(INSTALL)dnl
258
259 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
260 # It thinks the first close brace ends the variable substitution.
261 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
262 AC_SUBST(INSTALL_PROGRAM)dnl
263
264 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
265 AC_SUBST(INSTALL_DATA)dnl
266 ])
267
268 #serial 1
269 dnl This test replaces the one in autoconf.
270 dnl Currently this macro should have the same name as the autoconf macro
271 dnl because gettext's gettext.m4 (distributed in the automake package)
272 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
273 dnl give these diagnostics:
274 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
275 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
276
277 undefine([AC_ISC_POSIX])
278 AC_DEFUN(AC_ISC_POSIX,
279   [
280     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
281     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
282   ]
283 )
284
285 # Macro to add for using GNU gettext.
286 # Ulrich Drepper <drepper@cygnus.com>, 1995.
287 #
288 # This file can be copied and used freely without restrictions.  It can
289 # be used in projects which are not available under the GNU Public License
290 # but which still want to provide support for the GNU gettext functionality.
291 # Please note that the actual code is *not* freely available.
292
293 # serial 5
294
295 AC_DEFUN(AM_WITH_NLS,
296   [AC_MSG_CHECKING([whether NLS is requested])
297     dnl Default is enabled NLS
298     AC_ARG_ENABLE(nls,
299       [  --disable-nls           do not use Native Language Support],
300       USE_NLS=$enableval, USE_NLS=yes)
301     AC_MSG_RESULT($USE_NLS)
302     AC_SUBST(USE_NLS)
303
304     USE_INCLUDED_LIBINTL=no
305
306     dnl If we use NLS figure out what method
307     if test "$USE_NLS" = "yes"; then
308       AC_DEFINE(ENABLE_NLS)
309       AC_MSG_CHECKING([whether included gettext is requested])
310       AC_ARG_WITH(included-gettext,
311         [  --with-included-gettext use the GNU gettext library included here],
312         nls_cv_force_use_gnu_gettext=$withval,
313         nls_cv_force_use_gnu_gettext=no)
314       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
315
316       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
317       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
318         dnl User does not insist on using GNU NLS library.  Figure out what
319         dnl to use.  If gettext or catgets are available (in this order) we
320         dnl use this.  Else we have to fall back to GNU NLS library.
321         dnl catgets is only used if permitted by option --with-catgets.
322         nls_cv_header_intl=
323         nls_cv_header_libgt=
324         CATOBJEXT=NONE
325
326         AC_CHECK_HEADER(libintl.h,
327           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
328             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
329                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
330
331            if test "$gt_cv_func_gettext_libc" != "yes"; then
332              AC_CHECK_LIB(intl, bindtextdomain,
333                [AC_CACHE_CHECK([for gettext in libintl],
334                  gt_cv_func_gettext_libintl,
335                  [AC_CHECK_LIB(intl, gettext,
336                   gt_cv_func_gettext_libintl=yes,
337                   gt_cv_func_gettext_libintl=no)],
338                  gt_cv_func_gettext_libintl=no)])
339            fi
340
341            if test "$gt_cv_func_gettext_libc" = "yes" \
342               || test "$gt_cv_func_gettext_libintl" = "yes"; then
343               AC_DEFINE(HAVE_GETTEXT)
344               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
345                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
346               if test "$MSGFMT" != "no"; then
347                 AC_CHECK_FUNCS(dcgettext)
348                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
349                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
350                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
351                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
352                                return _nl_msg_cat_cntr],
353                   [CATOBJEXT=.gmo
354                    DATADIRNAME=share],
355                   [CATOBJEXT=.mo
356                    DATADIRNAME=lib])
357                 INSTOBJEXT=.mo
358               fi
359             fi
360         ])
361
362         if test "$CATOBJEXT" = "NONE"; then
363           AC_MSG_CHECKING([whether catgets can be used])
364           AC_ARG_WITH(catgets,
365             [  --with-catgets          use catgets functions if available],
366             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
367           AC_MSG_RESULT($nls_cv_use_catgets)
368
369           if test "$nls_cv_use_catgets" = "yes"; then
370             dnl No gettext in C library.  Try catgets next.
371             AC_CHECK_LIB(i, main)
372             AC_CHECK_FUNC(catgets,
373               [AC_DEFINE(HAVE_CATGETS)
374                INTLOBJS="\$(CATOBJS)"
375                AC_PATH_PROG(GENCAT, gencat, no)dnl
376                if test "$GENCAT" != "no"; then
377                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
378                  if test "$GMSGFMT" = "no"; then
379                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
380                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
381                  fi
382                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
383                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
384                  USE_INCLUDED_LIBINTL=yes
385                  CATOBJEXT=.cat
386                  INSTOBJEXT=.cat
387                  DATADIRNAME=lib
388                  INTLDEPS='$(top_builddir)/intl/libintl.a'
389                  INTLLIBS=$INTLDEPS
390                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
391                  nls_cv_header_intl=intl/libintl.h
392                  nls_cv_header_libgt=intl/libgettext.h
393                fi])
394           fi
395         fi
396
397         if test "$CATOBJEXT" = "NONE"; then
398           dnl Neither gettext nor catgets in included in the C library.
399           dnl Fall back on GNU gettext library.
400           nls_cv_use_gnu_gettext=yes
401         fi
402       fi
403
404       if test "$nls_cv_use_gnu_gettext" = "yes"; then
405         dnl Mark actions used to generate GNU NLS library.
406         INTLOBJS="\$(GETTOBJS)"
407         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
408           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
409         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
410         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
411           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
412         AC_SUBST(MSGFMT)
413         USE_INCLUDED_LIBINTL=yes
414         CATOBJEXT=.gmo
415         INSTOBJEXT=.mo
416         DATADIRNAME=share
417         INTLDEPS='$(top_builddir)/intl/libintl.a'
418         INTLLIBS=$INTLDEPS
419         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
420         nls_cv_header_intl=intl/libintl.h
421         nls_cv_header_libgt=intl/libgettext.h
422       fi
423
424       dnl Test whether we really found GNU xgettext.
425       if test "$XGETTEXT" != ":"; then
426         dnl If it is no GNU xgettext we define it as : so that the
427         dnl Makefiles still can work.
428         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
429           : ;
430         else
431           AC_MSG_RESULT(
432             [found xgettext program is not GNU xgettext; ignore it])
433           XGETTEXT=":"
434         fi
435       fi
436
437       # We need to process the po/ directory.
438       POSUB=po
439     else
440       DATADIRNAME=share
441       nls_cv_header_intl=intl/libintl.h
442       nls_cv_header_libgt=intl/libgettext.h
443     fi
444     AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
445     AC_OUTPUT_COMMANDS(
446      [case "$CONFIG_FILES" in *po/Makefile.in*)
447         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
448       esac])
449
450
451     # If this is used in GNU gettext we have to set USE_NLS to `yes'
452     # because some of the sources are only built for this goal.
453     if test "$PACKAGE" = gettext; then
454       USE_NLS=yes
455       USE_INCLUDED_LIBINTL=yes
456     fi
457
458     dnl These rules are solely for the distribution goal.  While doing this
459     dnl we only have to keep exactly one list of the available catalogs
460     dnl in configure.in.
461     for lang in $ALL_LINGUAS; do
462       GMOFILES="$GMOFILES $lang.gmo"
463       POFILES="$POFILES $lang.po"
464     done
465
466     dnl Make all variables we use known to autoconf.
467     AC_SUBST(USE_INCLUDED_LIBINTL)
468     AC_SUBST(CATALOGS)
469     AC_SUBST(CATOBJEXT)
470     AC_SUBST(DATADIRNAME)
471     AC_SUBST(GMOFILES)
472     AC_SUBST(INSTOBJEXT)
473     AC_SUBST(INTLDEPS)
474     AC_SUBST(INTLLIBS)
475     AC_SUBST(INTLOBJS)
476     AC_SUBST(POFILES)
477     AC_SUBST(POSUB)
478   ])
479
480 AC_DEFUN(AM_GNU_GETTEXT,
481   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
482    AC_REQUIRE([AC_PROG_CC])dnl
483    AC_REQUIRE([AC_PROG_RANLIB])dnl
484    AC_REQUIRE([AC_ISC_POSIX])dnl
485    AC_REQUIRE([AC_HEADER_STDC])dnl
486    AC_REQUIRE([AC_C_CONST])dnl
487    AC_REQUIRE([AC_C_INLINE])dnl
488    AC_REQUIRE([AC_TYPE_OFF_T])dnl
489    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
490    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
491
492    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
493 unistd.h sys/param.h])
494    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
495 strdup __argz_count __argz_stringify __argz_next])
496
497    if test "${ac_cv_func_stpcpy+set}" != "set"; then
498      AC_CHECK_FUNCS(stpcpy)
499    fi
500    if test "${ac_cv_func_stpcpy}" = "yes"; then
501      AC_DEFINE(HAVE_STPCPY)
502    fi
503
504    AM_LC_MESSAGES
505    AM_WITH_NLS
506
507    if test "x$CATOBJEXT" != "x"; then
508      if test "x$ALL_LINGUAS" = "x"; then
509        LINGUAS=
510      else
511        AC_MSG_CHECKING(for catalogs to be installed)
512        NEW_LINGUAS=
513        for lang in ${LINGUAS=$ALL_LINGUAS}; do
514          case "$ALL_LINGUAS" in
515           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
516          esac
517        done
518        LINGUAS=$NEW_LINGUAS
519        AC_MSG_RESULT($LINGUAS)
520      fi
521
522      dnl Construct list of names of catalog files to be constructed.
523      if test -n "$LINGUAS"; then
524        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
525      fi
526    fi
527
528    dnl The reference to <locale.h> in the installed <libintl.h> file
529    dnl must be resolved because we cannot expect the users of this
530    dnl to define HAVE_LOCALE_H.
531    if test $ac_cv_header_locale_h = yes; then
532      INCLUDE_LOCALE_H="#include <locale.h>"
533    else
534      INCLUDE_LOCALE_H="\
535 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
536    fi
537    AC_SUBST(INCLUDE_LOCALE_H)
538
539    dnl Determine which catalog format we have (if any is needed)
540    dnl For now we know about two different formats:
541    dnl   Linux libc-5 and the normal X/Open format
542    test -d intl || mkdir intl
543    if test "$CATOBJEXT" = ".cat"; then
544      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
545
546      dnl Transform the SED scripts while copying because some dumb SEDs
547      dnl cannot handle comments.
548      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
549    fi
550    dnl po2tbl.sed is always needed.
551    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
552      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
553
554    dnl In the intl/Makefile.in we have a special dependency which makes
555    dnl only sense for gettext.  We comment this out for non-gettext
556    dnl packages.
557    if test "$PACKAGE" = "gettext"; then
558      GT_NO="#NO#"
559      GT_YES=
560    else
561      GT_NO=
562      GT_YES="#YES#"
563    fi
564    AC_SUBST(GT_NO)
565    AC_SUBST(GT_YES)
566
567    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
568    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
569    dnl Try to locate is.
570    MKINSTALLDIRS=
571    if test -n "$ac_aux_dir"; then
572      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
573    fi
574    if test -z "$MKINSTALLDIRS"; then
575      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
576    fi
577    AC_SUBST(MKINSTALLDIRS)
578
579    dnl *** For now the libtool support in intl/Makefile is not for real.
580    l=
581    AC_SUBST(l)
582
583    dnl Generate list of files to be processed by xgettext which will
584    dnl be included in po/Makefile.
585    test -d po || mkdir po
586    if test "x$srcdir" != "x."; then
587      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
588        posrcprefix="$srcdir/"
589      else
590        posrcprefix="../$srcdir/"
591      fi
592    else
593      posrcprefix="../"
594    fi
595    rm -f po/POTFILES
596    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
597         < $srcdir/po/POTFILES.in > po/POTFILES
598   ])
599
600 # Check whether LC_MESSAGES is available in <locale.h>.
601 # Ulrich Drepper <drepper@cygnus.com>, 1995.
602 #
603 # This file can be copied and used freely without restrictions.  It can
604 # be used in projects which are not available under the GNU Public License
605 # but which still want to provide support for the GNU gettext functionality.
606 # Please note that the actual code is *not* freely available.
607
608 # serial 1
609
610 AC_DEFUN(AM_LC_MESSAGES,
611   [if test $ac_cv_header_locale_h = yes; then
612     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
613       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
614        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
615     if test $am_cv_val_LC_MESSAGES = yes; then
616       AC_DEFINE(HAVE_LC_MESSAGES)
617     fi
618   fi])
619
620 # Search path for a program which passes the given test.
621 # Ulrich Drepper <drepper@cygnus.com>, 1996.
622 #
623 # This file can be copied and used freely without restrictions.  It can
624 # be used in projects which are not available under the GNU Public License
625 # but which still want to provide support for the GNU gettext functionality.
626 # Please note that the actual code is *not* freely available.
627
628 # serial 1
629
630 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
631 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
632 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
633 [# Extract the first word of "$2", so it can be a program name with args.
634 set dummy $2; ac_word=[$]2
635 AC_MSG_CHECKING([for $ac_word])
636 AC_CACHE_VAL(ac_cv_path_$1,
637 [case "[$]$1" in
638   /*)
639   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
640   ;;
641   *)
642   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
643   for ac_dir in ifelse([$5], , $PATH, [$5]); do
644     test -z "$ac_dir" && ac_dir=.
645     if test -f $ac_dir/$ac_word; then
646       if [$3]; then
647         ac_cv_path_$1="$ac_dir/$ac_word"
648         break
649       fi
650     fi
651   done
652   IFS="$ac_save_ifs"
653 dnl If no 4th arg is given, leave the cache variable unset,
654 dnl so AC_PATH_PROGS will keep looking.
655 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
656 ])dnl
657   ;;
658 esac])dnl
659 $1="$ac_cv_path_$1"
660 if test -n "[$]$1"; then
661   AC_MSG_RESULT([$]$1)
662 else
663   AC_MSG_RESULT(no)
664 fi
665 AC_SUBST($1)dnl
666 ])
667
668 # Check whether mmap can map an arbitrary page from /dev/zero, without
669 # MAP_FIXED.
670 AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
671 [AC_CHECK_HEADERS(unistd.h)
672 AC_CHECK_FUNCS(getpagesize)
673 AC_CACHE_CHECK(for working mmap from /dev/zero, ac_cv_func_mmap_anywhere,
674 [AC_TRY_RUN([
675 /* Test by Richard Henderson and Alexandre Oliva.
676    Check whether mmap from /dev/zero works. */
677 #include <sys/types.h>
678 #include <fcntl.h>
679 #include <sys/mman.h>
680
681 /* This mess was copied from the GNU getpagesize.h.  */
682 #ifndef HAVE_GETPAGESIZE
683 # ifdef HAVE_UNISTD_H
684 #  include <unistd.h>
685 # endif
686
687 /* Assume that all systems that can run configure have sys/param.h.  */
688 # ifndef HAVE_SYS_PARAM_H
689 #  define HAVE_SYS_PARAM_H 1
690 # endif
691
692 # ifdef _SC_PAGESIZE
693 #  define getpagesize() sysconf(_SC_PAGESIZE)
694 # else /* no _SC_PAGESIZE */
695 #  ifdef HAVE_SYS_PARAM_H
696 #   include <sys/param.h>
697 #   ifdef EXEC_PAGESIZE
698 #    define getpagesize() EXEC_PAGESIZE
699 #   else /* no EXEC_PAGESIZE */
700 #    ifdef NBPG
701 #     define getpagesize() NBPG * CLSIZE
702 #     ifndef CLSIZE
703 #      define CLSIZE 1
704 #     endif /* no CLSIZE */
705 #    else /* no NBPG */
706 #     ifdef NBPC
707 #      define getpagesize() NBPC
708 #     else /* no NBPC */
709 #      ifdef PAGESIZE
710 #       define getpagesize() PAGESIZE
711 #      endif /* PAGESIZE */
712 #     endif /* no NBPC */
713 #    endif /* no NBPG */
714 #   endif /* no EXEC_PAGESIZE */
715 #  else /* no HAVE_SYS_PARAM_H */
716 #   define getpagesize() 8192   /* punt totally */
717 #  endif /* no HAVE_SYS_PARAM_H */
718 # endif /* no _SC_PAGESIZE */
719
720 #endif /* no HAVE_GETPAGESIZE */
721
722 int main()
723 {
724   char *x;
725   int fd, pg;
726
727   fd = open("/dev/zero", O_RDWR);
728   if (fd < 0)
729     exit(1);
730
731   pg = getpagesize();
732   x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
733   if (x == (char *) -1)
734     exit(2);
735
736   *(int *)x += 1;
737
738   if (munmap(x, pg) < 0)
739     exit(3);
740
741   exit(0);
742 }], ac_cv_func_mmap_anywhere=yes, ac_cv_func_mmap_anywhere=no,
743 ac_cv_func_mmap_anywhere=no)])
744 if test $ac_cv_func_mmap_anywhere = yes; then
745   AC_DEFINE(HAVE_MMAP_ANYWHERE, 1,
746             [Define if mmap can get us zeroed pages from /dev/zero.])
747 fi
748 ])
749
750 # Check whether mmap can map a plain file, without MAP_FIXED.
751 AC_DEFUN([AC_FUNC_MMAP_FILE], 
752 [AC_REQUIRE([AC_FUNC_MMAP_ANYWHERE])dnl
753 AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file,
754 [# Create a file one thousand bytes long.
755 for i in 1 2 3 4 5 6 7 8 9 0
756 do for j in 1 2 3 4 5 6 7 8 9 0
757 do echo $i $j xxxxx
758 done
759 done > conftestdata$$
760
761 AC_TRY_RUN([
762 /* Test by Zack Weinberg.  Modified from MMAP_ANYWHERE test by
763    Richard Henderson and Alexandre Oliva.
764    Check whether read-only mmap of a plain file works. */
765 #include <sys/types.h>
766 #include <sys/stat.h>
767 #include <fcntl.h>
768 #include <sys/mman.h>
769
770 int main()
771 {
772   char *x;
773   int fd;
774   struct stat st;
775
776   fd = open("conftestdata$$", O_RDONLY);
777   if (fd < 0)
778     exit(1);
779
780   if (fstat (fd, &st))
781     exit(2);
782
783   x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
784   if (x == (char *) -1)
785     exit(3);
786
787   if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
788     exit(4);
789
790   if (munmap(x, st.st_size) < 0)
791     exit(5);
792
793   exit(0);
794 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
795 ac_cv_func_mmap_file=no)])
796 if test $ac_cv_func_mmap_file = yes; then
797   AC_DEFINE(HAVE_MMAP_FILE, 1,
798             [Define if read-only mmap of a plain file works.])
799 fi
800 ])
801
802 dnl Locate a program and check that its version is acceptable.
803 dnl AC_PROG_CHECK_VER(var, name, version-switch,
804 dnl                  version-extract-regexp, version-glob)
805 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
806 [AC_CHECK_PROG([$1], [$2], [$2])
807 if test -n "[$]$1"; then
808   # Found it, now check the version.
809   AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
810 [changequote(<<,>>)dnl
811   ac_prog_version=`<<$>>$1 $3 2>&1 |
812                    sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
813   echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
814   case $ac_prog_version in
815     '')     gcc_cv_prog_$2_modern=no;;
816     <<$5>>)
817             gcc_cv_prog_$2_modern=yes;;
818     *)      gcc_cv_prog_$2_modern=no;;
819   esac
820 changequote([,])dnl
821 ])
822 else
823   gcc_cv_prog_$2_modern=no
824 fi
825 ])