OSDN Git Service

2003-02-12 Phil Edwards <pme@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / aclocal.m4
index 2fd6095..6e5fa4a 100644 (file)
@@ -1,3 +1,5 @@
+sinclude(../config/accross.m4)
+
 dnl See if stdbool.h properly defines bool and true/false.
 AC_DEFUN(gcc_AC_HEADER_STDBOOL,
 [AC_CACHE_CHECK([for working stdbool.h],
@@ -306,10 +308,7 @@ procedure conftest is begin null; end conftest;
 EOF
 gcc_cv_prog_adac=no
 # Have to do ac_tool_prefix and user overrides by hand.
-user_adac=$ADAC
-user_cc=$CC
-for cand in ${ac_tool_prefix}$user_adac        $user_adac      \
-           ${ac_tool_prefix}$user_cc   $user_cc        \
+for cand in ${ADAC+"$ADAC"} ${CC+"$CC"}        \
            ${ac_tool_prefix}gcc        gcc             \
            ${ac_tool_prefix}cc         cc              \
            ${ac_tool_prefix}gnatgcc    gnatgcc         \
@@ -660,14 +659,13 @@ AC_CACHE_CHECK(for working mmap from /dev/zero,
  then ac_cv_func_mmap_dev_zero=no
  else ac_cv_func_mmap_dev_zero=buggy
  fi],
- # If this is not cygwin, and /dev/zero is a character device, it's probably
- # safe to assume it works.
+ # When cross-building, assume that this works, unless we know it
+ # doesn't.  Of course, we have no way of knowing if there even is a /dev/zero
+ # on the host, let alone whether mmap will work on it.
  [case "$host_os" in
    cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;;
-   * ) if test -c /dev/zero
-       then ac_cv_func_mmap_dev_zero=yes
-       else ac_cv_func_mmap_dev_zero=no
-       fi ;;
+   darwin* ) ac_cv_func_mmap_dev_zero=no ;;
+   * ) ac_cv_func_mmap_dev_zero=yes ;;
   esac])
 ])
 if test $ac_cv_func_mmap_dev_zero = yes; then
@@ -687,7 +685,10 @@ AC_CACHE_CHECK([for working mmap with MAP_ANON(YMOUS)],
  fi],
  # Unlike /dev/zero, it is not safe to assume MAP_ANON(YMOUS) works
  # just because it's there. Some SCO Un*xen define it but don't implement it.
- ac_cv_func_mmap_anon=no)
+ [case "$host_os" in
+   darwin* ) ac_cv_func_mmap_anon=yes ;;
+   * ) ac_cv_func_mmap_anon=no ;;
+  esac])
 ])
 if test $ac_cv_func_mmap_anon = yes; then
   AC_DEFINE(HAVE_MMAP_ANON, 1,
@@ -740,7 +741,10 @@ int main()
 
   exit(0);
 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
-ac_cv_func_mmap_file=no)])
+ [case "$host_os" in
+   darwin* ) ac_cv_func_mmap_file=yes ;;
+   * ) ac_cv_func_mmap_file=no ;;
+  esac])])
 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.])
@@ -794,35 +798,6 @@ if test $gcc_cv_enum_bf_unsigned = yes; then
     [Define if enumerated bitfields are treated as unsigned values.])
 fi])
 
-dnl Host type sizes probe.
-dnl By Kaveh R. Ghazi.  One typo fixed since.
-dnl
-AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF],
-[changequote(<<, >>)dnl
-dnl The name to #define.
-define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
-dnl The cache variable name.
-define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
-changequote([, ])dnl
-AC_MSG_CHECKING(size of $1)
-AC_CACHE_VAL(AC_CV_NAME,
-[for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
-  AC_TRY_COMPILE([#include "confdefs.h"
-#include <sys/types.h>
-$2
-], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
-  if test x$AC_CV_NAME != x ; then break; fi
-done
-])
-if test x$AC_CV_NAME = x ; then
-  AC_MSG_ERROR([cannot determine a size for $1])
-fi
-AC_MSG_RESULT($AC_CV_NAME)
-AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
-undefine([AC_TYPE_NAME])dnl
-undefine([AC_CV_NAME])dnl
-])
-
 dnl Probe number of bits in a byte.
 dnl Note C89 requires CHAR_BIT >= 8.
 dnl
@@ -953,49 +928,6 @@ fi
 rm -rf conftest*
 AC_LANG_RESTORE])
 
