Ticket #35019: suitespace-4.0.0.diff

File suitespace-4.0.0.diff, 9.5 KB (added by skymoo (Adam Mercer), 12 years ago)
  • math/SuiteSparse/Portfile

    diff --git a/math/SuiteSparse/Portfile b/math/SuiteSparse/Portfile
    index 22402a9..0fef358 100644
    a b PortSystem 1.0 
    55
    66name                SuiteSparse
    77epoch               20120107
    8 version             3.4.0
    9 revision            3
     8version             4.0.0
    109categories          math science
    1110platforms           darwin
    1211maintainers         nomaintainer
    long_description SuiteSparse is a single archive that contains all packages \ 
    1918
    2019homepage            http://www.cise.ufl.edu/research/sparse/SuiteSparse/
    2120master_sites        http://www.cise.ufl.edu/research/sparse/SuiteSparse/
     21distname            SuiteSparse-${version}
    2222worksrcdir          ${name}
    2323
    24 checksums           md5     e59dcabc9173b1ba1b3659ae147006b8 \
    25                     sha1    6de027d48a573659b40ddf57c10e32b39ab034c6 \
    26                     rmd160  77ff7376691d2bc8581de6ae89f246cb289b2708
     24checksums           rmd160  395d9cfa86785db17e30ce02ba55984b2c896b00 \
     25                    sha256  b26cf214bf981d735a2f517aee1975cee0034c865b288d2629c6280e026f6bdb
    2726
    28 patchfiles          makefiles.patch \
    29                     UFconfig_UFconfig.mk-patch
    30 
    31 use_configure       no
    32 
    33 # cflags recommended for Macs in ${worksrcpath}/UFconfig/UFconfig.mk
    34 configure.optflags  -O3 -fno-common -fexceptions
    35 
    36 variant universal {}
    37 if {[variant_isset universal]} {
    38     append configure.cflags " " ${configure.universal_cflags}
    39 } else {
    40     append configure.cflags " " ${configure.cc_archflags}
    41 }
    42 
    43 use_parallel_build  no
    44 
    45 build.target
     27global makefile
     28set makefile ${worksrcpath}/SuiteSparse_config/SuiteSparse_config.mk
    4629
    4730post-patch {
    4831    if {[variant_isset metis]} {
    4932        # Use the MacPorts version rather than extracting copy in source dir
    50        
     33
    5134        # -I$(METIS_PATH)/Lib -> -I$(METIS_PATH)/include
    5235        reinplace \
    5336            "s|-I\$(METIS_PATH)/Lib|-I\$(METIS_PATH)/include|g" \
    5437            ${worksrcpath}/CHOLMOD/Lib/Makefile
    55        
     38
    5639        # #include "metis.h" -> #include <metis/metis.h>
    5740        reinplace \
    5841            "s|#include \"metis.h\"|#include <metis/metis.h>|g" \
    5942            ${worksrcpath}/CHOLMOD/Partition/cholmod_metis.c
     43
     44        # CHOLMOD Makefile is set up to detect metis local to build dir. Use Macports version.
     45        reinplace \
     46            "s|ifeq (../../metis-4.0, \$(wildcard ../../metis-4.0))|ifneq \(,\$\(METIS_PATH\)\)|" \
     47            ${worksrcpath}/CHOLMOD/Lib/Makefile ${worksrcpath}/CHOLMOD/Demo/Makefile
     48
     49        # Do not try to build Metis in /opt/local
     50        reinplace \
     51            "s|^\$\(METIS\):$|fooblafoo:|" \
     52            ${worksrcpath}/UMFPACK/Demo/Makefile
     53
     54        # There is a patch on the SuiteSparse homepage to get Metis 5.0 to work with SuiteSparse.
     55        # It replaces all idxtype with idx_t
     56        # and METIS_NodeComputeSeparator with METIS_ComputeVertexSeparator
     57        reinplace \
     58            "s|idxtype|idx_t|g" \
     59            ${worksrcpath}/CHOLMOD/Partition/cholmod_metis.c
     60        reinplace \
     61            "s|METIS_NodeComputeSeparator \(\&nn, Mp, Mi, Mnw, Mew, Opt, \&csp, Mpart\)|\
     62               METIS_ComputeVertexSeparator \(\\\&nn, Mp, Mi, Mnw, Opt, \\\&csp, Mpart\)|g" \
     63            ${worksrcpath}/CHOLMOD/Partition/cholmod_metis.c
    6064    }
    61    
     65
    6266    # klu_version.h defines Real and Imag which conflicts with math.h on ppc
    6367    reinplace -E \
    6468        "s|(\[^a-zA-Z\])Real(\[^a-zA-Z\])|\\1RealPart\\2|g" \
    post-patch { 
    6670    reinplace -E \
    6771        "s|(\[^a-zA-Z\])Imag(\[^a-zA-Z\])|\\1ImagPart\\2|g" \
    6872        ${worksrcpath}/KLU/Include/klu_version.h
    69     # ranlib after ar
    70     # THESE LINES NEED TO HAVE TABS ENCODED IN THE PORTFILE
    71     reinplace "s|ccolamd_global\.o|ccolamd_global.o\\
    72         - \$(RANLIB) libccolamd.a|" ${worksrcpath}/CCOLAMD/Lib/Makefile
    73     reinplace "s|colamd_global\.o|colamd_global.o\\
    74         - \$(RANLIB) libcolamd.a|" ${worksrcpath}/COLAMD/Lib/Makefile
     73}
     74
     75configure {
     76    file rename ${worksrcpath}/SuiteSparse_config/SuiteSparse_config.mk \
     77                ${worksrcpath}/SuiteSparse_config/SuiteSparse_config_Linux.mk
     78    file rename ${worksrcpath}/SuiteSparse_config/SuiteSparse_config_Mac.mk \
     79                ${worksrcpath}/SuiteSparse_config/SuiteSparse_config.mk
    7580}
    7681
    7782post-configure {
    post-configure { 
    7984    #    set manually.
    8085    # This is done in post-configure so that ${configure.cc} is
    8186    #    set to its default value.
    82     reinplace -E \
    83         "s|^CC = .*$|CC = ${configure.cc}|g" \
    84         ${worksrcpath}/UFconfig/UFconfig.mk \
    85         ${worksrcpath}/CSparse/Demo/Makefile \
    86         ${worksrcpath}/CSparse/Lib/Makefile
    87     reinplace -E \
    88         "s|^CPLUSPLUS = .*$|CPLUSPLUS = ${configure.cxx}|g" \
    89         ${worksrcpath}/UFconfig/UFconfig.mk
    90     reinplace -E \
    91         "s|^CFLAGS = .*$|CFLAGS = ${configure.cflags}|g" \
    92         ${worksrcpath}/UFconfig/UFconfig.mk
    93     reinplace -E \
    94         "s|^CFLAGS = -O|CFLAGS = ${configure.cflags}|g" \
    95         ${worksrcpath}/CSparse/Demo/Makefile \
    96         ${worksrcpath}/CSparse/Lib/Makefile
    97     reinplace -E \
    98         "s|^BLAS = .*$|BLAS = -framework Accelerate|g" \
    99         ${worksrcpath}/UFconfig/UFconfig.mk
    100     reinplace -E \
    101         "s|^LAPACK = .*$|LAPACK = -framework Accelerate|g" \
    102         ${worksrcpath}/UFconfig/UFconfig.mk
    103     reinplace "s|(CC)|(CC) \$(CFLAGS)|" ${worksrcpath}/CXSparse/Demo/Makefile
    104    
     87    reinplace "s|INSTALL_LIB = .*$|INSTALL_LIB = ${destroot}${prefix}/lib|g" ${makefile}
     88    reinplace "s|INSTALL_INCLUDE = .*$|INSTALL_INCLUDE = ${destroot}${prefix}/include|g" ${makefile}
     89
     90    # Include build archs
     91    reinplace -E "s|^\[^#\].*(CF = .*)$|\\1 \$(TARGET_ARCH)|g" ${makefile}
     92
     93    if {[variant_isset atlas]} {
     94        # linking to the threaded dylib, is there a reason to use non-threaded?
     95        reinplace "s|BLAS = .*$|BLAS = ${prefix}/lib/libtatlas.dylib|g" ${makefile}
     96        reinplace "s|LAPACK = .*$|LAPACK = ${prefix}/lib/libtatlas.dylib|g" ${makefile}
     97    }
     98
    10599    if {[variant_isset metis]} {
    106         reinplace -E \
    107             "s|^METIS_PATH = .*$|METIS_PATH = ${prefix}|g" \
    108             ${worksrcpath}/UFconfig/UFconfig.mk
    109         reinplace -E \
    110             "s|^METIS = .*$|METIS = ${prefix}/lib/libmetis.a|g" \
    111             ${worksrcpath}/UFconfig/UFconfig.mk
     100        reinplace "s|^METIS_PATH = .*$|METIS_PATH = ${prefix}|g" ${makefile}
     101        reinplace "s|^METIS = .*$|METIS = ${prefix}/lib/libmetis.dylib|g" ${makefile}
     102    } else {
     103        reinplace "s|^METIS_PATH = .*$|METIS_PATH = |g" ${makefile}
     104        reinplace "s|^METIS = .*$|METIS = |g" ${makefile}
     105        reinplace "s|^CHOLMOD_CONFIG = .*$|CHOLMOD_CONFIG = -DNPARTITION|g" ${makefile}
    112106    }
    113107}
    114108
    115 destroot {
    116     # SuiteSparse does not support "make install"
    117    
    118     eval xinstall -m 644 \
    119         [glob ${worksrcpath}/*/Lib/*.a] \
    120         ${destroot}${prefix}/lib
    121    
    122     xinstall -m 755 -d ${destroot}${prefix}/include/ufsparse
    123     eval xinstall -m 644 \
    124         [glob ${worksrcpath}/*/Include/*.h] \
    125         [glob ${worksrcpath}/*/Include/*.hpp] \
    126         ${worksrcpath}/UFconfig/UFconfig.h \
    127         ${destroot}${prefix}/include/ufsparse
    128    
     109use_parallel_build  no
     110
     111build.target        default
     112build.args-append   CC="${configure.cc}" CXX="${configure.cxx}" \
     113                    CFLAGS="${configure.cflags}" LDFLAGS="${configure.ldflags}"
     114
     115if {[variant_isset universal]} {
     116    build.args-append   TARGET_ARCH="${configure.universal_cflags}"
     117} else {
     118    build.args-append   TARGET_ARCH="${configure.cc_archflags}"
     119}
     120
     121post-destroot {
     122    # Create a dylib from all .a static libs
     123    if {[variant_isset universal]} {
     124        set arch ${configure.universal_cflags}
     125    } else {
     126        set arch ${configure.cc_archflags}
     127    }
     128
     129    if {[variant_isset metis]} {
     130        catch {exec port installed metis} output
     131        if {[string match *+openmpi* ${output}]} {
     132            # metis installed with +openmpi variant
     133            set metis "-lmetis -fopenmp"
     134        } else {
     135            set metis "-lmetis"
     136        }
     137    } else {
     138        set metis ""
     139    }
     140
     141    if {[variant_isset atlas]} {
     142        set atlas "-ltatlas"
     143    } else {
     144        set atlas "-framework Accelerate"
     145    }
     146
     147    set major [join [lrange [split ${version} .] 0 0] .]
     148
     149    set libs [list libamd.a libbtf.a libcamd.a libccolamd.a \
     150             libcholmod.a libcolamd.a libcxsparse.a libklu.a \
     151             libldl.a librbio.a libspqr.a libsuitesparseconfig.a libumfpack.a]
     152
     153    system "cd ${destroot}${prefix}/lib && \
     154        ${configure.cc} -Wall ${configure.cflags} ${arch} -dynamiclib -Wl,-all_load \
     155        -L${prefix}/lib ${atlas} ${metis} ${libs} -o lib${name}.${version}.dylib \
     156        -compatibility_version ${major} -current_version ${version} \
     157        -install_name ${prefix}/lib/lib${name}.${version}.dylib"
     158
     159    ln -s lib${name}.${version}.dylib ${destroot}${prefix}/lib/lib${name}.dylib
     160    ln -s lib${name}.${version}.dylib ${destroot}${prefix}/lib/lib${name}.${major}.dylib
     161
    129162    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    130163    eval xinstall -m 644 \
    131164        [glob ${worksrcpath}/*/Doc/*.pdf] \
    132165        ${destroot}${prefix}/share/doc/${name}
    133166}
    134167
    135 variant metis description {Use METIS (not distributable)} {
     168variant universal {}
     169
     170variant metis description {Use METIS for graph partitioning and sparse matrix ordering} {
    136171    depends_build       port:metis
    137     patchfiles-delete   UFconfig_UFconfig.mk-patch
     172}
     173
     174variant atlas description {Use Macports' ATLAS instead of Accelerate Framework} {
     175    depends_lib-append  port:atlas
    138176}
    139177
    140178livecheck.type      regex