OSDN Git Service

PR go/50656
[pf3gnuchains/gcc-fork.git] / gcc / acinclude.m4
index 3893b45..d8defea 100644 (file)
@@ -1,3 +1,21 @@
+dnl Copyright (C) 2005, 2006, 2007, 2008, 2011 Free Software Foundation, Inc.
+dnl
+dnl This file is part of GCC.
+dnl
+dnl GCC is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3, or (at your option)
+dnl any later version.
+dnl
+dnl GCC is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with GCC; see the file COPYING3.  If not see
+dnl <http://www.gnu.org/licenses/>.
+
 dnl See whether we need a declaration for a function.
 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
@@ -295,34 +313,6 @@ if test $gcc_cv_func_mmap_anon = yes; then
 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_REQUIRE([gcc_AC_BUILD_EXEEXT])
-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'`
-changequote([,])dnl
-  echo "configure:__oline__: version of $2 is $ac_prog_version" >&AS_MESSAGE_LOG_FD
-changequote(<<,>>)dnl
-  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
-])
-
 dnl Determine if enumerated bitfields are unsigned.   ISO C says they can 
 dnl be either signed or unsigned.
 dnl
@@ -375,7 +365,7 @@ if test $gcc_cv_c_nbby = failed; then
   AC_MSG_ERROR(cannot determine number of bits in a byte)
 else
   AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
-  [Define as the number of bits in a byte, if \`limits.h' doesn't.])
+  [Define as the number of bits in a byte, if `limits.h' doesn't.])
 fi
 fi])
 
@@ -385,13 +375,120 @@ AC_DEFUN([gcc_AC_INITFINI_ARRAY],
        [], [
 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
                 gcc_cv_initfini_array, [dnl
-  AC_RUN_IFELSE([AC_LANG_SOURCE([
+  if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then
+    AC_RUN_IFELSE([AC_LANG_SOURCE([
+#ifndef __ELF__
+#error Not an ELF OS
+#endif
+#ifdef __ia64__
+/* We turn on .preinit_array/.init_array/.fini_array support for ia64
+   if it can be used.  */
 static int x = -1;
 int main (void) { return x; }
 int foo (void) { x = 0; }
-int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;])],
+int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
+#else
+extern void abort ();
+static int count;
+
+static void
+init1005 ()
+{
+  if (count != 0)
+    abort ();
+  count = 1005;
+}
+void (*const init_array1005[]) ()
+  __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *))))
+  = { init1005 };
+static void
+fini1005 ()
+{
+  if (count != 1005)
+    abort ();
+}
+void (*const fini_array1005[]) ()
+  __attribute__ ((section (".fini_array.01005"), aligned (sizeof (void *))))
+  = { fini1005 };
+
+static void
+ctor1007 ()
+{
+  if (count != 1005)
+    abort ();
+  count = 1007;
+}
+void (*const ctors1007[]) ()
+  __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *))))
+  = { ctor1007 };
+static void
+dtor1007 ()
+{
+  if (count != 1007)
+    abort ();
+  count = 1005;
+}
+void (*const dtors1007[]) ()
+  __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *))))
+  = { dtor1007 };
+
+static void
+init65530 ()
+{
+  if (count != 1007)
+    abort ();
+  count = 65530;
+}
+void (*const init_array65530[]) ()
+  __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *))))
+  = { init65530 };
+static void
+fini65530 ()
+{
+  if (count != 65530)
+    abort ();
+  count = 1007;
+}
+void (*const fini_array65530[]) ()
+  __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *))))
+  = { fini65530 };
+
+static void
+ctor65535 ()
+{
+  if (count != 65530)
+    abort ();
+  count = 65535;
+}
+void (*const ctors65535[]) ()
+  __attribute__ ((section (".ctors"), aligned (sizeof (void *))))
+  = { ctor65535 };
+static void
+dtor65535 ()
+{
+  if (count != 65535)
+    abort ();
+  count = 65530;
+}
+void (*const dtors65535[]) ()
+  __attribute__ ((section (".dtors"), aligned (sizeof (void *))))
+  = { dtor65535 };
+
+int
+main ()
+{
+  if (count != 65535)
+    abort ();
+  return 0;
+}
+#endif
+])],
             [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
-            [gcc_cv_initfini_array=no])])
+            [gcc_cv_initfini_array=no])
+   else
+     AC_MSG_CHECKING(cross compile... guessing)
+     gcc_cv_initfini_array=no
+   fi])
   enable_initfini_array=$gcc_cv_initfini_array
 ])
 if test $enable_initfini_array = yes; then
@@ -452,6 +549,26 @@ AC_DEFUN([gcc_GAS_VERSION_GTE_IFELSE],
 ifelse([$1], elf, [_gcc_GAS_VERSION_GTE_IFELSE($@)],
                   [_gcc_GAS_VERSION_GTE_IFELSE(,$@)])])
 
+dnl # gcc_GAS_FLAGS
+dnl # Used by gcc_GAS_CHECK_FEATURE 
+dnl #
+AC_DEFUN([gcc_GAS_FLAGS],
+[AC_CACHE_CHECK([assembler flags], gcc_cv_as_flags,
+[ case "$target" in
+  i[[34567]]86-*-linux*)
+    dnl Always pass --32 to ia32 Linux assembler.
+    gcc_cv_as_flags="--32"
+    ;;
+  powerpc*-*-darwin*)
+    dnl Always pass -arch ppc to assembler.
+    gcc_cv_as_flags="-arch ppc"
+    ;;
+  *)
+    gcc_cv_as_flags=" "
+    ;;
+  esac])
+])
+
 dnl gcc_GAS_CHECK_FEATURE(description, cv, [[elf,]major,minor,patchlevel],
 dnl [extra switches to as], [assembler input],
 dnl [extra testing logic], [command if feature available])
