aboutsummaryrefslogtreecommitdiff
path: root/math/lapack/Makefile
blob: 73253ef2c45a9a1d7bb0c0d13004450f8c3a43c5 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Created by: jmz

PORTNAME?=	lapack
PORTVERSION=	3.10.0
.if !(defined(BLAS_SLAVEPORT) || defined(CBLAS_SLAVEPORT) || defined(XLAPACK_SLAVEPORT) || defined(LAPACKE_SLAVEPORT))
PORTREVISION=	1
.else
PORTREVISION?=	0	# Never remove this line, keep PORTREVISION?=0 in case.
.endif
CATEGORIES=	math
MASTER_SITES=	https://github.com/Reference-LAPACK/lapack/archive/refs/tags/:src	\
		http://www.netlib.org/lapack/:man	\
		LOCAL/thierry/lapack-${PORTVERSION}/:man
DISTFILES=	v${PORTVERSION}${EXTRACT_SUFX}:src
.if make(makesum) || !(defined(BLAS_SLAVEPORT) || defined(XLAPACK_SLAVEPORT))
DISTFILES+=	manpages.tgz:man
.endif
DIST_SUBDIR=	lapack-${PORTVERSION}

MAINTAINER?=	fortran@FreeBSD.org
COMMENT?=	Linear Algebra PACKage

LICENSE=	BSD3CLAUSE

USES=		cmake:testing fortran
WRKSRC=		${WRKDIR}/lapack-${PORTVERSION}
# The actual math/scilab needs deprecated functions - to be removed later
CMAKE_ON=	BUILD_SHARED_LIBS BUILD_DEPRECATED
USE_LDCONFIG=	yes

SVERSION=	${PORTVERSION:R:R}
PLIST_SUB=	SVERSION="${SVERSION}" VER=${PORTVERSION}

.include <bsd.port.options.mk>

.if defined(BLAS_SLAVEPORT)
BUILD_WRKSRC=		${CONFIGURE_WRKSRC}/BLAS/SRC
INSTALL_WRKSRC=		${BUILD_WRKSRC}
BLASLIB=		libblas.a
LIBS=			blas
PLIST_SUB+=		BLAS="" CBLAS="@comment " LAPACK="@comment " XLAPACK="@comment " LAPACKE="@comment "
.elif defined(CBLAS_SLAVEPORT)
BUILD_DEPENDS+=		lapack>0:math/lapack
LIB_DEPENDS+=		libblas.so:math/blas
CMAKE_ON+=		CBLAS
BUILD_WRKSRC=		${CONFIGURE_WRKSRC}/CBLAS
INSTALL_WRKSRC=		${BUILD_WRKSRC}
CBLASLIB=		libcblas.a
LIBS=			cblas
PLIST_SUB+=		BLAS="@comment " CBLAS="" LAPACK="@comment " XLAPACK="@comment " LAPACKE="@comment "
.elif defined(LAPACKE_SLAVEPORT)
USES+=			blaslapack
CMAKE_ON+=		USE_OPTIMIZED_BLAS USE_OPTIMIZED_LAPACK LAPACKE
CMAKE_ARGS+=		-DBLAS_LIBRARIES="${LOCALBASE}/lib/libblas.so"		\
			-DLAPACK_LIBRARIES="${LOCALBASE}/lib/liblapack.so"
BUILD_WRKSRC=		${CONFIGURE_WRKSRC}/LAPACKE
INSTALL_WRKSRC=		${BUILD_WRKSRC}
LAPACKELIB=		liblapacke.a
PLIST_SUB+=		BLAS="@comment " CBLAS="@comment " LAPACK="@comment " XLAPACK="@comment " LAPACKE=""
.elif defined(XLAPACK_SLAVEPORT)
LIB_DEPENDS+=		libblas.so:math/blas		\
			liblapack.so:math/lapack	\
			libxblas.so:math/xblas
FFLAGS+=		-fallow-argument-mismatch
CMAKE_ON+=		USE_OPTIMIZED_BLAS USE_XBLAS  BUILD_TESTING
CMAKE_ARGS+=		-DBLAS_LIBRARIES="${LOCALBASE}/lib/libblas.so"
PLIST_SUB+=		BLAS="@comment " CBLAS="@comment " LAPACK="@comment " XLAPACK="" LAPACKE="@comment "
.else
# Upstream recommand to use an optimized BLAS, but it would cause conflicts
# among the dependencies: for an optimized lapack switch to OpenBLAS.
# BUILD_TESTING to get tmglib.
LIB_DEPENDS+=		libblas.so:math/blas
. if defined(MAINTAINER_MODE)
USES+=			python:3.6+,build,test
. endif
CMAKE_ON+=		USE_OPTIMIZED_BLAS BUILD_TESTING
CMAKE_ARGS+=		-DBLAS_LIBRARIES="${LOCALBASE}/lib/libblas.so"
LIBS=			lapack
PLIST_SUB+=		BLAS="@comment " CBLAS="@comment " LAPACK="" XLAPACK="@comment " LAPACKE="@comment "
.endif

