Ticket #53348: OpenBlas-Portfile-tweak_compilers.diff

File OpenBlas-Portfile-tweak_compilers.diff, 4.7 KB (added by michaelld (Michael Dickens), 8 years ago)
  • math/OpenBLAS/Portfile

    diff --git a/math/OpenBLAS/Portfile b/math/OpenBLAS/Portfile
    index 8388fd3aeb..1ef520b33e 100644
    a b checksums rmd160 11f85eb4bb382e10298ac40d1e1fd4ecc46bb3da \ 
    4545
    4646}
    4747
    48 variant gcc45 conflicts gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 clang \
    49     description "Use Gcc45 as compiler" {
    50     configure.compiler  macports-gcc-4.5
    51 }
     48# declare +clang variant
     49
     50variant clang description "Use Clang as C/C++ compiler (required for AVX)" {}
    5251
    53 variant gcc46 conflicts gcc45 gcc47 gcc48 gcc49 gcc5 gcc6 clang \
    54     description "Use Gcc46 as compiler" {
    55     configure.compiler  macports-gcc-4.6
     52# default to +clang if the processor has avx instructions
     53if {![catch {sysctl hw.optional.avx1_0} has_avx] && $has_avx == 1 &&
     54    ![variant_isset clang]} {
     55    default_variants +clang
    5656}
    5757
    58 variant gcc47 conflicts gcc45 gcc46 gcc48 gcc49 gcc5 gcc6 clang \
    59     description "Use Gcc47 as compiler" {
    60     configure.compiler  macports-gcc-4.7
     58# it is OK to use -clang, so don't check for that condition here
     59
     60# declare +gcc* variants
     61
     62set GCC_VERSIONS_NO_DOT {45 46 47 48 49 5 6 7}
     63
     64foreach this_gcc_version_no_dot ${GCC_VERSIONS_NO_DOT} {
     65    set ndx [lsearch -exact ${this_gcc_version_no_dot} ${this_gcc_version_no_dot}]
     66    set this_conflicts [lreplace ${this_gcc_version_no_dot} ${ndx} ${ndx}]
     67    if {[variant_isset clang]} {
     68        set this_description "Use gcc${this_gcc_version_no_dot} as Fortran compiler"
     69    } else {
     70        set this_description "Use gcc${this_gcc_version_no_dot} for the compiler suite"
     71    }
     72    eval [subst {
     73        variant gcc${this_gcc_version_no_dot} \
     74            conflicts ${this_conflicts} \
     75            description ${this_description} {}
     76    }]
    6177}
    6278
    63 variant gcc48 conflicts gcc45 gcc46 gcc47 gcc49 gcc5 gcc6 clang \
    64     description "Use Gcc48 as compiler" {
    65     configure.compiler  macports-gcc-4.8
     79# set default +gcc* variant: default to +gcc6 if not other +gcc*
     80# variant is selected. this variant is used for Fortran, no matter
     81# whether +clang is selected or not. if +clang is not selected or
     82# -clang is selected, then use the selected +gcc* variant for the
     83# compiler suite.
     84
     85set GCC_VER_NO_DOT 0
     86foreach this_gcc_version_no_dot ${GCC_VERSIONS_NO_DOT} {
     87    if {[variant_isset gcc${this_gcc_version_no_dot}]} {
     88        set GCC_VER_NO_DOT ${this_gcc_version_no_dot}
     89        break
     90    }
    6691}
    6792
    68 variant gcc49 conflicts gcc45 gcc46 gcc47 gcc48 gcc5 gcc6 clang \
    69     description "Use Gcc49 as compiler" {
    70     configure.compiler  macports-gcc-4.9
     93if {${GCC_VER_NO_DOT} == 0} {
     94    default_variants +gcc6
    7195}
    7296
    73 variant gcc5 conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc6 clang \
    74     description "Use Gcc5 as compiler" {
    75     configure.compiler  macports-gcc-5
     97# make sure -gcc6 was not selected alone
     98
     99set GCC_VER_NO_DOT 0
     100foreach this_gcc_version_no_dot ${GCC_VERSIONS_NO_DOT} {
     101    if {[variant_isset gcc${this_gcc_version_no_dot}]} {
     102        set GCC_VER_NO_DOT ${this_gcc_version_no_dot}
     103        break
     104    }
    76105}
    77106
    78 variant gcc6 conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 clang \
    79     description "Use Gcc6 as compiler" {
    80     configure.compiler  macports-gcc-6
     107if {${GCC_VER_NO_DOT} == 0} {
     108    ui_error "\n\nYou must select a Fortran compiler variant; you cannot select -gcc6 alone.\n"
     109    return -code error "Invalid variant selection."
    81110}
    82111
    83 variant clang conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 \
    84     description "Use Clang as compiler" {
     112set GCC_VER_DOT [join [split ${GCC_VER_NO_DOT} ""] "."]
     113
     114# set compilers to use
     115
     116if {[variant_isset clang]} {
     117
     118    # use selected +gcc* for Fortran only
     119    depends_build-append    port:gcc${GCC_VER_NO_DOT}
     120    configure.fc            ${prefix}/bin/gfortran-mp-${GCC_VER_DOT}
     121
    85122    if {[vercmp $xcodeversion 5.0] >= 0} {
    86123        configure.compiler      clang
    87124    } else {
    variant clang conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 \ 
    94131            configure.compiler      macports-clang-3.4
    95132        }
    96133    }
    97     depends_build-append    port:gcc5
    98     configure.fc            ${prefix}/bin/gfortran-mp-5
     134} else {
    99135
    100 }
     136    # use selected +gcc* for the whole compiler suite
     137    configure.compiler  macports-gcc-${GCC_VER_DOT}
    101138
    102 if {![variant_isset gcc45] && ![variant_isset gcc46] && ![variant_isset gcc47] && \
    103     ![variant_isset gcc48] && ![variant_isset gcc49] && ![variant_isset gcc5] && \
    104     ![variant_isset gcc6] && ![variant_isset clang]} {
    105     if { ![catch {sysctl hw.optional.avx1_0} has_avx] && $has_avx == 1 } {
    106         #Use clang if the processor has avx instructions
    107         default_variants +clang
    108     } else {
    109         #Else, use gcc5 as default
    110         default_variants +gcc5
    111     }
    112139}
    113140
    114141variant lapack description "Add Lapack/CLapack support to the library" { }