aboutsummaryrefslogtreecommitdiffstats
path: root/math/suitesparse/Makefile
blob: d5e2a3086efa5c45b0fa18e0a4ed71e1978e32fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# New ports collection makefile for:    ufspace
# Date created:     4 July 2006
# Whom:         Maho Nakata <maho@FreeBSD.org>
#
# $FreeBSD$
#

PORTNAME=   suitesparse
PORTVERSION=    3.6.1
PORTREVISION=   1
CATEGORIES= math
MASTER_SITES=   http://www.cise.ufl.edu/research/sparse/SuiteSparse/
DISTNAME=   SuiteSparse-${PORTVERSION}

MAINTAINER= maho@FreeBSD.org
COMMENT=    SuiteSparse is a set of packages for sparse matrices calculation

.if defined (WITH_METIS)
LIB_DEPENDS=    metis:${PORTSDIR}/math/metis
.endif

.if defined (WITH_METIS)
RESTRICTED= GPL and METIS license contradicts
.endif

CONFLICTS=  umfpack-*

.include <bsd.port.pre.mk>

USE_BLAS?=  reference

.if exists(${LOCALBASE}/lib/libgoto2.so)
USE_BLAS=     gotoblas
.elif exists(${LOCALBASE}/lib/libatlas_r.so)
USE_BLAS=     atlas
.endif

.if ${USE_BLAS} == reference
LIB_DEPENDS+=   blas.2:${PORTSDIR}/math/blas
LIB_DEPENDS+=   lapack.4:${PORTSDIR}/math/lapack
BLAS=       -lblas
LAPACK=     -llapack
.elif ${USE_BLAS} == gotoblas
LIB_DEPENDS+=   goto2:${PORTSDIR}/math/gotoblas
LIB_DEPENDS+=   lapack.4:${PORTSDIR}/math/lapack
BLAS=       -pthread -lgoto2p
LAPACK=     -pthread -lgoto2p
.elif ${USE_BLAS} == atlas
LIB_DEPENDS+=   atlas:${PORTSDIR}/math/atlas
BLAS=       -pthread -lptf77blas -lptcblas -latlas_r
LAPACK=     -pthread -lalapack_r
.endif

.if ${ARCH} == "sparc64" || ${ARCH} == "amd64"
FPIC=   -fPIC
.else
FPIC=   -fpic
.endif

.if ${ARCH} == "sparc64"
BROKEN=     Does not link on sparc64
.endif

USE_LDCONFIG=   yes
USE_GMAKE=  yes
USE_FORTRAN=    yes
WRKSRC=${WRKDIR}/SuiteSparse
WRKSRC_SHARED=${WRKSRC}_shared
CFLAGS_SHARED=${CFLAGS} ${FPIC}
FFLAGS_SHARED=${CFLAGS} ${FPIC}
SVERSION=1
FORTRANRUNTIME=-lgfortran -lgfortranbegin

.if defined (WITH_METIS)
METIS=${LOCALBASE}/lib/libmetis.a
METIS_PATH=${LOCALBASE}/include/metis
CHOLMOD_CONFIG =
.else
CHOLMOD_CONFIG = -DNPARTITION
.endif

post-patch:
    ${CP} -r ${WRKSRC} ${WRKSRC_SHARED}
    @${REINPLACE_CMD} -e 's|%%CC%%|${CC}|g' \
              -e 's|%%CXX%%|${CXX}|g' \
              -e 's|%%F77%%|${F77}|g' \
              -e 's|%%BLAS%%|-L${LOCALBASE}/lib ${BLAS}|g' \
              -e 's|%%FORTRANRUNTIME%%|${FORTRANRUNTIME}|g' \
              -e 's|%%LAPACK%%|-L${LOCALBASE}/lib ${LAPACK}|g' \
              -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
              -e 's|%%METIS_PATH%%|${METIS_PATH}|g' \
              -e 's|%%METIS%%|${METIS}|g' \
              -e 's|%%CHOLMOD_CONFIG%%|${CHOLMOD_CONFIG}|g' \
                 ${WRKSRC}/UFconfig/UFconfig.mk \
                 ${WRKSRC_SHARED}/UFconfig/UFconfig.mk\
                 ${WRKSRC}/CSparse/Lib/Makefile \
                 ${WRKSRC_SHARED}/CSparse/Lib/Makefile \
                 ${WRKSRC}/CSparse3/Lib/Makefile \
                 ${WRKSRC_SHARED}/CSparse3/Lib/Makefile

    @${REINPLACE_CMD}  -e 's|%%CFLAGS%%|${CFLAGS}|g' \
               -e 's|%%FFLAGS%%|${FFLAGS}|g' \
                 ${WRKSRC}/UFconfig/UFconfig.mk \
                 ${WRKSRC}/CSparse/Lib/Makefile \
                 ${WRKSRC}/CSparse3/Lib/Makefile

    @${REINPLACE_CMD}  -e 's|%%CFLAGS%%|${CFLAGS_SHARED}|g' \
               -e 's|%%FFLAGS%%|${FFLAGS_SHARED}|g' \
                 ${WRKSRC_SHARED}/UFconfig/UFconfig.mk \
                 ${WRKSRC_SHARED}/CSparse/Lib/Makefile \
                 ${WRKSRC_SHARED}/CSparse3/Lib/Makefile
do-build:
    cd ${WRKSRC} ; ${GMAKE}
    cd ${WRKSRC_SHARED} ; ${GMAKE}
    ${RM} -rf ${WRKDIR}/tmp_static
    ${MKDIR} ${WRKDIR}/tmp_static
    cd ${WRKDIR}/tmp_static
    ${FIND} ${WRKSRC} -name "*\.a" -exec ${MV} {} ${WRKDIR}/tmp_static \;
    ${RM} -rf ${WRKDIR}/tmp_shared
    ${MKDIR} ${WRKDIR}/tmp_shared
    ${FIND} ${WRKSRC_SHARED} -name "*\.a" -exec ${MV} {} ${WRKDIR}/tmp_shared \;
post-build:
    cd ${WRKDIR}/tmp_shared ; for i in `ls *.a | ${SED}  's/\.a//' `; do \
        ld -Bshareable -o $${i}.so.${SVERSION} -x -soname $${i}.so.${SVERSION} --whole-archive $${i}.a ;\
        ${LN} -s $${i}.so.${SVERSION} $${i}.so ;\
    done

do-install:
    ${MKDIR} ${PREFIX}/include/suitesparse
    ${LN} -sf ${PREFIX}/include/suitesparse ${PREFIX}/include/ufsparse
    ${INSTALL_DATA} ${WRKSRC}/UFconfig/UFconfig.h                        ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/UMFPACK/Include/*.h                        ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/AMD/Include/*.h                ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/BTF/Include/*.h                ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/CCOLAMD/Include/*.h                    ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/CHOLMOD/Include/*.h                        ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/COLAMD/Include/*.h                     ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/CXSparse/Include/*.h                       ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/KLU/Include/*.h                            ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/CAMD/Include/*.h                   ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/SPQR/Include/*.h                   ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/SPQR/Include/*.hpp                     ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKDIR}/tmp_static/*.a                             ${PREFIX}/lib
    ${INSTALL_DATA} ${WRKDIR}/tmp_shared/*.so.${SVERSION}                    ${PREFIX}/lib
    ${INSTALL_DATA} ${WRKDIR}/tmp_shared/*.so                    ${PREFIX}/lib

.include <bsd.port.post.mk>