.include <bsd.port.pre.mk>

pre-configure:
	${SED} -Ee '\
		s@^(FORTRAN|LOADER)([[:blank:]]*=)(.*)@\1\2 $${FC}@; \
		s@^(OPTS[[:blank:]]*=)(.*)@\1 $${FFLAGS} $${EXTRAFLAGS}@; \
		s@^NOOPT[[:blank:]]*=.*@& $${EXTRAFLAGS}@; \
		s@^(LOADOPTS[[:blank:]]*=)(.*)@\1 $${LDFLAGS} $${EXTRAFLAGS}@; \
		s@^(CC[[:blank:]]*=)(.*)@@; \
		s@^(FC[[:blank:]]*=)(.*)@@; \
		s@^(CFLAGS[[:blank:]]*)(=)(.*)@\1 += $${EXTRAFLAGS}@; \
		s@^(FFLAGS[[:blank:]]*=)(.*)@@; \
		s@^(LDFLAGS[[:blank:]]*=)(.*)@@; \
		\@(BLAS|LAPACKE|RAN)LIB[[:blank:]]*=@d;' \
			${WRKSRC}/make.inc.example > ${WRKSRC}/make.inc
	${REINPLACE_CMD} -e 's@\./lapack_testing\.py@${S} &@' \
		${WRKSRC}/Makefile
	${FIND} ${WRKSRC} -name Makefile | ${XARGS}	\
		${SED} -i ".bak" -e 's|^ifdef|.ifdef|;s|^endif|.endif|'
.if defined(MAINTAINER_MODE)
	${REINPLACE_CMD} -e 's|PythonInterp 2.7|PythonInterp ${PYTHON_VER}|'	\
		${WRKSRC}/CMakeLists.txt
.endif

post-build:
.if defined(BLAS_SLAVEPORT)
	${SED} -e 's|%%LIB%%|blas|g;s|cd SRC|cd BLAS/SRC|;s|SRC/lib|BLAS/SRC/lib|'	\
		${FILESDIR}/static.mk >> ${BUILD_WRKSRC}/CMakeFiles/blas.dir/build.make
	(cd ${CONFIGURE_WRKSRC} && ${MAKE} -f BLAS/SRC/CMakeFiles/blas.dir/build.make build-static)
.elif defined(CBLAS_SLAVEPORT)
	${SED} -e 's|%%LIB%%|cblas|g;s|cd SRC|cd CBLAS/src|;s|SRC/lib|CBLAS/src/lib|'	\
		${FILESDIR}/static.mk >> ${BUILD_WRKSRC}/src/CMakeFiles/cblas.dir/build.make
	(cd ${CONFIGURE_WRKSRC} && ${MAKE} -f CBLAS/src/CMakeFiles/cblas.dir/build.make build-static)
.elif defined(LAPACKE_SLAVEPORT)
	${SED} -e 's|%%LIB%%|lapacke|g;s|cd SRC|cd LAPACKE|' ${FILESDIR}/static.mk	\
		>> ${BUILD_WRKSRC}/CMakeFiles/lapacke.dir/build.make
	(cd ${CONFIGURE_WRKSRC} && ${MAKE} -f LAPACKE/CMakeFiles/lapacke.dir/build.make build-static)
.else # xlapack + Lapack + tmglib
	${SED} -e 's|%%LIB%%|lapack|g' ${FILESDIR}/static.mk	\
		>> ${BUILD_WRKSRC}/SRC/CMakeFiles/lapack.dir/build.make
	(cd ${CONFIGURE_WRKSRC} && ${MAKE} -f SRC/CMakeFiles/lapack.dir/build.make build-static)
	${SED} -e 's|%%LIB%%|tmglib|g;s|cd SRC|cd TESTING/MATGEN|;s|SRC/lib|TESTING/MATGEN/lib|'	\
		${FILESDIR}/static.mk >> ${BUILD_WRKSRC}/TESTING/MATGEN/CMakeFiles/tmglib.dir/build.make
	(cd ${BUILD_WRKSRC} && ${MAKE} -f TESTING/MATGEN/CMakeFiles/tmglib.dir/build.make build-static)
