]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/lib/future.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / future.exp
index c95860def502fc732a21163fb00818ca94aca002..9855fdc21d6ce22d91ad74071c036b5b6bf3439e 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2004, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright 2004-2013 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
@@ -60,6 +60,30 @@ proc gdb_find_gfortran {} {
     return $CC
 }
 
+proc gdb_find_go {} {
+    global tool_root_dir
+
+    set GO ""
+
+    if {![is_remote host]} {
+       set file [lookfor_file $tool_root_dir gccgo]
+       if { $file != "" } {
+           set root [file dirname $file]
+           set GO "$file -B$root/gcc/"
+       }
+    }
+
+    if { $GO == "" } {
+       set GO [transform gccgo]
+    }
+
+    return $GO
+}
+
+proc gdb_find_go_linker {} {
+    return [find_go]
+}
+
 proc gdb_default_target_compile {source destfile type options} {
     global target_triplet
     global tool_root_dir
@@ -74,6 +98,11 @@ proc gdb_default_target_compile {source destfile type options} {
     set libs ""
     set compiler_type "c"
     set compiler ""
+    set linker ""
+    # linker_opts_order is one of "sources-then-flags", "flags-then-sources".
+    # The order shouldn't matter.  It's done this way to preserve
+    # existing behavior.
+    set linker_opts_order "sources-then-flags"
     set ldflags ""
     set dest [target_info name]
 
@@ -138,6 +167,26 @@ proc gdb_default_target_compile {source destfile type options} {
            }
        }
 
+       if { $i == "go" } {
+           set compiler_type "go"
+           if {[board_info $dest exists goflags]} {
+               append add_flags " [target_info goflags]"
+           }
+           if {[board_info $dest exists gocompiler]} {
+               set compiler [target_info gocompiler]
+           } else {
+               set compiler [find_go]
+           }
+           if {[board_info $dest exists golinker]} {
+               set linker [target_info golinker]
+           } else {
+               set linker [find_go_linker]
+           }
+           if {[board_info $dest exists golinker_opts_order]} {
+               set linker_opts_order [target_info golinker_opts_order]
+           }
+       }
+
        if {[regexp "^dest=" $i]} {
            regsub "^dest=" $i "" tmp
            if {[board_info $tmp exists name]} {
@@ -193,6 +242,8 @@ proc gdb_default_target_compile {source destfile type options} {
     global F77_FOR_TARGET
     global F90_FOR_TARGET
     global GNATMAKE_FOR_TARGET
+    global GO_FOR_TARGET
+    global GO_LD_FOR_TARGET
 
     if {[info exists GNATMAKE_FOR_TARGET]} {
        if { $compiler_type == "ada" } {
@@ -224,6 +275,19 @@ proc gdb_default_target_compile {source destfile type options} {
        }
     }
 
+    if { $compiler_type == "go" } {
+       if {[info exists GO_FOR_TARGET]} {
+           set compiler $GO_FOR_TARGET
+       }
+       if {[info exists GO_LD_FOR_TARGET]} {
+           set linker $GO_LD_FOR_TARGET
+       }
+    }
+
+    if { $type == "executable" && $linker != "" } {
+       set compiler $linker
+    }
+
     if { $compiler == "" } {
        set compiler [board_info $dest compiler]
        if { $compiler == "" } {
@@ -366,10 +430,26 @@ proc gdb_default_target_compile {source destfile type options} {
     # This is obscure: we put SOURCES at the end when building an
     # object, because otherwise, in some situations, libtool will
     # become confused about the name of the actual source file.
-    if {$type == "object"} {
-       set opts "$add_flags $sources"
-    } else {
-       set opts "$sources $add_flags"
+    switch $type {
+       "object" {
+           set opts "$add_flags $sources"
+       }
+       "executable" {
+           switch $linker_opts_order {
+               "flags-then-sources" {
+                   set opts "$add_flags $sources"
+               }
+               "sources-then-flags" {
+                   set opts "$sources $add_flags"
+               }
+               default {
+                   error "Invalid value for board_info linker_opts_order"
+               }
+           }
+       }
+       default {
+           set opts "$sources $add_flags"
+       }
     }
 
     if {[is_remote host]} {
@@ -431,7 +511,26 @@ if {[info procs find_gfortran] == ""} {
     set use_gdb_compile 1
 }
 
+if {[info procs find_go_linker] == ""} {
+    rename gdb_find_go find_go
+    rename gdb_find_go_linker find_go_linker
+    set use_gdb_compile 1
+}
+
 if {$use_gdb_compile} {
     catch {rename default_target_compile {}}
     rename gdb_default_target_compile default_target_compile
 }
+
+
+# Provide 'lreverse' missing in Tcl before 7.5.
+
+if {[info procs lreverse] == ""} {
+    proc lreverse { arg } {
+       set retval {}
+       while { [llength $retval] < [llength $arg] } {
+           lappend retval [lindex $arg end-[llength $retval]]
+       }
+       return $retval
+    }
+}