-dnl Host endianness probe.
-dnl This tests byte-within-word endianness.  GCC actually needs
-dnl to know word-within-larger-object endianness.  They are the
-dnl same on all presently supported hosts.
-dnl Differs from AC_C_BIGENDIAN in that it does not require
-dnl running a program on the host, and it defines the macro we
-dnl want to see.
-dnl
-AC_DEFUN([gcc_AC_C_COMPILE_ENDIAN],
-[AC_CACHE_CHECK(byte ordering, ac_cv_c_compile_endian,
-[ac_cv_c_compile_endian=unknown
-gcc_AC_EXAMINE_OBJECT([
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
-#endif
-/* This structure must have no internal padding.  */
-  struct {
-    char prefix[sizeof "\nendian:" - 1];
-    short word;
-    char postfix[2];
- } tester = {
-    "\nendian:",
-#if SIZEOF_SHORT == 4
-    ('A' << (CHAR_BIT * 3)) | ('B' << (CHAR_BIT * 2)) |
-#endif
-    ('A' << CHAR_BIT) | 'B',
-    'X', '\n'
-};],
- [if   grep 'endian:AB' conftest.dmp >/dev/null 2>&1; then
-    ac_cv_c_compile_endian=big-endian
-  elif grep 'endian:BA' conftest.dmp >/dev/null 2>&1; then
-    ac_cv_c_compile_endian=little-endian
-  fi])
-])
-if test $ac_cv_c_compile_endian = unknown; then
-  AC_MSG_ERROR([*** unable to determine endianness])
-elif test $ac_cv_c_compile_endian = big-endian; then
-  AC_DEFINE(HOST_WORDS_BIG_ENDIAN, 1,
-  [Define if the host machine stores words of multi-word integers in
-   big-endian order.])
-fi
-])
-
 dnl Floating point format probe.
 dnl The basic concept is the same as the above: grep the object
 dnl file for an interesting string.  We have to watch out for
@@ -1058,12 +990,12 @@ format=
 fbigend=
 case $ac_cv_c_float_format in
     'IEEE (big-endian)' )
-       if test $ac_cv_c_compile_endian = little-endian; then
+       if test $ac_cv_c_bigendian = no; then
            fbigend=1
        fi
        ;;
     'IEEE (little-endian)' )
-       if test $ac_cv_c_compile_endian = big-endian; then
+       if test $ac_cv_c_bigendian = yes; then
            fbigend=0
        fi
        ;;
@@ -1101,11 +1033,12 @@ AC_DEFUN([AM_ICONV],
   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
   dnl those with the standalone portable GNU libiconv installed).
 
+  am_cv_lib_iconv_ldpath=
   AC_ARG_WITH([libiconv-prefix],
 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
     for dir in `echo "$withval" | tr : ' '`; do
       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
-      if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
+      if test -d $dir/lib; then am_cv_lib_iconv_ldpath="-L$dir/lib"; fi
     done
    ])
 
@@ -1120,7 +1053,7 @@ AC_DEFUN([AM_ICONV],
       am_cv_func_iconv=yes)
     if test "$am_cv_func_iconv" != yes; then
       am_save_LIBS="$LIBS"
-      LIBS="$LIBS -liconv"
+      LIBS="$LIBS $am_cv_libiconv_ldpath -liconv"
       AC_TRY_LINK([#include <stdlib.h>
 #include <iconv.h>],
         [iconv_t cd = iconv_open("","");
@@ -1157,7 +1090,7 @@ size_t iconv();
   fi
   LIBICONV=
   if test "$am_cv_lib_iconv" = yes; then
-    LIBICONV="-liconv"
+    LIBICONV="$am_cv_lib_iconv_ldpath -liconv"
   fi
   AC_SUBST(LIBICONV)
 ])
@@ -1689,3 +1622,23 @@ strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
    INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
   ])
+
+AC_DEFUN(gcc_AC_INITFINI_ARRAY,
+[AC_ARG_ENABLE(initfini-array,
+       [  --enable-initfini-array      use .init_array/.fini_array sections],
+       [], [
+AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
+                gcc_cv_initfini_array, [dnl
+  AC_TRY_RUN([
+static int x = -1;
+int main (void) { return x; }
+int foo (void) { x = 0; }
+int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;],
+            [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
+            [gcc_cv_initfini_array=no])])
+  enable_initfini_array=$gcc_cv_initfini_array
+])
+if test $enable_initfini_array = yes; then
+  AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
+    [Define .init_array/.fini_array sections are available and working.])
+fi])