Import final gcc2 snapshot (990109)
[official-gcc.git] / gcc / aclocal.m4
blob76d8b682ef9af24497b60885c8d6fde2adbf221e
1 dnl See whether we can include both string.h and strings.h.
2 AC_DEFUN(GCC_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
12 dnl See whether we need a declaration for a function.
13 dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
14 AC_DEFUN(GCC_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 #define rindex strrchr
39 #endif
40 #ifndef HAVE_INDEX
41 #define index strchr
42 #endif
43 $2],
44 [char *(*pfn) = (char *(*)) $1],
45 eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
46 if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
47   AC_MSG_RESULT(yes)
48   gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
49   AC_DEFINE_UNQUOTED($gcc_tr_decl)
50 else
51   AC_MSG_RESULT(no)
53 ])dnl
55 dnl Check multiple functions to see whether each needs a declaration.
56 dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
57 AC_DEFUN(GCC_NEED_DECLARATIONS,
58 [for ac_func in $1
60 GCC_NEED_DECLARATION($ac_func, $2)
61 done
64 dnl Use <inttypes.h> only if it exists,
65 dnl doesn't clash with <sys/types.h>, and declares intmax_t.
66 AC_DEFUN(GCC_HEADER_INTTYPES,
67 [AC_MSG_CHECKING(for inttypes.h)
68 AC_CACHE_VAL(gcc_cv_header_inttypes_h,
69 [AC_TRY_COMPILE(
70   [#include <sys/types.h>
71 #include <inttypes.h>],
72   [intmax_t i = -1;],
73   gcc_cv_header_inttypes_h=yes,
74   gcc_cv_header_inttypes_h=no)])
75 AC_MSG_RESULT($gcc_cv_header_inttypes_h)
76 if test $gcc_cv_header_inttypes_h = yes; then
77   AC_DEFINE(HAVE_INTTYPES_H)
81 dnl See if the system preprocessor understands the ANSI C preprocessor
82 dnl stringification operator.
83 AC_DEFUN(GCC_CHECK_STRINGIFY,
84 [AC_MSG_CHECKING(whether cpp understands the stringify operator)
85 AC_CACHE_VAL(gcc_cv_c_have_stringify,
86 [AC_TRY_COMPILE(,
87 [#define S(x)   #x
88 char *test = S(foo);],
89 gcc_cv_c_have_stringify=yes, gcc_cv_c_have_stringify=no)])
90 AC_MSG_RESULT($gcc_cv_c_have_stringify)
91 if test $gcc_cv_c_have_stringify = yes; then
92   AC_DEFINE(HAVE_CPP_STRINGIFY)
96 dnl Check if we have vprintf and possibly _doprnt.
97 dnl Note autoconf checks for vprintf even though we care about vfprintf.
98 AC_DEFUN(GCC_FUNC_VFPRINTF_DOPRNT,
99 [AC_FUNC_VPRINTF
100 vfprintf=
101 doprint=
102 if test $ac_cv_func_vprintf != yes ; then
103   vfprintf=vfprintf.o
104   if test $ac_cv_func__doprnt != yes ; then
105     doprint=doprint.o
106   fi
108 AC_SUBST(vfprintf)
109 AC_SUBST(doprint)
110 ])    
112 dnl See if the printf functions in libc support %p in format strings.
113 AC_DEFUN(GCC_FUNC_PRINTF_PTR,
114 [AC_CACHE_CHECK(whether the printf functions support %p,
115   gcc_cv_func_printf_ptr,
116 [AC_TRY_RUN([#include <stdio.h>
118 main()
120   char buf[64];
121   char *p = buf, *q = NULL;
122   sprintf(buf, "%p", p);
123   sscanf(buf, "%p", &q);
124   exit (p != q);
125 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
126         gcc_cv_func_printf_ptr=no)
127 rm -f core core.* *.core])
128 if test $gcc_cv_func_printf_ptr = yes ; then
129   AC_DEFINE(HAVE_PRINTF_PTR)
133 dnl See whether the stage1 host compiler accepts the volatile keyword.
134 AC_DEFUN(GCC_C_VOLATILE,
135 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
136 [AC_TRY_COMPILE(, [volatile int foo;],
137         gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
138 if test $gcc_cv_c_volatile = yes ; then
139   AC_DEFINE(HAVE_VOLATILE)
143 #serial 1
144 dnl This test replaces the one in autoconf.
145 dnl Currently this macro should have the same name as the autoconf macro
146 dnl because gettext's gettext.m4 (distributed in the automake package)
147 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
148 dnl give these diagnostics:
149 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
150 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
152 undefine([AC_ISC_POSIX])
153 AC_DEFUN(AC_ISC_POSIX,
154   [
155     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
156     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
157   ]
160 # Macro to add for using GNU gettext.
161 # Ulrich Drepper <drepper@cygnus.com>, 1995.
163 # This file can be copied and used freely without restrictions.  It can
164 # be used in projects which are not available under the GNU Public License
165 # but which still want to provide support for the GNU gettext functionality.
166 # Please note that the actual code is *not* freely available.
168 # serial 5
170 AC_DEFUN(AM_WITH_NLS,
171   [AC_MSG_CHECKING([whether NLS is requested])
172     dnl Default is enabled NLS
173     AC_ARG_ENABLE(nls,
174       [  --disable-nls           do not use Native Language Support],
175       USE_NLS=$enableval, USE_NLS=yes)
176     AC_MSG_RESULT($USE_NLS)
177     AC_SUBST(USE_NLS)
179     USE_INCLUDED_LIBINTL=no
181     dnl If we use NLS figure out what method
182     if test "$USE_NLS" = "yes"; then
183       AC_DEFINE(ENABLE_NLS)
184       AC_MSG_CHECKING([whether included gettext is requested])
185       AC_ARG_WITH(included-gettext,
186         [  --with-included-gettext use the GNU gettext library included here],
187         nls_cv_force_use_gnu_gettext=$withval,
188         nls_cv_force_use_gnu_gettext=no)
189       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
191       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
192       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
193         dnl User does not insist on using GNU NLS library.  Figure out what
194         dnl to use.  If gettext or catgets are available (in this order) we
195         dnl use this.  Else we have to fall back to GNU NLS library.
196         dnl catgets is only used if permitted by option --with-catgets.
197         nls_cv_header_intl=
198         nls_cv_header_libgt=
199         CATOBJEXT=NONE
201         AC_CHECK_HEADER(libintl.h,
202           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
203             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
204                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
206            if test "$gt_cv_func_gettext_libc" != "yes"; then
207              AC_CHECK_LIB(intl, bindtextdomain,
208                [AC_CACHE_CHECK([for gettext in libintl],
209                  gt_cv_func_gettext_libintl,
210                  [AC_CHECK_LIB(intl, gettext,
211                   gt_cv_func_gettext_libintl=yes,
212                   gt_cv_func_gettext_libintl=no)],
213                  gt_cv_func_gettext_libintl=no)])
214            fi
216            if test "$gt_cv_func_gettext_libc" = "yes" \
217               || test "$gt_cv_func_gettext_libintl" = "yes"; then
218               AC_DEFINE(HAVE_GETTEXT)
219               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
220                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
221               if test "$MSGFMT" != "no"; then
222                 AC_CHECK_FUNCS(dcgettext)
223                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
224                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
225                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
226                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
227                                return _nl_msg_cat_cntr],
228                   [CATOBJEXT=.gmo
229                    DATADIRNAME=share],
230                   [CATOBJEXT=.mo
231                    DATADIRNAME=lib])
232                 INSTOBJEXT=.mo
233               fi
234             fi
235         ])
237         if test "$CATOBJEXT" = "NONE"; then
238           AC_MSG_CHECKING([whether catgets can be used])
239           AC_ARG_WITH(catgets,
240             [  --with-catgets          use catgets functions if available],
241             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
242           AC_MSG_RESULT($nls_cv_use_catgets)
244           if test "$nls_cv_use_catgets" = "yes"; then
245             dnl No gettext in C library.  Try catgets next.
246             AC_CHECK_LIB(i, main)
247             AC_CHECK_FUNC(catgets,
248               [AC_DEFINE(HAVE_CATGETS)
249                INTLOBJS="\$(CATOBJS)"
250                AC_PATH_PROG(GENCAT, gencat, no)dnl
251                if test "$GENCAT" != "no"; then
252                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
253                  if test "$GMSGFMT" = "no"; then
254                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
255                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
256                  fi
257                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
258                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
259                  USE_INCLUDED_LIBINTL=yes
260                  CATOBJEXT=.cat
261                  INSTOBJEXT=.cat
262                  DATADIRNAME=lib
263                  INTLDEPS='$(top_builddir)/intl/libintl.a'
264                  INTLLIBS=$INTLDEPS
265                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
266                  nls_cv_header_intl=intl/libintl.h
267                  nls_cv_header_libgt=intl/libgettext.h
268                fi])
269           fi
270         fi
272         if test "$CATOBJEXT" = "NONE"; then
273           dnl Neither gettext nor catgets in included in the C library.
274           dnl Fall back on GNU gettext library.
275           nls_cv_use_gnu_gettext=yes
276         fi
277       fi
279       if test "$nls_cv_use_gnu_gettext" = "yes"; then
280         dnl Mark actions used to generate GNU NLS library.
281         INTLOBJS="\$(GETTOBJS)"
282         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
283           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
284         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
285         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
286           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
287         AC_SUBST(MSGFMT)
288         USE_INCLUDED_LIBINTL=yes
289         CATOBJEXT=.gmo
290         INSTOBJEXT=.mo
291         DATADIRNAME=share
292         INTLDEPS='$(top_builddir)/intl/libintl.a'
293         INTLLIBS=$INTLDEPS
294         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
295         nls_cv_header_intl=intl/libintl.h
296         nls_cv_header_libgt=intl/libgettext.h
297       fi
299       dnl Test whether we really found GNU xgettext.
300       if test "$XGETTEXT" != ":"; then
301         dnl If it is no GNU xgettext we define it as : so that the
302         dnl Makefiles still can work.
303         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
304           : ;
305         else
306           AC_MSG_RESULT(
307             [found xgettext program is not GNU xgettext; ignore it])
308           XGETTEXT=":"
309         fi
310       fi
312       # We need to process the po/ directory.
313       POSUB=po
314     else
315       DATADIRNAME=share
316       nls_cv_header_intl=intl/libintl.h
317       nls_cv_header_libgt=intl/libgettext.h
318     fi
319     AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
320     AC_OUTPUT_COMMANDS(
321      [case "$CONFIG_FILES" in *po/Makefile.in*)
322         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
323       esac])
326     # If this is used in GNU gettext we have to set USE_NLS to `yes'
327     # because some of the sources are only built for this goal.
328     if test "$PACKAGE" = gettext; then
329       USE_NLS=yes
330       USE_INCLUDED_LIBINTL=yes
331     fi
333     dnl These rules are solely for the distribution goal.  While doing this
334     dnl we only have to keep exactly one list of the available catalogs
335     dnl in configure.in.
336     for lang in $ALL_LINGUAS; do
337       GMOFILES="$GMOFILES $lang.gmo"
338       POFILES="$POFILES $lang.po"
339     done
341     dnl Make all variables we use known to autoconf.
342     AC_SUBST(USE_INCLUDED_LIBINTL)
343     AC_SUBST(CATALOGS)
344     AC_SUBST(CATOBJEXT)
345     AC_SUBST(DATADIRNAME)
346     AC_SUBST(GMOFILES)
347     AC_SUBST(INSTOBJEXT)
348     AC_SUBST(INTLDEPS)
349     AC_SUBST(INTLLIBS)
350     AC_SUBST(INTLOBJS)
351     AC_SUBST(POFILES)
352     AC_SUBST(POSUB)
353   ])
355 AC_DEFUN(AM_GNU_GETTEXT,
356   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
357    AC_REQUIRE([AC_PROG_CC])dnl
358    AC_REQUIRE([AC_PROG_RANLIB])dnl
359    AC_REQUIRE([AC_ISC_POSIX])dnl
360    AC_REQUIRE([AC_HEADER_STDC])dnl
361    AC_REQUIRE([AC_C_CONST])dnl
362    AC_REQUIRE([AC_C_INLINE])dnl
363    AC_REQUIRE([AC_TYPE_OFF_T])dnl
364    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
365    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
366    AC_REQUIRE([AC_FUNC_MMAP])dnl
368    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
369 unistd.h sys/param.h])
370    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
371 strdup __argz_count __argz_stringify __argz_next])
373    if test "${ac_cv_func_stpcpy+set}" != "set"; then
374      AC_CHECK_FUNCS(stpcpy)
375    fi
376    if test "${ac_cv_func_stpcpy}" = "yes"; then
377      AC_DEFINE(HAVE_STPCPY)
378    fi
380    AM_LC_MESSAGES
381    AM_WITH_NLS
383    if test "x$CATOBJEXT" != "x"; then
384      if test "x$ALL_LINGUAS" = "x"; then
385        LINGUAS=
386      else
387        AC_MSG_CHECKING(for catalogs to be installed)
388        NEW_LINGUAS=
389        for lang in ${LINGUAS=$ALL_LINGUAS}; do
390          case "$ALL_LINGUAS" in
391           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
392          esac
393        done
394        LINGUAS=$NEW_LINGUAS
395        AC_MSG_RESULT($LINGUAS)
396      fi
398      dnl Construct list of names of catalog files to be constructed.
399      if test -n "$LINGUAS"; then
400        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
401      fi
402    fi
404    dnl The reference to <locale.h> in the installed <libintl.h> file
405    dnl must be resolved because we cannot expect the users of this
406    dnl to define HAVE_LOCALE_H.
407    if test $ac_cv_header_locale_h = yes; then
408      INCLUDE_LOCALE_H="#include <locale.h>"
409    else
410      INCLUDE_LOCALE_H="\
411 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
412    fi
413    AC_SUBST(INCLUDE_LOCALE_H)
415    dnl Determine which catalog format we have (if any is needed)
416    dnl For now we know about two different formats:
417    dnl   Linux libc-5 and the normal X/Open format
418    test -d intl || mkdir intl
419    if test "$CATOBJEXT" = ".cat"; then
420      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
422      dnl Transform the SED scripts while copying because some dumb SEDs
423      dnl cannot handle comments.
424      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
425    fi
426    dnl po2tbl.sed is always needed.
427    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
428      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
430    dnl In the intl/Makefile.in we have a special dependency which makes
431    dnl only sense for gettext.  We comment this out for non-gettext
432    dnl packages.
433    if test "$PACKAGE" = "gettext"; then
434      GT_NO="#NO#"
435      GT_YES=
436    else
437      GT_NO=
438      GT_YES="#YES#"
439    fi
440    AC_SUBST(GT_NO)
441    AC_SUBST(GT_YES)
443    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
444    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
445    dnl Try to locate is.
446    MKINSTALLDIRS=
447    if test -n "$ac_aux_dir"; then
448      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
449    fi
450    if test -z "$MKINSTALLDIRS"; then
451      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
452    fi
453    AC_SUBST(MKINSTALLDIRS)
455    dnl *** For now the libtool support in intl/Makefile is not for real.
456    l=
457    AC_SUBST(l)
459    dnl Generate list of files to be processed by xgettext which will
460    dnl be included in po/Makefile.
461    test -d po || mkdir po
462    if test "x$srcdir" != "x."; then
463      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
464        posrcprefix="$srcdir/"
465      else
466        posrcprefix="../$srcdir/"
467      fi
468    else
469      posrcprefix="../"
470    fi
471    rm -f po/POTFILES
472    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
473         < $srcdir/po/POTFILES.in > po/POTFILES
474   ])
476 # Check whether LC_MESSAGES is available in <locale.h>.
477 # Ulrich Drepper <drepper@cygnus.com>, 1995.
479 # This file can be copied and used freely without restrictions.  It can
480 # be used in projects which are not available under the GNU Public License
481 # but which still want to provide support for the GNU gettext functionality.
482 # Please note that the actual code is *not* freely available.
484 # serial 1
486 AC_DEFUN(AM_LC_MESSAGES,
487   [if test $ac_cv_header_locale_h = yes; then
488     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
489       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
490        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
491     if test $am_cv_val_LC_MESSAGES = yes; then
492       AC_DEFINE(HAVE_LC_MESSAGES)
493     fi
494   fi])
496 # Search path for a program which passes the given test.
497 # Ulrich Drepper <drepper@cygnus.com>, 1996.
499 # This file can be copied and used freely without restrictions.  It can
500 # be used in projects which are not available under the GNU Public License
501 # but which still want to provide support for the GNU gettext functionality.
502 # Please note that the actual code is *not* freely available.
504 # serial 1
506 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
507 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
508 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
509 [# Extract the first word of "$2", so it can be a program name with args.
510 set dummy $2; ac_word=[$]2
511 AC_MSG_CHECKING([for $ac_word])
512 AC_CACHE_VAL(ac_cv_path_$1,
513 [case "[$]$1" in
514   /*)
515   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
516   ;;
517   *)
518   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
519   for ac_dir in ifelse([$5], , $PATH, [$5]); do
520     test -z "$ac_dir" && ac_dir=.
521     if test -f $ac_dir/$ac_word; then
522       if [$3]; then
523         ac_cv_path_$1="$ac_dir/$ac_word"
524         break
525       fi
526     fi
527   done
528   IFS="$ac_save_ifs"
529 dnl If no 4th arg is given, leave the cache variable unset,
530 dnl so AC_PATH_PROGS will keep looking.
531 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
532 ])dnl
533   ;;
534 esac])dnl
535 $1="$ac_cv_path_$1"
536 if test -n "[$]$1"; then
537   AC_MSG_RESULT([$]$1)
538 else
539   AC_MSG_RESULT(no)
541 AC_SUBST($1)dnl