.endif

pre-su-install:
.if !(defined(BLAS_SLAVEPORT) || defined(CBLAS_SLAVEPORT) || defined(XLAPACK_SLAVEPORT) || defined(LAPACKE_SLAVEPORT))
	cd ${WRKDIR} && ${FIND} man/man3 -type f | ${GREP} -v Users_julie | \
	tee ${WRKDIR}/manpages | ${SED} 's|$$|.gz|' >> ${TMPPLIST}
	cd ${WRKDIR} && \
	${XARGS} -J @ ${INSTALL_MAN} @ ${STAGEDIR}${MAN3PREFIX}/man/man3 < ${WRKDIR}/manpages
.endif

post-install:
.if defined(BLAS_SLAVEPORT)
	${INSTALL_DATA} ${CONFIGURE_WRKSRC}/BLAS/SRC/${BLASLIB} ${STAGEDIR}${PREFIX}/lib
	${INSTALL_DATA} ${CONFIGURE_WRKSRC}/BLAS/blas.pc ${STAGEDIR}${PREFIX}/libdata/pkgconfig
.elif defined(CBLAS_SLAVEPORT)
	# Avoid conflict with OpenBLAS
	${MKDIR} ${STAGEDIR}${PREFIX}/include/cblas
	${MV} ${STAGEDIR}${PREFIX}/include/*.h ${STAGEDIR}${PREFIX}/include/cblas/
	${INSTALL_DATA} ${BUILD_WRKSRC}/src/${CBLASLIB} ${STAGEDIR}${PREFIX}/lib
.elif defined(LAPACKE_SLAVEPORT)
	# Avoid conflict with OpenBLAS
	${MKDIR} ${STAGEDIR}${PREFIX}/include/lapacke
	${MV} ${STAGEDIR}${PREFIX}/include/*.h ${STAGEDIR}${PREFIX}/include/lapacke/
	${INSTALL_DATA} ${CONFIGURE_WRKSRC}/LAPACKE/${LAPACKELIB} ${STAGEDIR}${PREFIX}/lib
.elif defined(XLAPACK_SLAVEPORT)
	${INSTALL_DATA} ${BUILD_WRKSRC}/SRC/liblapack.a ${STAGEDIR}${PREFIX}/lib/libxlapack.a
	${INSTALL_DATA} ${BUILD_WRKSRC}/TESTING/MATGEN/libtmglib.a	\
		${STAGEDIR}${PREFIX}/lib/libxtmglib.a
	${MV} ${STAGEDIR}${PREFIX}/lib/liblapack.so	\
		${STAGEDIR}${PREFIX}/lib/libxlapack.so.${PORTVERSION}
	${LN} -sf libxlapack.so.${PORTVERSION} ${STAGEDIR}${PREFIX}/lib/libxlapack.so
	${LN} -sf libxlapack.so.${PORTVERSION}	\
		${STAGEDIR}${PREFIX}/lib/libxlapack.so.${SVERSION}
	${MV} ${STAGEDIR}${PREFIX}/lib/libtmglib.so	\
		${STAGEDIR}${PREFIX}/lib/libxtmglib.so.${PORTVERSION}
	${LN} -sf libxtmglib.so.${PORTVERSION} ${STAGEDIR}${PREFIX}/lib/libxtmglib.so
	${LN} -sf libxtmglib.so.${PORTVERSION}	\
		${STAGEDIR}${PREFIX}/lib/libxtmglib.so.${SVERSION}
	${SED} -e 's|lapack|xlapack|g;s|LAPACK|XLAPACK|'		\
		${STAGEDIR}${PREFIX}/libdata/pkgconfig/lapack.pc	\
		> ${STAGEDIR}${PREFIX}/libdata/pkgconfig/xlapack.pc
	${RM} ${STAGEDIR}${PREFIX}/libdata/pkgconfig/lapack.pc
.else # Lapack
	${INSTALL_DATA} ${BUILD_WRKSRC}/SRC/liblapack.a ${STAGEDIR}${PREFIX}/lib
	${INSTALL_DATA} ${BUILD_WRKSRC}/TESTING/MATGEN/libtmglib.a ${STAGEDIR}${PREFIX}/lib
.endif

.include <bsd.port.post.mk>