summaryrefslogtreecommitdiff
path: root/math/lapack/Makefile
blob: 70c39e1fcf0183c79035aa0b6d45648d60ec2245 (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
# New ports collection makefile for:    lapack
# Date created:         2 July 1994
# Whom:                 jmz
#
# $FreeBSD$
#

PORTNAME=	lapack
PORTVERSION=	3.3.0
PORTREVISION=	1
CATEGORIES=	math
MASTER_SITES=	ftp://ftp.netlib.org/lapack/ \
		http://netlib.org/lapack/ \
		http://scicomp.ewha.ac.kr/netlib/lapack/ \
		http://service-spi.web.cern.ch/service-spi/external/tarFiles/
DISTFILES=	lapack-${PORTVERSION}.tgz manpages-3.2.0.tgz

MAINTAINER=	maho@FreeBSD.org
COMMENT=	A library of Fortran 77 subroutines for linear algebra

LIB_DEPENDS=	blas.2:${PORTSDIR}/math/blas

USE_FORTRAN=	yes
DIST_SUBDIR=	lapack
USE_LDCONFIG=	yes

OPTIONS=	PROFILE "Build and install profiling libraries" Off

.include <bsd.port.pre.mk>

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

MAKE_JOBS_SAFE=	yes
MANSRC=${WRKDIR}/lapack-3.2.0
WRKSRC_SHARED=${WRKSRC}_shared
FFLAGS_SHARED=${FPIC}
.if defined(WITH_PROFILE)
.if defined(WITHOUT_PROFILE)
IGNORE =	you have defined both WITH_PROFILE and WITHOUT_PROFILE
.elif !exists(/usr/lib/libc_p.a)
IGNORE=	you have chosen WITH_PROFILE, but have not installed the\
base system profiling libraries
.endif
WRKSRC_PROFILE=${WRKSRC}_profile
FFLAGS_PROFILE=-pg
PLIST_SUB+=	PROFILE=""
.else
PLIST_SUB+=	PROFILE="@comment "
.endif

SVERSION=4
BLAS?=	-L${LOCALBASE}/lib -lblas
RANLIB=	${LOCALBASE}/bin/ranlib
AR=	${LOCALBASE}/bin/ar

pre-fetch:
	@${ECHO} "You can override F77 and FFLAGS on the command line."

.include "${FILESDIR}/manpages"

post-patch:
	@${MV} ${WRKSRC}/INSTALL/make.inc.gfortran ${WRKSRC}/make.inc
	${REINPLACE_CMD} -Ee \
		's,\( *cd ([^ ;]+) *; *\$$\(MAKE\) *([[:alnum:]]*) *\),${MAKE} -C \1 ${_MAKE_JOBS} \2,' \
		${WRKSRC}/Makefile
	${REINPLACE_CMD} -Ee \
		's,cd ([^ ;]+) *; *\$$\(MAKE\) *([[:alnum:]]*) *,${MAKE} -C \1 ${_MAKE_JOBS} \2,' \
		${WRKSRC}/TESTING/Makefile
	@${REINPLACE_CMD} -e 's;%%F77%%;${F77};g' \
			  -e 's;%%FFLAGS%%;${FFLAGS};g' \
			  -e 's;%%LDFLAGS%%;${LDFLAGS};g' \
			  -e 's;%%RANLIB%%;${RANLIB};g' \
			  -e 's;%%BLAS%%;${BLAS};g' \
				${WRKSRC}/make.inc
	@${CP} -r ${WRKSRC} ${WRKSRC_SHARED}
	@(cd ${WRKSRC_SHARED}; ${PATCH} <${FILESDIR}/shared-patch-SRC+Makefile)
.if !(defined(NOPROFILE) || defined(NO_PROFILE) || defined(WITHOUT_PROFILE))
	@${CP} -r ${WRKSRC} ${WRKSRC_PROFILE}
.endif
	@${REINPLACE_CMD} -e 's,%%EXTRAFLAGS%%,,g' \
				${WRKSRC}/make.inc
	@${REINPLACE_CMD} -e 's,%%EXTRAFLAGS%%,${FFLAGS_SHARED},g' \
				${WRKSRC_SHARED}/make.inc
.if defined(WITH_PROFILE)
	@${REINPLACE_CMD} -e 's,%%EXTRAFLAGS%%,${FFLAGS_PROFILE},g' \
				${WRKSRC_PROFILE}/make.inc
.endif

do-build:
	@${ECHO_CMD} "Building static lapack library"
	${MAKE} -C ${WRKSRC} ${.MAKEFLAGS} ${_MAKE_JOBS} ARCH="${AR}"
	@${ECHO_CMD} "Building shared lapack library"
	${MAKE} -C ${WRKSRC_SHARED} ${.MAKEFLAGS} ${_MAKE_JOBS} ARCH="${AR}"
.if defined(WITH_PROFILE)
	@${ECHO_CMD} "Building profile lapack library"
	${MAKE} -C ${WRKSRC_PROFILE} ${.MAKEFLAGS} ${_MAKE_JOBS} ARCH="${AR}"
.endif

post-build:
.for lib in lapack tmglib
	cd ${WRKSRC_SHARED} ; ${FC} ${FFLAGS} ${FFLAGS_SHARED} ${LDFLAGS} -shared \
	-o lib${lib}.so.${SVERSION} -Wl,-x -Wl,-soname,lib${lib}.so.${SVERSION} \
	-Wl,--whole-archive lib${lib}.a -Wl,--no-whole-archive
.endfor

do-install:
.for lib in lapack tmglib
	${INSTALL_DATA} ${WRKSRC}/lib${lib}.a ${PREFIX}/lib
	${INSTALL_DATA} ${WRKSRC_SHARED}/lib${lib}.so.${SVERSION} ${PREFIX}/lib
	${LN} -sf lib${lib}.so.${SVERSION} ${PREFIX}/lib/lib${lib}.so
.if defined(WITH_PROFILE)
	${INSTALL_DATA} ${WRKSRC_PROFILE}/lib${lib}.a ${PREFIX}/lib/lib${lib}_p.a
.endif
.endfor
	${INSTALL_MAN} ${MANSRC}/manpages/man/manl/[a-c]*.l ${PREFIX}/man/manl
	${INSTALL_MAN} ${MANSRC}/manpages/man/manl/[d-l]*.l ${PREFIX}/man/manl
	${INSTALL_MAN} ${MANSRC}/manpages/man/manl/[m-s]*.l ${PREFIX}/man/manl
	${INSTALL_MAN} ${MANSRC}/manpages/man/manl/[t-z]*.l ${PREFIX}/man/manl

regression-test check test: build
	@${ECHO_CMD} "Testing static lapack library"
	${MAKE} -C ${WRKSRC}/TESTING ${.MAKEFLAGS} ARCH="${AR}"

.include <bsd.port.post.mk>