OSDN Git Service

PR testsuite/28870
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / objc.exp
index c3de61e..1705979 100644 (file)
@@ -1,19 +1,19 @@
-# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001
-# Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004, 2005,
+# 2007 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
 
 # This file was written by Rob Savoye (rob@cygnus.com)
 # Currently maintained by Doug Evans (dje@cygnus.com)
 # They are also used by the various testsuites to define the environment:
 # where to find stdio.h, libc.a, etc.
 
+load_lib libgloss.exp
+load_lib prune.exp
+load_lib gcc-defs.exp
+load_lib timeout.exp
+load_lib target-libpath.exp
+
 #
 # OBJC_UNDER_TEST is the compiler under test.
 #
 proc default_objc_version { } {
     global OBJC_UNDER_TEST
 
-    objc_init;
+    objc_init
 
     # ignore any arguments after the command
     set compiler [lindex $OBJC_UNDER_TEST 0]
 
     if ![is_remote host] {
-       set compiler_name [which $compiler];
+       set compiler_name [which $compiler]
     } else {
-       set compiler_name $compiler;
+       set compiler_name $compiler
     }
 
     # verify that the compiler exists
     if { $compiler_name != 0 } then {
        set tmp [remote_exec host "$compiler -v"]
-       set status [lindex $tmp 0];
-       set output [lindex $tmp 1];
-       regexp "version.*$" $output version
+       set status [lindex $tmp 0]
+       set output [lindex $tmp 1]
+       regexp " version \[^\n\r\]*" $output version
        if { $status == 0 && [info exists version] } then {
            clone_output "$compiler_name $version\n"
        } else {
@@ -68,7 +74,7 @@ proc default_objc_version { } {
 # Call objc_version. We do it this way so we can override it if needed.
 #
 proc objc_version { } {
-    default_objc_version;
+    default_objc_version
 }
 
 #
@@ -81,18 +87,24 @@ proc objc_version { } {
 set objc_initialized 0
 
 proc objc_init { args } {
+    global rootme
     global tmpdir
     global libdir
     global gluefile wrap_flags
     global objc_initialized
     global OBJC_UNDER_TEST
     global TOOL_EXECUTABLE
+    global objc_libgcc_s_path
+
+    # We set LC_ALL and LANG to C so that we get the same error messages as expected.
+    setenv LC_ALL C
+    setenv LANG C
 
     if { $objc_initialized == 1 } { return; }
 
     if ![info exists OBJC_UNDER_TEST] then {
        if [info exists TOOL_EXECUTABLE] {
-           set OBJC_UNDER_TEST $TOOL_EXECUTABLE;
+           set OBJC_UNDER_TEST $TOOL_EXECUTABLE
        } else {
            set OBJC_UNDER_TEST [find_gcc]
        }
@@ -101,28 +113,27 @@ proc objc_init { args } {
     if ![info exists tmpdir] then {
        set tmpdir /tmp
     }
-    if { [target_info needs_status_wrapper]!="" && ![info exists gluefile] } {
-       set gluefile ${tmpdir}/testglue.o;
-       set result [build_wrapper $gluefile];
-       if { $result != "" } {
-           set gluefile [lindex $result 0];
-           set wrap_flags [lindex $result 1];
-       } else {
-           unset gluefile
-       }
-    }
+
+    objc_maybe_build_wrapper "${tmpdir}/objc-testglue.o"
+
+    set objc_libgcc_s_path [gcc-set-multilib-library-path $OBJC_UNDER_TEST]
 }
 
 proc objc_target_compile { source dest type options } {
-    global rootme;
-    global tmpdir;
-    global gluefile wrap_flags;
+    global rootme
+    global tmpdir
+    global gluefile wrap_flags
+    global srcdir
     global OBJC_UNDER_TEST
     global TOOL_OPTIONS
     global ld_library_path
+    global objc_libgcc_s_path
+    global shlib_ext
 
-    set ld_library_path ".:${rootme}"
+    set ld_library_path ".:${objc_libgcc_s_path}"
     lappend options "libs=-lobjc"
+    set shlib_ext [get_shlib_extension]
+    verbose "shared lib extension: $shlib_ext"
 
     if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
        lappend options "libs=${gluefile}"
@@ -138,21 +149,55 @@ proc objc_target_compile { source dest type options } {
     if [target_info exists objc,no_label_values] {
        lappend options "additional_flags=-DNO_LABEL_VALUES"
     }
+    # TOOL_OPTIONS must come first, so that it doesn't override testcase
+    # specific options.
     if [info exists TOOL_OPTIONS] {
-       lappend options "additional_flags=$TOOL_OPTIONS"
-    }
-    if [target_info exists objc,no_varargs] {
-       lappend options "additional_flags=-DNO_VARARGS"
+       set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
     }
+
+    # If we have built libobjc along with the compiler (which usually
+    # _is not_ the case on Mac OS X systems), point the test harness
+    # at it (and associated headers).
+
     set objcpath "[get_multilibs]"
+
     set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
+    if { $libobjc_dir == ""} {
+      verbose "see if we have -fgnu-runtime in options"
+      if [regexp ".*-fgnu-runtime.*" "${options}"] {
+       set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
+      }
+    }
+    # Now check if we have a shared only build.
+    if { $libobjc_dir == ""} {
+     set libobjc_dir \
+        [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
+    }
+    if { $libobjc_dir == ""} {
+       verbose "see if we have -fgnu-runtime in options"
+       if [regexp ".*-fgnu-runtime.*" "${options}"] {
+        set libobjc_dir \
+            [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
+       }
+    }
     if { $libobjc_dir != "" } {
+       set objc_include_dir "${srcdir}/../../libobjc"
+       lappend options "additional_flags=-I${objc_include_dir}"
        set libobjc_dir [file dirname ${libobjc_dir}]
        set objc_link_flags "-L${libobjc_dir}"
        lappend options "additional_flags=${objc_link_flags}"
        append ld_library_path ":${libobjc_dir}"
     }
+    if { $type == "precompiled_header" } {
+       # If we generating a precompiled header, we have say this is an
+       # objective-C header
+       set source [concat "-x objective-c-header" $source]
+    }
     lappend options "compiler=$OBJC_UNDER_TEST"
+    lappend options "timeout=[timeout_value]"
+
+    set_ld_library_path_env_vars
+
     return [target_compile $source $dest $type $options]
 }
 
@@ -190,7 +235,7 @@ proc objc_fail { testcase cflags } {
 
 proc objc_finish { } {
     # The testing harness apparently requires this.
-    global errorInfo;
+    global errorInfo
 
     if [info exists errorInfo] then {
        unset errorInfo
@@ -204,11 +249,11 @@ proc objc_finish { } {
 }
 
 proc objc_exit { } {
-    global gluefile;
+    global gluefile
 
     if [info exists gluefile] {
-       file_on_build delete $gluefile;
-       unset gluefile;
+       file_on_build delete $gluefile
+       unset gluefile
     }
 }
     
@@ -237,20 +282,6 @@ if { [info procs prune_warnings] == "" } then {
     }
 }
 
-# On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
-# called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
-# (for the 64-bit ABI).  The right way to do this would be to modify
-# unix.exp -- but that's not an option since it's part of DejaGNU
-# proper, so we do it here, by trickery.  We really only need to do 
-# this on IRIX, but it shouldn't hurt to do it anywhere else.
-
-proc ${tool}_set_ld_library_path { name element op } {
-  setenv LD_LIBRARYN32_PATH [getenv LD_LIBRARY_PATH]
-  setenv LD_LIBRARY64_PATH [getenv LD_LIBRARY_PATH]
-}
-
-trace variable env(LD_LIBRARY_PATH) w ${tool}_set_ld_library_path
-
 # Utility used by mike-gcc.exp and c-torture.exp.
 # Check the compiler(/assembler/linker) output for text indicating that
 # the testcase should be marked as "unsupported".