@@ -464,14 +581,15 @@ dnl if assembly succeeds.  If EXTRA TESTING LOGIC is not the empty string,
 dnl then it is run instead of simply setting CV to "yes" - it is responsible
 dnl for doing so, if appropriate.
 AC_DEFUN([gcc_GAS_CHECK_FEATURE],
-[AC_CACHE_CHECK([assembler for $1], [$2],
+[AC_REQUIRE([gcc_GAS_FLAGS])dnl
+AC_CACHE_CHECK([assembler for $1], [$2],
  [[$2]=no
   ifelse([$3],,,[dnl
   if test $in_tree_gas = yes; then
     gcc_GAS_VERSION_GTE_IFELSE($3, [[$2]=yes])
   el])if test x$gcc_cv_as != x; then
-    echo ifelse(m4_substr([$5],0,1),[$], "[$5]", '[$5]') > conftest.s
-    if AC_TRY_COMMAND([$gcc_cv_as $4 -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD])
+    AS_ECHO([ifelse(m4_substr([$5],0,1),[$], "[$5]", '[$5]')]) > conftest.s
+    if AC_TRY_COMMAND([$gcc_cv_as $gcc_cv_as_flags $4 -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD])
     then
        ifelse([$6],, [$2]=yes, [$6])
     else
@@ -506,94 +624,7 @@ m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[#ifndef USED_FOR_TARGET
 #endif
 ]))])
 
-AC_DEFUN([gcc_AC_TOOL_DIRS], [
-# When searching for the assembler or linker, search the same directories
-# that the installed compiler will search.  Else we may find the wrong
-# assembler or linker and lose.  If we do not find a suitable binary,
-# then try the user's path.
-#
-# Also note we have to check MD_EXEC_PREFIX before checking the user's path.
-if test "x$exec_prefix" = xNONE; then
-       if test "x$prefix" = xNONE; then
-               gcc_cv_tool_prefix=/usr/local
-       else
-               gcc_cv_tool_prefix=$prefix
-       fi
-else
-       gcc_cv_tool_prefix=$exec_prefix
-fi
-
-if test x$host = x$build; then
-    gcc_cv_tool_dirs="$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical/$gcc_version"
-    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical"
-    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR/usr/lib/gcc/$target_noncanonical/$gcc_version"
-    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR/usr/lib/gcc/$target_noncanonical"
-    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version"
-    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/$target_noncanonical/bin"
-else
-    gcc_cv_tool_dirs=
-fi
-
-if test x$build = x$target; then
-    # Rummage through tm_files looking for MD_EXEC_PREFIX
-    md_dirs=
-    for f in ${tm_file_list}; do
-       if test -f $f; then
-           if grep '^#[        ]*undef[        ]*MD_EXEC_PREFIX' $f > /dev/null; then
-               md_dirs=
-           fi
-           md_dirs="$md_dirs "`sed -n -e 's@^#[        ]*define[       ]*MD_EXEC_PREFIX[       ]*"\(.*\)/"@\1@p' < $f`
-       fi
-    done
-    for f in ${md_dirs}; do
-        gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$f"
-    done
-fi])
-
 dnl Make sure that build_exeext is looked for
 AC_DEFUN([gcc_AC_BUILD_EXEEXT], [
 ac_executable_extensions="$build_exeext"])
 
-AC_DEFUN([gcc_AC_CHECK_TOOL], [
-AC_REQUIRE([gcc_AC_TOOL_DIRS])
-AC_REQUIRE([gcc_AC_BUILD_EXEEXT])
-
-dnl shut up useless "checking for..." messages
-dnl we can still read them in config.log
-exec AS_MESSAGE_FD([])>/dev/null
-
-# First try the environment variables.  Handle full paths or basenames.
-if test "x[$]$1" = x && test -n "[$]$4"; then
-       AC_PATH_PROG($1, [$]$4)
-fi
-if test "x[$]$1" = x && test -n "[$]$5" && test x$host = x$target; then
-       AC_PATH_PROG($1, [$]$5)
-fi
-
-if test "x[$]$1" = x; then
-       # The AC_PATH_PROGS macro doesn't work properly when its 4th argument
-       # is empty.
-       if test "x$gcc_cv_tool_dirs" = x; then
-               $1=
-       else
-               AC_PATH_PROGS($1, $2, , $gcc_cv_tool_dirs)
-       fi
-fi
-if test "x[$]$1" = x; then
-       # If the loop above did not find a tool, then use whatever
-       # one we can find in the users's path.  We are looking for a
-       # ${build} -> ${target} tool.
-       if test "x$program_prefix" != xNONE; then
-               default_tool_name=${program_prefix}$2
-       elif test x$build != x$host && test x$build != x$target; then
-               default_tool_name=${target_noncanonical}-$2
-       else
-               default_tool_name=`echo $2 | sed "${program_transform_name}"`
-       fi
-       AC_PATH_PROGS($1, $default_tool_name,
-               $gcc_cv_tool_prefix/bin/$default_tool_name$build_exeext)
-fi
-test "$silent" != yes && exec AS_MESSAGE_FD([])>&1
-
-$3="[$]$1"
-AC_SUBST($3)])