OSDN Git Service

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