source: trunk/dports/math/OpenBLAS/Portfile @ 147867

Last change on this file since 147867 was 147867, checked in by michaelld@…, 4 years ago

OpenBLAS-devel: update to 9253dada (20160412_1).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.9 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 147867 2016-04-19 13:05:02Z michaelld@macports.org $
3
4PortSystem          1.0
5PortGroup           github 1.0
6PortGroup           muniversal 1.0
7
8name                OpenBLAS
9categories          math science
10license             BSD
11maintainers         nicos michaelld openmaintainer
12description         OpenBLAS is an optimized BLAS library based on GotoBLAS2
13long_description    ${description}
14platforms           darwin
15
16# Prevent precompiled binaries to let compilation optimise the library
17# for the user processor
18archive_sites
19
20subport OpenBLAS-devel {}
21if {[string first "-devel" $subport] > 0} {
22
23    github.setup    xianyi OpenBLAS 9253dadaa7c517090b56c8d01ab3fd751bfeddfd
24    version         20160412
25    revision        1
26    checksums       rmd160 d0cc1733b3ad1867f674023aec4ce6e6a208d0b7 \
27                    sha256 c8ab9f4efe17f71e72523ec39a0cda204e1288bf887809e07b7677d66f436062
28
29    name            ${github.project}-devel
30    conflicts       OpenBLAS
31
32    patchfiles      patch-libnoarch.devel.diff \
33                    patch-linkLib.devel.diff
34
35    livecheck.url   ${github.homepage}/commits/develop.atom
36
37} else {
38
39    github.setup    xianyi OpenBLAS 0.2.17 v
40    conflicts       OpenBLAS-devel
41
42checksums           rmd160 21387a4ba0d35b4e7854b5fc65f41d37c7a1a933 \
43                    sha256 3e18beaedeb244d03302780af921b82073c386ef9c5d356dcf5c5929edb93b44
44
45    patchfiles      patch-libnoarch.release.diff \
46                    patch-linkLib.release.diff
47
48}
49
50variant gcc45 conflicts gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 clang \
51    description "Use Gcc45 as compiler" { 
52    configure.compiler  macports-gcc-4.5
53}
54
55variant gcc46 conflicts gcc45 gcc47 gcc48 gcc49 gcc5 gcc6 clang \
56    description "Use Gcc46 as compiler" { 
57    configure.compiler  macports-gcc-4.6
58}
59
60variant gcc47 conflicts gcc45 gcc46 gcc48 gcc49 gcc5 gcc6 clang \
61    description "Use Gcc47 as compiler" { 
62    configure.compiler  macports-gcc-4.7
63}
64
65variant gcc48 conflicts gcc45 gcc46 gcc47 gcc49 gcc5 gcc6 clang \
66    description "Use Gcc48 as compiler" { 
67    configure.compiler  macports-gcc-4.8
68}
69
70variant gcc49 conflicts gcc45 gcc46 gcc47 gcc48 gcc5 gcc6 clang \
71    description "Use Gcc49 as compiler" { 
72    configure.compiler  macports-gcc-4.9
73}
74
75variant gcc5 conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc6 clang \
76    description "Use Gcc5 as compiler" { 
77    configure.compiler  macports-gcc-5
78}
79
80variant gcc6 conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 clang \
81    description "Use Gcc6 as compiler" { 
82    configure.compiler  macports-gcc-6
83}
84
85variant clang conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 \
86    description "Use Clang as compiler" {
87    if {[vercmp $xcodeversion 5.0] >= 0} {
88        configure.compiler      clang
89    } else {
90        # Xcode's clang < 5.0 does not support avx
91
92        #Use a compiler depending on system
93        if {${configure.cxx_stdlib} eq "libc++"} {
94            configure.compiler      macports-clang-3.7
95        } else {
96            configure.compiler      macports-clang-3.4
97        }
98    }
99    depends_build-append    port:gcc5
100    configure.fc            ${prefix}/bin/gfortran-mp-5
101
102}
103
104if {![variant_isset gcc45] && ![variant_isset gcc46] && ![variant_isset gcc47] && \
105    ![variant_isset gcc48] && ![variant_isset gcc49] && ![variant_isset gcc5] && \
106    ![variant_isset gcc6] && ![variant_isset clang]} {
107    if { ![catch {sysctl hw.optional.avx1_0} has_avx] && $has_avx == 1 } {
108        #Use clang if the processor has avx instructions
109        default_variants +clang       
110    } else {
111        #Else, use gcc5 as default
112        default_variants +gcc5
113    }
114}
115
116variant lapack description "Add Lapack/CLapack support to the library" { }
117default_variants-append +lapack
118
119use_configure       no
120
121pre-build {
122    if {[variant_isset universal]} {
123        foreach arch ${universal_archs_to_use} {
124            set makeINC [open ${worksrcpath}-${arch}/Makefile.rule "w"]
125            puts $makeINC "VERSION = 1"
126            puts $makeINC "LIBNAMESUFFIX = "
127
128            puts $makeINC "CC = ${configure.cc}"
129            puts $makeINC "FC = ${configure.fc}"
130
131            if {${arch} eq "x86_64" || ${arch} eq "ppc64"} {
132                puts $makeINC "BINARY = 64"
133            } else {
134                puts $makeINC "BINARY = 32"
135            }
136            if {![variant_isset clang]} {
137                 puts $makeINC "COMMON_OPT = -O3"
138            } else {
139                #Ensure to use the AVX-capable assembler
140                puts $makeINC "COMMON_OPT = -O3"
141            }
142            puts $makeINC "COMMON_PROF = -pg"
143   
144            if {![variant_isset lapack]} {
145                puts $makeINC "NO_LAPACK = 1"
146            }
147            if {![variant_isset clang]} {
148                puts $makeINC "NO_AVX = 1"
149            }
150            close $makeINC
151        }
152    } else {
153        set makeINC [open ${worksrcpath}/Makefile.rule "w"]
154        puts $makeINC "VERSION = 1"
155        puts $makeINC "LIBNAMESUFFIX = "
156
157        puts $makeINC "CC = ${configure.cc}"
158        puts $makeINC "FC = ${configure.fc}"
159
160        if {${build_arch} eq "x86_64" || ${build_arch} eq "ppc64"} {
161            puts $makeINC "BINARY = 64"
162        } else {
163            puts $makeINC "BINARY = 32"
164        }
165        if {![variant_isset clang]} {
166            puts $makeINC "COMMON_OPT = -O3"
167        } else {
168            #Ensure to use the AVX-capable assembler
169            puts $makeINC "COMMON_OPT = -O3"
170        }       
171        puts $makeINC "COMMON_PROF = -pg"
172
173        if {![variant_isset lapack]} {
174            puts $makeINC "NO_LAPACK = 1"
175        }
176        if {![variant_isset clang]} {
177            if { ![catch {sysctl hw.optional.avx1_0} has_avx] && $has_avx == 1 } {
178                ui_msg "Warning: the chosen compiler cannot handle advanced optimisation instructions."
179                ui_msg "         AVX instructions are disabled."
180            }
181            puts $makeINC "NO_AVX = 1"
182        }
183        close $makeINC
184    }
185}
186#Using system ones as default is set to bin/gcc-ar which does not exist,
187#and using gcc-mp ones end up in an error about a missing plugin
188#(see ticket #38551 for example)
189build.args          "AR=/usr/bin/ar RANLIB=/usr/bin/ranlib"
190destroot.args       "PREFIX=${prefix}"
191
192if {[variant_isset universal]} {
193    merger-post-destroot {
194        foreach arch ${universal_archs_to_use} {
195            move ${destroot}-${arch}${prefix}/include/cblas.h \
196                ${destroot}-${arch}${prefix}/include/cblas_openblas.h
197            #Correct library name
198            system "install_name_tool -id \
199                ${prefix}/lib/libopenblas-r1.dylib \
200                ${destroot}-${arch}${prefix}/lib/libopenblas-r1.dylib"
201            delete file ${destroot}-${arch}/${prefix}/lib/cmake
202            if {[variant_isset lapack]} {
203                #Install lapacke headers too
204                set LAPACKE_DIR [exec /bin/ls ${worksrcpath}/lapack-netlib | \
205                                     grep -i lapacke]
206                xinstall -m 755 ${worksrcpath}-${arch}/lapack-netlib/${LAPACKE_DIR}/include/lapacke_config.h \
207                    ${destroot}-${arch}${prefix}/include/lapacke_config.h
208                xinstall -m 755 ${worksrcpath}-${arch}/lapack-netlib/${LAPACKE_DIR}/include/lapacke_mangling.h \
209                    ${destroot}-${arch}${prefix}/include/lapacke_mangling.h
210                xinstall -m 755 ${worksrcpath}-${arch}/lapack-netlib/${LAPACKE_DIR}/include/lapacke_utils.h \
211                    ${destroot}-${arch}${prefix}/include/lapacke_utils.h
212                xinstall -m 755 ${worksrcpath}-${arch}/lapack-netlib/${LAPACKE_DIR}/include/lapacke.h \
213                    ${destroot}-${arch}${prefix}/include/lapacke.h
214            }
215        }
216    }
217} else {
218    post-destroot {
219        #Avoid conflict with Atlas
220        move ${destroot}${prefix}/include/cblas.h \
221            ${destroot}${prefix}/include/cblas_openblas.h
222        #Correct library name
223        system "install_name_tool -id \
224            ${prefix}/lib/libopenblas-r1.dylib \
225            ${destroot}${prefix}/lib/libopenblas-r1.dylib"
226        delete file ${destroot}/${prefix}/lib/cmake
227        if {[variant_isset lapack]} {
228            #Install lapacke headers too
229            set LAPACKE_DIR [exec /bin/ls ${worksrcpath}/lapack-netlib | \
230                                 grep -i lapacke]
231            xinstall -m 755 ${worksrcpath}/lapack-netlib/${LAPACKE_DIR}/include/lapacke_config.h \
232                ${destroot}${prefix}/include/lapacke_config.h
233            xinstall -m 755 ${worksrcpath}/lapack-netlib/${LAPACKE_DIR}/include/lapacke_mangling.h \
234                ${destroot}${prefix}/include/lapacke_mangling.h
235            xinstall -m 755 ${worksrcpath}/lapack-netlib/${LAPACKE_DIR}/include/lapacke_utils.h \
236                ${destroot}${prefix}/include/lapacke_utils.h
237            xinstall -m 755 ${worksrcpath}/lapack-netlib/${LAPACKE_DIR}/include/lapacke.h \
238                ${destroot}${prefix}/include/lapacke.h
239        }
240    }
241}
Note: See TracBrowser for help on using the repository browser.