OSDN Git Service

* Makefile.am: Add dummy install-pdf target.
[pf3gnuchains/gcc-fork.git] / libmudflap / testsuite / lib / libmudflap.exp
index 04a1720..94d060b 100644 (file)
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  
 
 # Define libmudflap callbacks for dg.exp.
 # This file is a copy of libstdc++-v3's dejagnu driver, with minor changes.
 
+# Useful hook:  if ${hostname}_init exists, it will be called, almost
+# the last thing before testing begins.  This can be defined in, e.g.,
+# ~/.dejagnurc or $DEJAGNU.
+
+proc load_gcc_lib { filename } {
+    global srcdir
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+}
+
 load_lib mfdg.exp
 load_lib libgloss.exp
-
+load_gcc_lib target-libpath.exp
 
 proc libmudflap-init { language } {
-    global srcdir
-    global outdir
-    global blddir
-    global cxx
+    global env
+    global srcdir outdir blddir objdir tool_root_dir
+    global cxx cxxflags
     global includes
     global libs
-    global cxxflags
-    global objdir
     global gluefile wrap_flags
     global ld_library_path
-    global tool_root_dir
 
     switch $language {
         "c" { set cxx [find_gcc] }
@@ -64,12 +69,12 @@ proc libmudflap-init { language } {
     if {[is_remote host] == 0} {
        foreach i "[exec ${gccdir}/xgcc --print-multi-lib]" {
            set mldir ""
-           regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
+           regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
            set mldir [string trimright $mldir "\;@"]
            if { "$mldir" == "." } {
                continue
            }
-           if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] == 1 } {
+           if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
                append ld_library_path ":${gccdir}/${mldir}"
            }
        }
@@ -78,7 +83,7 @@ proc libmudflap-init { language } {
 
     set libs "-L${blddir}/.libs"
     set cxxflags "-ggdb3 -DDEBUG_ASSERT"
-    set includes "-I${srcdir} -I.."
+    set includes "-I${srcdir} -I${srcdir}/.. -I.."
 
     if {$language == "c++"} {
         if {[file exists $cxxflags_file]} then {
@@ -96,12 +101,10 @@ proc libmudflap-init { language } {
     global add_flags
     append add_flags " $mfconfig_libs"
 
-    verbose -log "ld_library_path=$ld_library_path"
-    setenv  LD_LIBRARY_PATH     $ld_library_path
-    setenv  SHLIB_PATH          $ld_library_path
-    setenv  LD_RUN_PATH         $ld_library_path
-    setenv  LD_LIBRARYN32_PATH  $ld_library_path
-    setenv  LD_LIBRARY64_PATH   $ld_library_path
+    set_ld_library_path_env_vars
+    if [info exists env(LD_LIBRARY_PATH)] {
+       verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
+    }
 
     if { [target_info needs_status_wrapper]!=""} {
       file delete ${objdir}/testglue.o;
@@ -114,6 +117,28 @@ proc libmudflap-init { language } {
           unset gluefile
       }
     }
+
+    # If there is no static library then don't run tests with -static.
+    global tool
+    set opts "additional_flags=-static"
+    lappend opts "additional_flags=-fmudflap"
+    lappend opts "additional_flags=-lmudflap"
+    set src stlm[pid].c
+    set exe stlm[pid].x
+
+    set f [open $src "w"]
+    puts $f "int main () { }"
+    close $f
+    set lines [${tool}_target_compile $src $exe executable "$opts"]
+    file delete $src
+    remote_file build delete $exe
+
+    if { ![string match "" $lines] } {
+       # Compilation failed; assume static library is not available.
+       global MUDFLAP_FLAGS
+       set i [lsearch $MUDFLAP_FLAGS "*static*"]
+       set MUDFLAP_FLAGS [lreplace $MUDFLAP_FLAGS $i $i]
+    }
 }
 
 proc libmudflap-dg-test { prog do_what extra_tool_flags } {