source: trunk/dports/math/SuiteSparse/Portfile @ 121952

Last change on this file since 121952 was 121952, checked in by sean@…, 5 years ago

compilers-1.0: move setup call in all ports to after setting of name

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.0 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 121952 2014-07-12 05:25:04Z sean@macports.org $
3
4PortSystem          1.0
5PortGroup           compilers 1.0
6
7name                SuiteSparse
8epoch               20120107
9version             4.2.1
10revision            3
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://www.cise.ufl.edu/research/sparse/SuiteSparse/
25master_sites        http://www.cise.ufl.edu/research/sparse/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 "-framework Accelerate"
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    }
86    reinplace "s|@BLAS_LAPACK@|${BLAS}|g" ${makefile}
87
88    # select METIS usage, per the variant
89
90    set METIS_PATH ""
91    set METIS ""
92    set CHOLMOD_CONFIG "-DNPARTITION"
93    if {[variant_isset metis]} {
94        set METIS_PATH "${prefix}"
95        set METIS "${prefix}/lib/libmetis.dylib"
96        set CHOLMOD_CONFIG "\$(GPU_CONFIG)"
97    }
98    reinplace "s|@METIS_PATH@|${METIS_PATH}|g" ${makefile}
99    reinplace "s|@METIS@|${METIS}|g" ${makefile}
100    reinplace "s|@CHOLMOD_CONFIG@|${CHOLMOD_CONFIG}|g" ${makefile}
101}
102
103use_parallel_build  no
104
105pre-build {
106    build.args-append \
107        CC="${configure.cc}" \
108        CXX="${configure.cxx}" \
109        CFLAGS="${configure.cflags}" \
110        TARGET_ARCH="[get_canonical_archflags]"
111}
112
113build.target        default
114
115post-destroot {
116    # Create a dylib from all .a static libs
117
118    set metis ""
119    if {[variant_isset metis]} {
120        catch {exec port installed metis} output
121        if {[string match *+openmp* ${output}]} {
122            # metis installed with +openmp variant
123            set metis "-lmetis -fopenmp"
124        } else {
125            set metis "-lmetis"
126        }
127    }
128
129    set atlas "-framework Accelerate"
130    if {[variant_isset atlas]} {
131        if {[file exists ${prefix}/lib/libtatlas.dylib]} {
132            set atlas "-ltatlas"
133        } else {
134            set atlas "-lsatlas"
135        }
136    }
137
138    set major [join [lrange [split ${version} .] 0 0] .]
139
140    set libs [list libamd.dylib libbtf.dylib libcamd.dylib libccolamd.dylib \
141                   libcholmod.dylib libcolamd.dylib libcxsparse.dylib \
142                   libklu.dylib libldl.dylib librbio.dylib libspqr.dylib \
143                   libsuitesparseconfig.dylib libumfpack.dylib]
144
145    # check the version number of each package
146    set sversion(amd)      2.4.0
147    set sversion(camd)     2.4.0
148    set sversion(btf)      1.2.0
149    set sversion(ccolamd)  2.9.0
150    set sversion(colamd)   2.9.0
151    set sversion(cholmod)  3.0.0
152    set sversion(cxsparse) 3.1.3
153    set sversion(klu)      1.3.0
154    set sversion(ldl)      2.2.0
155    set sversion(rbio)     2.2.0
156    set sversion(spqr)     1.3.2
157    set sversion(umfpack)  5.7.0
158
159    system -W ${worksrcpath}/SuiteSparse_config "\
160        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
161        -dynamiclib -Wl,-all_load \
162        -o libsuitesparseconfig.${version}.dylib \
163        -compatibility_version ${major} -current_version ${version} \
164        -install_name ${prefix}/lib/libsuitesparseconfig.${version}.dylib *.a"
165
166    foreach l {AMD BTF CAMD CCOLAMD COLAMD CXSparse LDL RBio} {
167        system -W ${worksrcpath}/$l/Lib "\
168            ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
169            -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
170            ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
171            -o lib[string tolower $l].$sversion([string tolower $l]).dylib \
172            -compatibility_version \
173            [join [lrange [split $sversion([string tolower $l]) .] 0 0] .] \
174            -current_version $sversion([string tolower $l]) \
175            -install_name ${prefix}/lib/lib[string tolower $l].$sversion([string tolower $l]).dylib \
176            *.o"
177    }
178
179    system -W ${worksrcpath}/CHOLMOD/Lib "\
180        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
181        -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
182        ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
183        ../../AMD/Lib/libamd.$sversion(amd).dylib \
184        ../../CAMD/Lib/libcamd.$sversion(camd).dylib \
185        ../../COLAMD/Lib/libcolamd.$sversion(colamd).dylib \
186        ../../CCOLAMD/Lib/libccolamd.$sversion(ccolamd).dylib \
187        -o libcholmod.$sversion(cholmod).dylib \
188        -compatibility_version \
189        [join [lrange [split $sversion(cholmod) .] 0 0] .] \
190        -current_version $sversion(cholmod) \
191        -install_name ${prefix}/lib/libcholmod.$sversion(cholmod).dylib \
192        *.o"
193
194    system -W ${worksrcpath}/KLU/Lib "\
195        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
196        -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
197        ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
198        ../../AMD/Lib/libamd.$sversion(amd).dylib \
199        ../../BTF/Lib/libbtf.$sversion(btf).dylib \
200        ../../COLAMD/Lib/libcolamd.$sversion(colamd).dylib \
201        -o libklu.$sversion(klu).dylib \
202        -compatibility_version \
203        [join [lrange [split $sversion(klu) .] 0 0] .] \
204        -install_name ${prefix}/lib/libklu.$sversion(klu).dylib \
205        *.o"
206
207    system -W ${worksrcpath}/SPQR/Lib "\
208        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
209        -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
210        ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
211        ../../AMD/Lib/libamd.$sversion(amd).dylib \
212        ../../CHOLMOD/Lib/libcholmod.$sversion(cholmod).dylib \
213        ../../COLAMD/Lib/libcolamd.$sversion(colamd).dylib \
214        -o libspqr.$sversion(spqr).dylib \
215        -compatibility_version \
216        [join [lrange [split $sversion(spqr) .] 0 0] .] \
217        -install_name ${prefix}/lib/libspqr.$sversion(spqr).dylib \
218        *.o"
219
220    system -W ${worksrcpath}/UMFPACK/Lib "\
221        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] \
222        -dynamiclib -Wl,-all_load -L${prefix}/lib ${atlas} ${metis} \
223        ../../SuiteSparse_config/libsuitesparseconfig.${version}.dylib \
224        ../../AMD/Lib/libamd.$sversion(amd).dylib \
225        ../../CHOLMOD/Lib/libcholmod.$sversion(cholmod).dylib \
226        -o libumfpack.$sversion(umfpack).dylib \
227        -compatibility_version \
228        [join [lrange [split $sversion(umfpack) .] 0 0] .] \
229        -install_name ${prefix}/lib/libumfpack.$sversion(umfpack).dylib \
230        *.o"
231
232    copy ${worksrcpath}/SuiteSparse_config/libsuitesparseconfig.${version}.dylib ${destroot}${prefix}/lib
233    ln -s libsuitesparseconfig.${version}.dylib ${destroot}${prefix}/lib/libsuitesparseconfig.dylib
234
235    foreach l {AMD BTF CAMD CCOLAMD CHOLMOD COLAMD CXSparse KLU LDL RBio SPQR UMFPACK} {
236        copy ${worksrcpath}/$l/Lib/lib[string tolower $l].$sversion([string tolower $l]).dylib ${destroot}${prefix}/lib
237        ln -s lib[string tolower $l].$sversion([string tolower $l]).dylib ${destroot}${prefix}/lib/lib[string tolower $l].dylib
238    }
239
240    system -W ${destroot}${prefix}/lib "\
241        ${configure.cxx} -Wall ${configure.cflags} [get_canonical_archflags cxx] -dynamiclib -Wl,-all_load \
242        -L${prefix}/lib ${atlas} ${metis} ${libs} -o lib${name}.${version}.dylib \
243        -compatibility_version ${major} -current_version ${version} \
244        -install_name ${prefix}/lib/lib${name}.${version}.dylib"
245
246    ln -s lib${name}.${version}.dylib ${destroot}${prefix}/lib/lib${name}.dylib
247    ln -s lib${name}.${version}.dylib ${destroot}${prefix}/lib/lib${name}.${major}.dylib
248
249    # install documentation
250
251    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
252    eval xinstall -m 644 \
253        [glob ${worksrcpath}/*/Doc/*.pdf] \
254        ${destroot}${prefix}/share/doc/${name}
255}
256
257variant metis description {Include METIS for graph partitioning and sparse matrix ordering} {
258    depends_lib-append port:metis
259}
260
261variant atlas description {Use MacPorts' ATLAS instead of Accelerate Framework} {
262    depends_lib-append port:atlas
263}
264
265livecheck.type      regex
266livecheck.regex     ${name}-(\\d+(\\.\\d+)*)${extract.suffix}
Note: See TracBrowser for help on using the repository browser.