Ticket #30041: supported_compilers.patch

File supported_compilers.patch, 3.2 KB (added by nerdling (Jeremy Lavergne), 13 years ago)
  • src/port1.0/portconfigure.tcl

     
    183183default configure.f90           {[portconfigure::configure_get_compiler f90]}
    184184default configure.fc            {[portconfigure::configure_get_compiler fc]}
    185185default configure.javac         {[portconfigure::configure_get_compiler javac]}
    186 default configure.compiler      {[portconfigure::configure_get_default_compiler]}
     186default configure.compiler      {[portconfigure::configure_choose_supported_compilers [portconfigure::configure_get_default_compiler]]}
    187187
    188188set_ui_prefix
    189189
     
    233233    }
    234234}
    235235
     236# internal function find known compilers
     237proc portconfigure::find_known_compilers default {
     238    set compiler_names {}
     239    lappend $compiler_names cc gcc gcc-3.3 gcc-4.0 gcc-4.2 apple-gcc-3.3 apple-gcc-4.0 apple-gcc-4.2
     240    lappend $compiler_names macports-gcc-4.0 macports-gcc-4.1 macports-gcc-4.2 macports-gcc-4.3 macports-gcc-4.4 macports-gcc-4.5 macports-gcc-4.6
     241    lappend $compiler_names llvm-gcc-4.2 clang macports-llvm-gcc-4.2 macports-clang
     242
     243    set compiler_binaries {}
     244    lappend $compiler_binaries cc objc cxx cpp fc f77 f90
     245
     246    set found_compilers {}
     247    ## assume the default compiler exists, search for the rest
     248    #lappend $found_compilers [portconfigure::configure_get_default_compiler]
     249
     250    # check for any binary from each compiler
     251    foreach compiler $compiler_names {
     252        foreach binary $compiler_binaries {
     253            set test_compiler [portconfigure::configure_get_compiler $binary $compiler]
     254            if {[file executable $test_compiler] && [lsearch -exact $found_compilers $compiler] == -1} {
     255                lappend found_compilers $compiler
     256                ui_debug "Found $compiler ($test_compiler)"
     257                break
     258            }
     259        }
     260    }
     261
     262    return $found_compilers
     263}
     264
     265# internal function to choose the default configure.compiler
     266proc portconfigure::choose_supported_compilers {compilers} {
     267
     268    # if not set, any compiler will work
     269    global supported_compilers
     270    if {$supported_compilers == ""} {
     271        return $compilers
     272    }
     273
     274    # if set, thin the available set
     275    set ret {}
     276    foreach compiler $compilers {
     277        if {[lsearch -exact $supported_compilers $compiler] != -1]} {
     278            if {[lsearch -exact $ret $add_compiler] == -1} {
     279                lappend $ret $add_compiler
     280            }
     281        }
     282    }
     283
     284    return $ret
     285}
     286
    236287# internal function to choose the default configure.build_arch and
    237288# configure.universal_archs based on supported_archs and build_arch or
    238289# universal_archs
     
    368419}
    369420
    370421# internal function to find correct compilers
    371 proc portconfigure::configure_get_compiler {type} {
     422proc portconfigure::configure_get_compiler {type} {find_this_compiler} {
    372423    global configure.compiler prefix developer_dir
    373424    set ret ""
    374     switch -exact ${configure.compiler} {
     425
     426    if {$find_this_compiler == ""} {
     427        set compiler ${configure.compiler}
     428    }
     429
     430    switch -exact ${find_this_compiler} {
    375431        cc {
    376432            switch -exact ${type} {
    377433                cc   { set ret /usr/bin/cc }