| 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 |
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 | |
| 75 | configure { |
| 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 |
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 | |
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} |
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 | | |
| 109 | use_parallel_build no |
| 110 | |
| 111 | build.target default |
| 112 | build.args-append CC="${configure.cc}" CXX="${configure.cxx}" \ |
| 113 | CFLAGS="${configure.cflags}" LDFLAGS="${configure.ldflags}" |
| 114 | |
| 115 | if {[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 | |
| 121 | post-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 | |