| OLD | NEW |
| 1 # Copyright 2004, 2007-2012 Free Software Foundation, Inc. | 1 # Copyright 2004, 2007-2012 Free Software Foundation, Inc. |
| 2 # | 2 # |
| 3 # This program is free software; you can redistribute it and/or modify | 3 # This program is free software; you can redistribute it and/or modify |
| 4 # it under the terms of the GNU General Public License as published by | 4 # it under the terms of the GNU General Public License as published by |
| 5 # the Free Software Foundation; either version 3 of the License, or | 5 # the Free Software Foundation; either version 3 of the License, or |
| 6 # (at your option) any later version. | 6 # (at your option) any later version. |
| 7 # | 7 # |
| 8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 set CC "$file -B[file dirname $file]/" | 53 set CC "$file -B[file dirname $file]/" |
| 54 } else { | 54 } else { |
| 55 set CC [transform gfortran] | 55 set CC [transform gfortran] |
| 56 } | 56 } |
| 57 } else { | 57 } else { |
| 58 set CC [transform gfortran] | 58 set CC [transform gfortran] |
| 59 } | 59 } |
| 60 return $CC | 60 return $CC |
| 61 } | 61 } |
| 62 | 62 |
| 63 proc gdb_find_go {} { |
| 64 global tool_root_dir |
| 65 |
| 66 set GO "" |
| 67 |
| 68 if {![is_remote host]} { |
| 69 set file [lookfor_file $tool_root_dir gccgo] |
| 70 if { $file != "" } { |
| 71 set root [file dirname $file] |
| 72 set GO "$file -B$root/gcc/" |
| 73 } |
| 74 } |
| 75 |
| 76 if { $GO == "" } { |
| 77 set GO [transform gccgo] |
| 78 } |
| 79 |
| 80 return $GO |
| 81 } |
| 82 |
| 83 proc gdb_find_go_linker {} { |
| 84 return [find_go] |
| 85 } |
| 86 |
| 63 proc gdb_default_target_compile {source destfile type options} { | 87 proc gdb_default_target_compile {source destfile type options} { |
| 64 global target_triplet | 88 global target_triplet |
| 65 global tool_root_dir | 89 global tool_root_dir |
| 66 global CFLAGS_FOR_TARGET | 90 global CFLAGS_FOR_TARGET |
| 67 global compiler_flags | 91 global compiler_flags |
| 68 | 92 |
| 69 if { $destfile == "" && $type != "preprocess" && $type != "none" } { | 93 if { $destfile == "" && $type != "preprocess" && $type != "none" } { |
| 70 error "Must supply an output filename for the compile to default_target_
compile" | 94 error "Must supply an output filename for the compile to default_target_
compile" |
| 71 } | 95 } |
| 72 | 96 |
| 73 set add_flags "" | 97 set add_flags "" |
| 74 set libs "" | 98 set libs "" |
| 75 set compiler_type "c" | 99 set compiler_type "c" |
| 76 set compiler "" | 100 set compiler "" |
| 101 set linker "" |
| 102 # linker_opts_order is one of "sources-then-flags", "flags-then-sources". |
| 103 # The order shouldn't matter. It's done this way to preserve |
| 104 # existing behavior. |
| 105 set linker_opts_order "sources-then-flags" |
| 77 set ldflags "" | 106 set ldflags "" |
| 78 set dest [target_info name] | 107 set dest [target_info name] |
| 79 | 108 |
| 80 if {[info exists CFLAGS_FOR_TARGET]} { | 109 if {[info exists CFLAGS_FOR_TARGET]} { |
| 81 append add_flags " $CFLAGS_FOR_TARGET" | 110 append add_flags " $CFLAGS_FOR_TARGET" |
| 82 } | 111 } |
| 83 | 112 |
| 84 if {[info exists target_info(host,name)]} { | 113 if {[info exists target_info(host,name)]} { |
| 85 set host [host_info name] | 114 set host [host_info name] |
| 86 } else { | 115 } else { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if {[board_info $dest exists f90flags]} { | 160 if {[board_info $dest exists f90flags]} { |
| 132 append add_flags " [target_info f90flags]" | 161 append add_flags " [target_info f90flags]" |
| 133 } | 162 } |
| 134 if {[board_info $dest exists f90compiler]} { | 163 if {[board_info $dest exists f90compiler]} { |
| 135 set compiler [target_info f90compiler] | 164 set compiler [target_info f90compiler] |
| 136 } else { | 165 } else { |
| 137 set compiler [find_gfortran] | 166 set compiler [find_gfortran] |
| 138 } | 167 } |
| 139 } | 168 } |
| 140 | 169 |
| 170 if { $i == "go" } { |
| 171 set compiler_type "go" |
| 172 if {[board_info $dest exists goflags]} { |
| 173 append add_flags " [target_info goflags]" |
| 174 } |
| 175 if {[board_info $dest exists gocompiler]} { |
| 176 set compiler [target_info gocompiler] |
| 177 } else { |
| 178 set compiler [find_go] |
| 179 } |
| 180 if {[board_info $dest exists golinker]} { |
| 181 set linker [target_info golinker] |
| 182 } else { |
| 183 set linker [find_go_linker] |
| 184 } |
| 185 if {[board_info $dest exists golinker_opts_order]} { |
| 186 set linker_opts_order [target_info golinker_opts_order] |
| 187 } |
| 188 } |
| 189 |
| 141 if {[regexp "^dest=" $i]} { | 190 if {[regexp "^dest=" $i]} { |
| 142 regsub "^dest=" $i "" tmp | 191 regsub "^dest=" $i "" tmp |
| 143 if {[board_info $tmp exists name]} { | 192 if {[board_info $tmp exists name]} { |
| 144 set dest [board_info $tmp name] | 193 set dest [board_info $tmp name] |
| 145 } else { | 194 } else { |
| 146 set dest $tmp | 195 set dest $tmp |
| 147 } | 196 } |
| 148 } | 197 } |
| 149 if {[regexp "^compiler=" $i]} { | 198 if {[regexp "^compiler=" $i]} { |
| 150 regsub "^compiler=" $i "" tmp | 199 regsub "^compiler=" $i "" tmp |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 235 |
| 187 if {[board_info $host exists cflags_for_target]} { | 236 if {[board_info $host exists cflags_for_target]} { |
| 188 append add_flags " [board_info $host cflags_for_target]" | 237 append add_flags " [board_info $host cflags_for_target]" |
| 189 } | 238 } |
| 190 | 239 |
| 191 global CC_FOR_TARGET | 240 global CC_FOR_TARGET |
| 192 global CXX_FOR_TARGET | 241 global CXX_FOR_TARGET |
| 193 global F77_FOR_TARGET | 242 global F77_FOR_TARGET |
| 194 global F90_FOR_TARGET | 243 global F90_FOR_TARGET |
| 195 global GNATMAKE_FOR_TARGET | 244 global GNATMAKE_FOR_TARGET |
| 245 global GO_FOR_TARGET |
| 246 global GO_LD_FOR_TARGET |
| 196 | 247 |
| 197 if {[info exists GNATMAKE_FOR_TARGET]} { | 248 if {[info exists GNATMAKE_FOR_TARGET]} { |
| 198 if { $compiler_type == "ada" } { | 249 if { $compiler_type == "ada" } { |
| 199 set compiler $GNATMAKE_FOR_TARGET | 250 set compiler $GNATMAKE_FOR_TARGET |
| 200 } | 251 } |
| 201 } | 252 } |
| 202 | 253 |
| 203 if {[info exists CC_FOR_TARGET]} { | 254 if {[info exists CC_FOR_TARGET]} { |
| 204 if { $compiler == "" } { | 255 if { $compiler == "" } { |
| 205 set compiler $CC_FOR_TARGET | 256 set compiler $CC_FOR_TARGET |
| (...skipping 11 matching lines...) Expand all Loading... |
| 217 set compiler $F77_FOR_TARGET | 268 set compiler $F77_FOR_TARGET |
| 218 } | 269 } |
| 219 } | 270 } |
| 220 | 271 |
| 221 if {[info exists F90_FOR_TARGET]} { | 272 if {[info exists F90_FOR_TARGET]} { |
| 222 if { $compiler_type == "f90" } { | 273 if { $compiler_type == "f90" } { |
| 223 set compiler $F90_FOR_TARGET | 274 set compiler $F90_FOR_TARGET |
| 224 } | 275 } |
| 225 } | 276 } |
| 226 | 277 |
| 278 if { $compiler_type == "go" } { |
| 279 if {[info exists GO_FOR_TARGET]} { |
| 280 set compiler $GO_FOR_TARGET |
| 281 } |
| 282 if {[info exists GO_LD_FOR_TARGET]} { |
| 283 set linker $GO_LD_FOR_TARGET |
| 284 } |
| 285 } |
| 286 |
| 287 if { $type == "executable" && $linker != "" } { |
| 288 set compiler $linker |
| 289 } |
| 290 |
| 227 if { $compiler == "" } { | 291 if { $compiler == "" } { |
| 228 set compiler [board_info $dest compiler] | 292 set compiler [board_info $dest compiler] |
| 229 if { $compiler == "" } { | 293 if { $compiler == "" } { |
| 230 return "default_target_compile: No compiler to compile with" | 294 return "default_target_compile: No compiler to compile with" |
| 231 } | 295 } |
| 232 } | 296 } |
| 233 | 297 |
| 234 if {![is_remote host]} { | 298 if {![is_remote host]} { |
| 235 if { [which $compiler] == 0 } { | 299 if { [which $compiler] == 0 } { |
| 236 return "default_target_compile: Can't find $compiler." | 300 return "default_target_compile: Can't find $compiler." |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 remote_file host delete a.out | 423 remote_file host delete a.out |
| 360 } else { | 424 } else { |
| 361 if { $destfile != "" } { | 425 if { $destfile != "" } { |
| 362 append add_flags " -o $destfile" | 426 append add_flags " -o $destfile" |
| 363 } | 427 } |
| 364 } | 428 } |
| 365 | 429 |
| 366 # This is obscure: we put SOURCES at the end when building an | 430 # This is obscure: we put SOURCES at the end when building an |
| 367 # object, because otherwise, in some situations, libtool will | 431 # object, because otherwise, in some situations, libtool will |
| 368 # become confused about the name of the actual source file. | 432 # become confused about the name of the actual source file. |
| 369 if {$type == "object"} { | 433 switch $type { |
| 370 » set opts "$add_flags $sources" | 434 » "object" { |
| 371 } else { | 435 » set opts "$add_flags $sources" |
| 372 » set opts "$sources $add_flags" | 436 » } |
| 437 » "executable" { |
| 438 » switch $linker_opts_order { |
| 439 » » "flags-then-sources" { |
| 440 » » set opts "$add_flags $sources" |
| 441 » » } |
| 442 » » "sources-then-flags" { |
| 443 » » set opts "$sources $add_flags" |
| 444 » » } |
| 445 » » default { |
| 446 » » error "Invalid value for board_info linker_opts_order" |
| 447 » » } |
| 448 » } |
| 449 » } |
| 450 » default { |
| 451 » set opts "$sources $add_flags" |
| 452 » } |
| 373 } | 453 } |
| 374 | 454 |
| 375 if {[is_remote host]} { | 455 if {[is_remote host]} { |
| 376 if {[host_info exists use_at]} { | 456 if {[host_info exists use_at]} { |
| 377 set fid [open "atfile" "w"] | 457 set fid [open "atfile" "w"] |
| 378 puts $fid "$opts" | 458 puts $fid "$opts" |
| 379 close $fid | 459 close $fid |
| 380 set opts "@[remote_download host atfile]" | 460 set opts "@[remote_download host atfile]" |
| 381 remote_file build delete atfile | 461 remote_file build delete atfile |
| 382 } | 462 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 if {[info procs find_gnatmake] == ""} { | 504 if {[info procs find_gnatmake] == ""} { |
| 425 rename gdb_find_gnatmake find_gnatmake | 505 rename gdb_find_gnatmake find_gnatmake |
| 426 set use_gdb_compile 1 | 506 set use_gdb_compile 1 |
| 427 } | 507 } |
| 428 | 508 |
| 429 if {[info procs find_gfortran] == ""} { | 509 if {[info procs find_gfortran] == ""} { |
| 430 rename gdb_find_gfortran find_gfortran | 510 rename gdb_find_gfortran find_gfortran |
| 431 set use_gdb_compile 1 | 511 set use_gdb_compile 1 |
| 432 } | 512 } |
| 433 | 513 |
| 514 if {[info procs find_go_linker] == ""} { |
| 515 rename gdb_find_go find_go |
| 516 rename gdb_find_go_linker find_go_linker |
| 517 set use_gdb_compile 1 |
| 518 } |
| 519 |
| 434 if {$use_gdb_compile} { | 520 if {$use_gdb_compile} { |
| 435 catch {rename default_target_compile {}} | 521 catch {rename default_target_compile {}} |
| 436 rename gdb_default_target_compile default_target_compile | 522 rename gdb_default_target_compile default_target_compile |
| 437 } | 523 } |
| OLD | NEW |