source: trunk/dports/math/SuiteSparse/Portfile

Last change on this file was 144149, checked in by mcalhoun@…, 23 months ago

arpack, qrupdate, SuiteSparse: use vecLibFort instead of Accelerate Framework

  • Octave can crash unless it uses vecLibFort and its dependents do not use Accelerate Framework (run test suite to confirm)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.2 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 144149 2016-01-03 07:17:55Z ryandesign@macports.org $
3
4PortSystem          1.0
5PortGroup           compilers 1.0
6
7name                SuiteSparse
8epoch               20120107
9version             4.2.1
10revision            4
11categories          math science
12platforms           darwin
13maintainers         michaelld openmaintainer
14license             GPL-2+ LGPL-2.1+
15
16compilers.choose    cc cpp cxx
17compilers.setup
18
19description         Sparse matrix routines
20
21long_description    SuiteSparse is a single archive that contains all packages \
22                    authored by Tim Davis.
23
24homepage            http://faculty.cse.tamu.edu/davis/suitesparse.html
25master_sites        http://faculty.cse.tamu.edu/davis/SuiteSparse/
26distname            SuiteSparse-${version}
27worksrcdir          ${name}
28
29checksums           rmd160  9a2fa65845564efad79311f2ff8573217bd79f0d \
30                    sha256  e8023850bc30742e20a3623fabda02421cb5774b980e3e7c9c6d9e7e864946bd
31
32# fix Mac configuration file
33
34patchfiles-append patch-SuiteSparce_config_Mac.mk.diff
35
36# get path ordering correct
37
38patchfiles-append patch-CHOLMOD_Lib_Makefile.diff
39
40# Real -> RealPart; Imag -> ImagPart to work with some PPC
41
42patchfiles-append patch-KLU-Include-klu_version.h.diff
43
44# use <metis/metis.h>, and a METIS-specific type (idx_t instead of
45# idxtype) and routine (METIS_ComputeVertexSeparator in place of
46# METIS_NodeComputeSeparator)
47
48patchfiles-append patch-CHOLMOD-Partition-choldmod_metis.c.diff
49
50# do not try to build METIS
51
52patchfiles-append \
53    patch-CHOLMOD-Demo-Makefile.diff \
54    patch-SPQR-Demo-Makefile.diff \
55    patch-UMFPACK-Demo-Makefile.diff
56
57configure {
58
59    # SuiteSparse does not use a configure script, so we have to set
60    # configure variables manually.
61
62    set makefile ${worksrcpath}/SuiteSparse_config/SuiteSparse_config.mk
63
64    copy -force \
65        ${worksrcpath}/SuiteSparse_config/SuiteSparse_config_Mac.mk \
66        ${makefile}
67
68    # destroot, pretix, and build arch(es)
69
70    reinplace "s|@DESTROOT@|${destroot}|g" ${makefile}
71    reinplace "s|@PREFIX@|${prefix}|g" ${makefile}
72    reinplace "s|@ARCHES@|\$(TARGET_ARCH)|g" ${makefile}
73
74    # select BLAS and LAPACK
75
76    set BLAS "${prefix}/lib/vecLibFort.dylib"
77    if {[variant_isset atlas]} {
78        # Threaded lib gets priority over non-threaded (ppc)
79        if {[file exists ${prefix}/lib/libtatlas.dylib]} {
80            # linking to the threaded dylib, is there a reason to use non-threaded?
81            set BLAS "${prefix}/lib/libtatlas.dylib"
82        } else {
83            set BLAS "${prefix}/lib/libsatlas.dylib"
84        }
85    } elseif {[variant_isset openblas]} {
86        set BLAS "${prefix}/lib/libopenblas.dylib"
87    }
88    reinplace "s|@BLAS_LAPACK@|${BLAS}|g" ${makefile}
89
90    # select METIS usage, per the variant
91
92    set METIS_PATH ""
93    set METIS ""
94    set CHOLMOD_CONFIG "-DNPARTITION"
95    if {[variant_isset metis]} {
96        set METIS_PATH "${prefix}"
97        set METIS "${prefix}/lib/libmetis.dylib"
98        set CHOLMOD_CONFIG "\$(GPU_CONFIG)"
99    }
100    reinplace "s|@METIS_PATH@|${METIS_PATH}|g" ${makefile}
101    reinplace "s|@METIS@|${METIS}|g" ${makefile}
102    reinplace "s|@CHOLMOD_CONFIG@|${CHOLMOD_CONFIG}|g" ${makefile}
103}
104
105use_parallel_build  no
106
107pre-build {
108    build.args-append \
109        CC="${configure.cc}" \
110        CXX="${configure.cxx}" \
111        CFLAGS="${configure.cflags}" \
112        TARGET_ARCH="[get_canonical_archflags]"
113}
114
115build.target        default
116
117post-destroot {
118    # Create a dylib from all .a static libs
119
120    set metis ""
121    if {[variant_isset metis]} {
122        catch {exec port installed metis} output
123        if {[string match *+openmp* ${output}]} {
124            # metis installed with +openmp variant
125            set metis "-lmetis -fopenmp"
126        } else {
127            set metis "-lmetis"
128        }
129    }
130
131    set atlas "-lvecLibFort"
132    if {[variant_isset atlas]} {
133        if {[file exists ${prefix}/lib/libtatlas.dylib]} {
134            set atlas "-ltatlas"
135        } else {
136            set atlas "-lsatlas"
137        }
138    } elseif {[variant_isset openblas]} {
139        set atlas "-lopenblas"
140    }
141
142    set major [join [lrange [split ${version} .] 0 0] .]
143
144    set libs [list libamd.dylib libbtf.dylib libcamd.dylib libccolamd.dylib \
145                   libcholmod.dylib libcolamd.dylib libcxsparse.dylib \
146                   libklu.dylib libldl.dylib librbio.dylib libspqr.dylib \
147                   libsuitesparseconfig.dylib libumfpack.dylib]
148
149    # check the version number of each package
150    set sversion(amd)      2.4.0
151    set sversion(camd)     2.4.0
152    set sversion(btf)      1.2.0
153    set sversion(ccolamd)  2.9.0
154    set sversion(colamd)   2.9.0
155    set sversion(cholmod)  3.0.0
156    set sversion(cxsparse) 3.1.3
157    set sversion(klu)      1.3.0
158    set sversion(ldl)      2.2.0
159    set sversion(rbio)     2.2.0
160    set sversion(spqr)     1.3.2
161    set sversion(umfpack)  5.7.0
162
163    system -W ${worksrcpath}/SuiteSparse_config "\
164        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
165        -dynamiclib -Wl,-all_load \
166        -o libsuitesparseconfig.${version}.dylib \
167        -compatibility_version ${major} -current_version ${version} \
168        -install_name ${prefix}/lib/libsuitesparseconfig.${version}.dylib *.a"
169
170    foreach l {AMD BTF CAMD CCOLAMD COLAMD CXSparse LDL RBio} {
171        system -W ${worksrcpath}/$l/Lib "\
172            ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
173            -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
174            ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
175            -o lib[string tolower $l].$sversion([string tolower $l]).dylib \
176            -compatibility_version \
177            [join [lrange [split $sversion([string tolower $l]) .] 0 0] .] \
178            -current_version $sversion([string tolower $l]) \
179            -install_name ${prefix}/lib/lib[string tolower $l].$sversion([string tolower $l]).dylib \
180            *.o"
181    }
182
183    system -W ${worksrcpath}/CHOLMOD/Lib "\
184        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
185        -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
186        ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
187        ../../AMD/Lib/libamd.$sversion(amd).dylib \
188        ../../CAMD/Lib/libcamd.$sversion(camd).dylib \
189        ../../COLAMD/Lib/libcolamd.$sversion(colamd).dylib \
190        ../../CCOLAMD/Lib/libccolamd.$sversion(ccolamd).dylib \
191        -o libcholmod.$sversion(cholmod).dylib \
192        -compatibility_version \
193        [join [lrange [split $sversion(cholmod) .] 0 0] .] \
194        -current_version $sversion(cholmod) \
195        -install_name ${prefix}/lib/libcholmod.$sversion(cholmod).dylib \
196        *.o"
197
198    system -W ${worksrcpath}/KLU/Lib "\
199        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
200        -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
201        ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
202        ../../AMD/Lib/libamd.$sversion(amd).dylib \
203        ../../BTF/Lib/libbtf.$sversion(btf).dylib \
204        ../../COLAMD/Lib/libcolamd.$sversion(colamd).dylib \
205        -o libklu.$sversion(klu).dylib \
206        -compatibility_version \
207        [join [lrange [split $sversion(klu) .] 0 0] .] \
208        -install_name ${prefix}/lib/libklu.$sversion(klu).dylib \
209        *.o"
210
211    system -W ${worksrcpath}/SPQR/Lib "\
212        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
213        -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
214        ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
215        ../../AMD/Lib/libamd.$sversion(amd).dylib \
216        ../../CHOLMOD/Lib/libcholmod.$sversion(cholmod).dylib \
217        ../../COLAMD/Lib/libcolamd.$sversion(colamd).dylib \
218        -o libspqr.$sversion(spqr).dylib \
219        -compatibility_version \
220        [join [lrange [split $sversion(spqr) .] 0 0] .] \
221        -install_name ${prefix}/lib/libspqr.$sversion(spqr).dylib \
222        *.o"
223
224    system -W ${worksrcpath}/UMFPACK/Lib "\
225        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
226        -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
227        ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
228        ../../AMD/Lib/libamd.$sversion(amd).dylib \
229        ../../CHOLMOD/Lib/libcholmod.$sversion(cholmod).dylib \
230        -o libumfpack.$sversion(umfpack).dylib \
231        -compatibility_version \
232        [join [lrange [split $sversion(umfpack) .] 0 0] .] \
233        -install_name ${prefix}/lib/libumfpack.$sversion(umfpack).dylib \
234        *.o"
235
236    copy ${worksrcpath}/SuiteSparse_config/libsuitesparseconfig.${version}.dylib ${destroot}${prefix}/lib
237    ln -s libsuitesparseconfig.${version}.dylib ${destroot}${prefix}/lib/libsuitesparseconfig.dylib
238
239    foreach l {AMD BTF CAMD CCOLAMD CHOLMOD COLAMD CXSparse KLU LDL RBio SPQR UMFPACK} {
240        copy ${worksrcpath}/$l/Lib/lib[string tolower $l].$sversion([string tolower $l]).dylib ${destroot}${prefix}/lib
241        ln -s lib[string tolower $l].$sversion([string tolower $l]).dylib ${destroot}${prefix}/lib/lib[string tolower $l].dylib
242    }
243
244    system -W ${destroot}${prefix}/lib "\
245        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] -dynamiclib -Wl,-all_load \
246        -L${prefix}/lib ${atlas} ${metis} ${libs} -o lib${name}.${version}.dylib \
247        -compatibility_version ${major} -current_version ${version} \
248        -install_name ${prefix}/lib/lib${name}.${version}.dylib"
249
250    ln -s lib${name}.${version}.dylib ${destroot}${prefix}/lib/lib${name}.dylib
251    ln -s lib${name}.${version}.dylib ${destroot}${prefix}/lib/lib${name}.${major}.dylib
252
253    # install documentation
254
255    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
256    eval xinstall -m 644 \
257        [glob ${worksrcpath}/*/Doc/*.pdf] \
258        ${destroot}${prefix}/share/doc/${name}
259}
260
261variant metis description {Include METIS for graph partitioning and sparse matrix ordering} {
262    depends_lib-append port:metis
263}
264
265variant accelerate description {use BLAS from Apple's Accelerate.framework} conflicts atlas openblas {
266    depends_lib-append port:vecLibFort
267}
268
269variant atlas description {use BLAS from MacPorts' atlas port} conflicts accelerate openblas {
270    depends_lib-append port:atlas
271
272    # +atlas requires atlas to be installed without +nofortran
273    # see: https://trac.macports.org/ticket/47007
274    PortGroup active_variants 1.1
275    require_active_variants port:atlas "" nofortran
276
277}
278
279variant openblas description {use BLAS from MacPorts' openblas port} conflicts accelerate atlas {
280    depends_lib-append path:lib/libopenblas.dylib:OpenBLAS
281
282    # LAPACK required
283    PortGroup active_variants 1.1
284    require_active_variants path:lib/libopenblas.dylib:OpenBLAS lapack
285}
286
287if {![variant_isset accelerate] && ![variant_isset openblas] && ![variant_isset atlas] } {
288    default_variants-append +accelerate
289}
290
291if {![variant_isset accelerate] && ![variant_isset openblas] && ![variant_isset atlas] } {
292    ui_error "\n\nYou must select either the +accelerate, +atlas, or +openblas variant.\n"
293    return -code error "Invalid variant selection"
294}
295
296livecheck.type      regex
297livecheck.regex     ${name}-(\\d+(\\.\\d+)*)${extract.suffix}
Note: See TracBrowser for help on using the repository browser.