OSDN Git Service

ch:
[pf3gnuchains/gcc-fork.git] / gcc / aclocal.m4
index 5439383..92748f3 100644 (file)
@@ -1,69 +1,61 @@
 dnl See whether we can include both string.h and strings.h.
-AC_DEFUN(GCC_HEADER_STRING,
+AC_DEFUN(gcc_AC_HEADER_STRING,
 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
   gcc_cv_header_string,
 [AC_TRY_COMPILE([#include <string.h>
 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
 if test $gcc_cv_header_string = yes; then
-  AC_DEFINE(STRING_WITH_STRINGS)
+  AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
 fi
 ])
 
 dnl See whether we need a declaration for a function.
-dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
-AC_DEFUN(GCC_NEED_DECLARATION,
-[AC_MSG_CHECKING([whether $1 must be declared])
-AC_CACHE_VAL(gcc_cv_decl_needed_$1,
-[AC_TRY_COMPILE([
-#include <stdio.h>
-#ifdef STRING_WITH_STRINGS
-# include <string.h>
-# include <strings.h>
-#else
-# ifdef HAVE_STRING_H
-#  include <string.h>
-# else
-#  ifdef HAVE_STRINGS_H
-#   include <strings.h>
-#  endif
-# endif
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifndef HAVE_RINDEX
-#define rindex strrchr
-#endif
-#ifndef HAVE_INDEX
-#define index strchr
-#endif
-$2],
-[char *(*pfn) = (char *(*)) $1],
-eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
-if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
-  AC_MSG_RESULT(yes)
-  gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
-  AC_DEFINE_UNQUOTED($gcc_tr_decl)
+dnl The result is highly dependent on the INCLUDES passed in, so make sure
+dnl to use a different cache variable name in this macro if it is invoked
+dnl in a different context somewhere else.
+dnl gcc_AC_CHECK_DECL(SYMBOL,
+dnl    [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
+AC_DEFUN(gcc_AC_CHECK_DECL,
+[AC_MSG_CHECKING([whether $1 is declared])
+AC_CACHE_VAL(gcc_cv_have_decl_$1,
+[AC_TRY_COMPILE([$4],
+[#ifndef $1
+char *(*pfn) = (char *(*)) $1 ;
+#endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
+if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
+  AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
 else
-  AC_MSG_RESULT(no)
+  AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
 fi
 ])dnl
 
 dnl Check multiple functions to see whether each needs a declaration.
-dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
-AC_DEFUN(GCC_NEED_DECLARATIONS,
+dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
+dnl gcc_AC_CHECK_DECLS(SYMBOLS,
+dnl    [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
+AC_DEFUN(gcc_AC_CHECK_DECLS,
 [for ac_func in $1
 do
-GCC_NEED_DECLARATION($ac_func, $2)
+changequote(, )dnl
+  ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+changequote([, ])dnl
+gcc_AC_CHECK_DECL($ac_func,
+  [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
+  [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
+  $4
+)
 done
+dnl Automatically generate config.h entries via autoheader.
+if test x = y ; then
+  patsubst(translit([$1], [a-z], [A-Z]), [\w+],
+    AC_DEFINE([HAVE_DECL_\&], 1,
+      [Define to 1 if we found this declaration otherwise define to 0.]))dnl
+fi
 ])
 
 dnl Check if we have vprintf and possibly _doprnt.
 dnl Note autoconf checks for vprintf even though we care about vfprintf.
-AC_DEFUN(GCC_FUNC_VFPRINTF_DOPRNT,
+AC_DEFUN(gcc_AC_FUNC_VFPRINTF_DOPRNT,
 [AC_FUNC_VPRINTF
 vfprintf=
 doprint=
@@ -78,28 +70,28 @@ AC_SUBST(doprint)
 ])    
 
 dnl See if the printf functions in libc support %p in format strings.
-AC_DEFUN(GCC_FUNC_PRINTF_PTR,
+AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
 [AC_CACHE_CHECK(whether the printf functions support %p,
   gcc_cv_func_printf_ptr,
 [AC_TRY_RUN([#include <stdio.h>
 
-main()
+int main()
 {
   char buf[64];
   char *p = buf, *q = NULL;
   sprintf(buf, "%p", p);
   sscanf(buf, "%p", &q);
-  exit (p != q);
+  return (p != q);
 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
        gcc_cv_func_printf_ptr=no)
 rm -f core core.* *.core])
 if test $gcc_cv_func_printf_ptr = yes ; then
-  AC_DEFINE(HAVE_PRINTF_PTR)
+  AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
 fi
 ])
 
 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
-AC_DEFUN(GCC_PROG_LN_S,
+AC_DEFUN(gcc_AC_PROG_LN_S,
 [AC_MSG_CHECKING(whether ln -s works)
 AC_CACHE_VAL(gcc_cv_prog_LN_S,
 [rm -f conftestdata_t
@@ -131,7 +123,7 @@ AC_SUBST(LN_S)dnl
 ])
 
 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
-AC_DEFUN(GCC_PROG_LN,
+AC_DEFUN(gcc_AC_PROG_LN,
 [AC_MSG_CHECKING(whether ln works)
 AC_CACHE_VAL(gcc_cv_prog_LN,
 [rm -f conftestdata_t
@@ -163,18 +155,18 @@ AC_SUBST(LN)dnl
 ])
 
 dnl See whether the stage1 host compiler accepts the volatile keyword.
-AC_DEFUN(GCC_C_VOLATILE,
+AC_DEFUN(gcc_AC_C_VOLATILE,
 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
 [AC_TRY_COMPILE(, [volatile int foo;],
         gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
 if test $gcc_cv_c_volatile = yes ; then
-  AC_DEFINE(HAVE_VOLATILE)
+  AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.])
 fi
 ])
 
 dnl Check whether long double is supported.  This differs from the
 dnl built-in autoconf test in that it works for cross compiles.
-AC_DEFUN(AC_GCC_C_LONG_DOUBLE,
+AC_DEFUN(gcc_AC_C_LONG_DOUBLE,
 [AC_CACHE_CHECK(for long double, gcc_cv_c_long_double,
 [if test "$GCC" = yes; then
   gcc_cv_c_long_double=yes
@@ -193,7 +185,7 @@ fi
 
 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
 dnl of the usual 2.
-AC_DEFUN(GCC_FUNC_MKDIR_TAKES_ONE_ARG,
+AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
 [AC_TRY_COMPILE([
 #include <sys/types.h>
@@ -208,11 +200,11 @@ AC_DEFUN(GCC_FUNC_MKDIR_TAKES_ONE_ARG,
 #endif], [mkdir ("foo", 0);], 
         gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
-  AC_DEFINE(MKDIR_TAKES_ONE_ARG)
+  AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
 fi
 ])
 
-AC_DEFUN(EGCS_PROG_INSTALL,
+AC_DEFUN(gcc_AC_PROG_INSTALL,
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
@@ -388,7 +380,11 @@ AC_DEFUN(AM_WITH_NLS,
                 AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
                 if test "$GMSGFMT" = "no"; then
                   AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
-                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
+                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
+                  if test "$GMSGFMT" = "msgfmt"; then
+                    AC_MSG_WARN(No program for catalog building found, so disabling building them)
+                    create_catalogs="no"
+                  fi
                 fi
                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
@@ -418,6 +414,12 @@ AC_DEFUN(AM_WITH_NLS,
         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
          [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+        dnl If we didn't find either msgfmt or gmsgfmt, don't try to
+        dnl create a catalog.
+       if test "$MSGFMT" = "msgfmt" && test "$GMSGFMT" = "msgfmt"; then
+         AC_MSG_WARN(Neither msgfmt nor gmsgfmt found. No catalogs will be built)
+         create_catalogs="no"
+       fi
         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
          [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
         AC_SUBST(MSGFMT)
@@ -445,6 +447,8 @@ AC_DEFUN(AM_WITH_NLS,
        fi
       fi
 
+
+
       # We need to process the po/ directory.
       POSUB=po
     else
@@ -499,7 +503,6 @@ AC_DEFUN(AM_GNU_GETTEXT,
    AC_REQUIRE([AC_TYPE_OFF_T])dnl
    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
-   AC_REQUIRE([AC_FUNC_MMAP])dnl
 
    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
 unistd.h sys/param.h])
@@ -516,18 +519,22 @@ strdup __argz_count __argz_stringify __argz_next])
    AM_LC_MESSAGES
    AM_WITH_NLS
 
-   if test "x$CATOBJEXT" != "x"; then
+   if test "x$CATOBJEXT" != "x" && test "x$create_catalogs" != "xno" ; then
      if test "x$ALL_LINGUAS" = "x"; then
        LINGUAS=
      else
        AC_MSG_CHECKING(for catalogs to be installed)
-       NEW_LINGUAS=
-       for lang in ${LINGUAS=$ALL_LINGUAS}; do
-         case "$ALL_LINGUAS" in
-          *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
-         esac
-       done
-       LINGUAS=$NEW_LINGUAS
+       if test "x$LINGUAS" = "x"; then
+        LINGUAS=$ALL_LINGUAS
+       else
+        NEW_LINGUAS=
+        for lang in $ALL_LINGUAS; do
+          case " $LINGUAS " in
+            *" $lang "*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
+          esac
+        done
+         LINGUAS=$NEW_LINGUAS
+       fi
        AC_MSG_RESULT($LINGUAS)
      fi
 
@@ -676,3 +683,174 @@ else
 fi
 AC_SUBST($1)dnl
 ])
+
+# Check whether mmap can map an arbitrary page from /dev/zero or with
+# MAP_ANONYMOUS, without MAP_FIXED.
+AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
+[AC_CHECK_HEADERS(unistd.h)
+AC_CHECK_FUNCS(getpagesize)
+AC_CACHE_CHECK(for working mmap which provides zeroed pages anywhere,
+  ac_cv_func_mmap_anywhere,
+[AC_TRY_RUN([
+/* Test by Richard Henderson and Alexandre Oliva.
+   Check whether mmap MAP_ANONYMOUS or mmap from /dev/zero works. */
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
+# define MAP_ANONYMOUS MAP_ANON
+#endif
+
+/* This mess was copied from the GNU getpagesize.h.  */
+#ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+# endif
+
+/* Assume that all systems that can run configure have sys/param.h.  */
+# ifndef HAVE_SYS_PARAM_H
+#  define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+#  define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+#  ifdef HAVE_SYS_PARAM_H
+#   include <sys/param.h>
+#   ifdef EXEC_PAGESIZE
+#    define getpagesize() EXEC_PAGESIZE
+#   else /* no EXEC_PAGESIZE */
+#    ifdef NBPG
+#     define getpagesize() NBPG * CLSIZE
+#     ifndef CLSIZE
+#      define CLSIZE 1
+#     endif /* no CLSIZE */
+#    else /* no NBPG */
+#     ifdef NBPC
+#      define getpagesize() NBPC
+#     else /* no NBPC */
+#      ifdef PAGESIZE
+#       define getpagesize() PAGESIZE
+#      endif /* PAGESIZE */
+#     endif /* no NBPC */
+#    endif /* no NBPG */
+#   endif /* no EXEC_PAGESIZE */
+#  else /* no HAVE_SYS_PARAM_H */
+#   define getpagesize() 8192  /* punt totally */
+#  endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+int main()
+{
+  char *x;
+  int fd, pg;
+
+#ifndef MAP_ANONYMOUS
+  fd = open("/dev/zero", O_RDWR);
+  if (fd < 0)
+    exit(1);
+#endif
+
+  pg = getpagesize();
+#ifdef MAP_ANONYMOUS
+  x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE,
+                  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+#else
+  x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+#endif
+  if (x == (char *) -1)
+    exit(2);
+
+  *(int *)x += 1;
+
+  if (munmap(x, pg) < 0)
+    exit(3);
+
+  exit(0);
+}], ac_cv_func_mmap_anywhere=yes, ac_cv_func_mmap_anywhere=no,
+ac_cv_func_mmap_anywhere=no)])
+if test $ac_cv_func_mmap_anywhere = yes; then
+  AC_DEFINE(HAVE_MMAP_ANYWHERE, 1,
+           [Define if mmap can get us zeroed pages without MAP_FIXED.])
+fi
+])
+
+# Check whether mmap can map a plain file, without MAP_FIXED.
+AC_DEFUN([AC_FUNC_MMAP_FILE], 
+[AC_REQUIRE([AC_FUNC_MMAP_ANYWHERE])dnl
+AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file,
+[# Create a file one thousand bytes long.
+for i in 1 2 3 4 5 6 7 8 9 0
+do for j in 1 2 3 4 5 6 7 8 9 0
+do echo $i $j xxxxx
+done
+done > conftestdata$$
+
+AC_TRY_RUN([
+/* Test by Zack Weinberg.  Modified from MMAP_ANYWHERE test by
+   Richard Henderson and Alexandre Oliva.
+   Check whether read-only mmap of a plain file works. */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+int main()
+{
+  char *x;
+  int fd;
+  struct stat st;
+
+  fd = open("conftestdata$$", O_RDONLY);
+  if (fd < 0)
+    exit(1);
+
+  if (fstat (fd, &st))
+    exit(2);
+
+  x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+  if (x == (char *) -1)
+    exit(3);
+
+  if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
+    exit(4);
+
+  if (munmap(x, st.st_size) < 0)
+    exit(5);
+
+  exit(0);
+}], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
+ac_cv_func_mmap_file=no)])
+if test $ac_cv_func_mmap_file = yes; then
+  AC_DEFINE(HAVE_MMAP_FILE, 1,
+           [Define if read-only mmap of a plain file works.])
+fi
+])
+
+dnl Locate a program and check that its version is acceptable.
+dnl AC_PROG_CHECK_VER(var, name, version-switch,
+dnl                  version-extract-regexp, version-glob)
+AC_DEFUN(gcc_AC_CHECK_PROG_VER,
+[AC_CHECK_PROG([$1], [$2], [$2])
+if test -n "[$]$1"; then
+  # Found it, now check the version.
+  AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
+[changequote(<<,>>)dnl
+  ac_prog_version=`<<$>>$1 $3 2>&1 |
+                   sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
+  echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
+  case $ac_prog_version in
+    '')     gcc_cv_prog_$2_modern=no;;
+    <<$5>>)
+            gcc_cv_prog_$2_modern=yes;;
+    *)      gcc_cv_prog_$2_modern=no;;
+  esac
+changequote([,])dnl
+])
+else
+  gcc_cv_prog_$2_modern=no
+fi
+])