OSDN Git Service

2005-11-11 Andreas Tobler <a.tobler@schweiz.ch>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / objc.exp
index 5041b70..18cdfea 100644 (file)
@@ -1,19 +1,19 @@
-# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004
+# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004, 2005
 # 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
 # (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.
+# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
 # This file was written by Rob Savoye (rob@cygnus.com)
 # Currently maintained by Doug Evans (dje@cygnus.com)
@@ -41,22 +41,22 @@ load_lib target-libpath.exp
 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];
+       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"
@@ -73,7 +73,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
 }
 
 #
@@ -103,7 +103,7 @@ proc objc_init { args } {
 
     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]
        }
@@ -115,35 +115,24 @@ proc objc_init { args } {
 
     objc_maybe_build_wrapper "${tmpdir}/objc-testglue.o"
 
-    set objc_libgcc_s_path "${rootme}"
-    set compiler [lindex $OBJC_UNDER_TEST 0]
-    if { [is_remote host] == 0 && [which $compiler] != 0 } {
-       foreach i "[exec $compiler --print-multi-lib]" {
-           set mldir ""
-           regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
-           set mldir [string trimright $mldir "\;@"]
-           if { "$mldir" == "." } {
-               continue
-           }
-           if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] >= 1 } {
-               append objc_libgcc_s_path ":${rootme}/${mldir}"
-           }
-       }
-    }
+    append 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 ".:${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}"
@@ -162,7 +151,7 @@ proc objc_target_compile { source dest type options } {
     # TOOL_OPTIONS must come first, so that it doesn't override testcase
     # specific options.
     if [info exists TOOL_OPTIONS] {
-       set options [concat "{additional_flags=$TOOL_OPTIONS}" $options];
+       set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
     }
 
     # If we have built libobjc along with the compiler (which usually
@@ -173,11 +162,23 @@ proc objc_target_compile { source dest type options } {
 
     set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
     if { $libobjc_dir == ""} {
-      verbose "see if we have -fgnu-runtime in [target_info name]"
-      if [regexp ".*-fgnu-runtime.*" [target_info name]] {
-        set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
+      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}"
@@ -227,7 +228,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
@@ -241,11 +242,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
     }
 }