aboutsummaryrefslogtreecommitdiffstats
path: root/math/suitesparse/Makefile
blob: fd94ebe14992103db7c820fca89b88650049f3e9 (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
# New ports collection makefile for:    ufspace
# Date created:     4 July 2006
# Whom:         Maho Nakata <maho@FreeBSD.org>
#
# $FreeBSD$
#

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

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

LIB_DEPENDS=     metis:${PORTSDIR}/math/metis

CONFLICTS=  umfpack-*

.include <bsd.port.pre.mk>

.if exists(${LOCALBASE}/lib/libatlas_r.so) && !defined(WITH_BLAS)
WITH_ATLAS= yes
.endif
.if defined(WITH_ATLAS)
LIB_DEPENDS+=   atlas.2:${PORTSDIR}/math/atlas
BLAS=       -L${LOCALBASE}/lib -lf77blas -latlas -lcblas
LAPACK=     -L${LOCALBASE}/lib -lalapack
.else
LIB_DEPENDS+=   blas.2:${PORTSDIR}/math/blas
LIB_DEPENDS+=   lapack.4:${PORTSDIR}/math/lapack
BLAS=       -L${LOCALBASE}/lib -lblas
LAPACK=     -L${LOCALBASE}/lib -llapack
.endif

.if ${ARCH} == "sparc64" || ${ARCH} == "amd64"
FPIC=   -fPIC
.else
FPIC=   -fpic
.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

post-patch:
    ${CP} -r ${WRKSRC} ${WRKSRC_SHARED}
    @${REINPLACE_CMD} -e 's,%%CC%%,${CC},g' \
              -e 's,%%CFLAGS%%,${CFLAGS},g' \
              -e 's,%%F77%%,${F77},g' \
              -e 's,%%FC%%,${FC},g' \
              -e 's,%%FFLAGS%%,${FFLAGS},g' \
              -e 's,%%BLAS%%,${BLAS},g' \
              -e 's,%%LAPACK%%,${LAPACK},g' \
              -e 's,%%LOCALBASE%%,${LOCALBASE},g' \
                 ${WRKSRC}/UFconfig/UFconfig.mk
    @${REINPLACE_CMD} -e 's,%%CC%%,${CC},g' \
              -e 's,%%CFLAGS%%,${CFLAGS},g' \
                ${WRKSRC}/CSparse/Source/Makefile \
                ${WRKSRC}/CXSparse/Source/Makefile

    @${REINPLACE_CMD} -e 's,%%CC%%,${CC},g' \
              -e 's,%%CFLAGS%%,${CFLAGS_SHARED},g' \
              -e 's,%%F77%%,${F77},g' \
              -e 's,%%FC%%,${FC},g' \
              -e 's,%%FFLAGS%%,${FFLAGS_SHARED},g' \
              -e 's,%%BLAS%%,${BLAS},g' \
              -e 's,%%LAPACK%%,${LAPACK},g' \
              -e 's,%%LOCALBASE%%,${LOCALBASE},g' \
                 ${WRKSRC_SHARED}/UFconfig/UFconfig.mk
    @${REINPLACE_CMD} -e 's,%%CC%%,${CC},g' \
              -e 's,%%CFLAGS%%,${CFLAGS_SHARED},g' \
                ${WRKSRC_SHARED}/CSparse/Source/Makefile \
                ${WRKSRC_SHARED}/CXSparse/Source/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/*.h                            ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/CHOLMOD/Include/*.h                        ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/COLAMD/*.h                             ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/CXSparse/Source/*.h                        ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/KLU/Include/*.h                            ${PREFIX}/include/suitesparse
    ${INSTALL_DATA} ${WRKSRC}/CAMD/Include/*.h                   ${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>