aboutsummaryrefslogtreecommitdiff
path: root/math/suitesparse/bsd.suitesparse.mk
blob: 1138901747f13c65b00bd3eb9af32f4c87d0b8b0 (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
# Created by: Maho Nakata <maho@FreeBSD.org>
#
# Common elements used by the SuiteSparse modules

PKGNAMEPREFIX=	suitesparse-
SSPNAME=	suitesparse
SSPVERSION=	5.10.1
DISTVERSIONPREFIX=	v

MAINTAINER=	fortran@FreeBSD.org

#USE_GITHUB=	yes # Does not work with different versions for modules
GH_ACCOUNT=	DrTimothyAldenDavis
GH_PROJECT=	SuiteSparse
GH_TAGNAME=	${SSPVERSION}
MASTER_SITES=	https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/archive/refs/tags/
DISTNAME=	${DISTVERSIONPREFIX}${SSPVERSION}
DIST_SUBDIR=	${SSPNAME}
WRKSRC=		${WRKDIR}/${GH_PROJECT}-${SSPVERSION}

.if ${PORTNAME} != config &&	\
	${PORTNAME} != CSparse &&	\
	${PORTNAME} != ssget
LIB_DEPENDS+=	libsuitesparseconfig.so:math/suitesparse-config
.endif
.if ${PORTNAME} != config &&	\
	${PORTNAME} != BTF &&	\
	${PORTNAME} != ssget
OPTIONS_DEFINE+=DEMOS
.else
ALL_TARGET=	library
.endif

USES+=		gmake

DOCSDIR=	${PREFIX}/share/doc/${SSPNAME}
MAKE_ENV=	BLAS="${BLASLIB}" LAPACK="${LAPACKLIB}" \
		OPTIMIZATION="${OPTIMIZATION}" \
		MY_METIS_LIB="-lmetis" \
		JOBS="${MAKE_JOBS_NUMBER}" \
		CMAKE_OPTIONS='${CMAKE_ARGS}' \
		INSTALL="${STAGEDIR}${PREFIX}" \
		INSTALL_DOC="${STAGEDIR}${DOCSDIR}" \
		INSTALL_INCLUDE="${STAGEDIR}${PREFIX}/include/${SSPNAME}"
CMAKE_ARGS=	-DCMAKE_INSTALL_INCLUDEDIR:PATH="include/${SSPNAME}"	\
		-DBUILD_GRB_STATIC_LIBRARY:BOOL=ON
LDFLAGS+=	-L${WRKSRC}/lib # prevent linking with shared libs from the preinstalled older versions

INSTALL_TARGET=	install # skip USES=cmake
INSTALL_WRKSRC=	${BUILD_WRKSRC}

# FIXME: wont work if .CURDIR contains spaces
DISTINFO_FILE=	${.CURDIR}/../../math/suitesparse/distinfo

OPTIONS_DEFINE+=	DOCS OPTIMIZED_CFLAGS
OPTIONS_DEFAULT+=	OPTIMIZED_CFLAGS

.if defined(BLAS_NEEDED)
OPTIONS_RADIO+=		BLAS
OPTIONS_RADIO_BLAS+=	ATLAS GOTOBLAS NETLIB OPENBLAS
OPTIONS_DEFAULT+=	OPENBLAS

ATLAS_USES=		blaslapack:atlas
GOTOBLAS_DESC=		Goto blas implementation
GOTOBLAS_USES=		blaslapack:gotoblas
NETLIB_USES=		blaslapack:netlib
OPENBLAS_USES=		blaslapack:openblas
.endif

.if defined(OMP_NEEDED)
OPTIONS_DEFINE+=	OPENMP
OPTIONS_EXCLUDE_aarch64=	OPENMP
OPTIONS_DEFAULT+=	OPENMP

OPENMP_MAKE_ENV_OFF=	CFOPENMP=
. if !exists(/usr/include/omp.h)
# XXX ports/199603: LLVM openmp in base doesn't support armv6, armv7 yet
OPENMP_VARS=		OPENMP=gcc-
. endif
.endif

DEMOS_DESC=		Build the demonstrations
.if ${PORTNAME} == Mongoose
DEMOS_ALL_TARGET=	default
.else
DEMOS_ALL_TARGET=	all
.endif
DEMOS_ALL_TARGET_OFF=	library

.if !defined(WITH_DEBUG)
OPTIMIZED_CFLAGS_VARS=	OPTIMIZATION="-O3"
LDFLAGS+=	-s
.endif

post-extract:
	${RM} -r ${WRKSRC}/metis-*

.if ${PORTNAME} == AMD ||	\
	${PORTNAME} == CAMD ||	\
	${PORTNAME} == CCOLAMD ||	\
	${PORTNAME} == CHOLMOD ||	\
	${PORTNAME} == COLAMD ||	\
	${PORTNAME} == CSparse ||	\
	${PORTNAME} == CXSparse_newfiles ||	\
	${PORTNAME} == CXSparse ||	\
	${PORTNAME} == GPUQREngine ||	\
	${PORTNAME} == KLU ||	\
	${PORTNAME} == LDL ||	\
	${PORTNAME} == RBio ||	\
	${PORTNAME} == SPQR ||	\
	${PORTNAME} == UMFPACK
pre-configure:
	${REINPLACE_CMD} -e 's|-I../../include|-I${STAGEDIR}${PREFIX}/include/suitesparse -I../../SuiteSparse_config -I../../AMD/Include -I../../COLAMD/Include -I../../BTF/Include -I../../CHOLMOD/Include|;\
		s|-lsuitesparseconfig|-lsuitesparseconfig -L${LOCALBASE}/lib|'	\
		${BUILD_WRKSRC}/Demo/Makefile
.endif

do-configure: # skip USES=cmake

post-install:
.if ! ${PORTNAME} == config
	 @${RM} ${STAGEDIR}${DOCSDIR}/SUITESPARSECONFIG_README.txt	\
		${STAGEDIR}${PREFIX}/include/suitesparse/SuiteSparse_config.h
.endif

.include <bsd.port.pre.mk>

.if ${ARCH} == i386
# See PR 230888 : Missing 64 bit atomic functions for i386
USE_GCC=	yes
LDFLAGS+=	-latomic
.elif defined(PPC_ABI) && ${PPC_ABI} == ELFv1
USE_GCC=	yes
.else
USES+=	compiler:c++11-lib
.endif