aboutsummaryrefslogtreecommitdiffstats
path: root/math/lapack/Makefile
blob: 1234365f82698c73160bfaebcf5359e52fa2c4a2 (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# New ports collection makefile for:    lapack
# Date created:         2 July 1994
# Whom:                 jmz
#
# $FreeBSD$
#

PORTNAME?=  lapack
PORTVERSION=    3.4.0
PORTREVISION?=  1
CATEGORIES= math
MASTER_SITES=   NL/lapack/ \
        http://service-spi.web.cern.ch/service-spi/external/tarFiles/
DISTFILES=  lapack-${PORTVERSION}.tgz
.if make(makesum) || !(defined(BLAS_SLAVEPORT) || defined(XLAPACK_SLAVEPORT))
DISTFILES+=     manpages-${PORTVERSION}.tgz
.endif
DIST_SUBDIR=    lapack

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

LICENSE=    BSD
LICENSE_FILE=   ${WRKSRC}/LICENSE

USE_FORTRAN=    yes

OPTIONS=    PROFILE "Build profiling libraries" Off \
        SHARED  "Build shared libraries and PIC archives" On \
        STATIC  "Build (non-PIC) archives" On

MAKE_ENV=   BLASLIB="${BLASLIB}"
MAKE_JOBS_SAFE= yes
PLIST_SUB=  SVERSION="${SVERSION}"

WRKSRC =        ${WRKDIR}/lapack-${PORTVERSION}
WRKSRC_PROFILE =    ${WRKSRC}_PROFILE
WRKSRC_SHARED=      ${WRKSRC}_SHARED
WRKSRC_STATIC=      ${WRKSRC}

.include <bsd.port.options.mk>

.if defined(BLAS_SLAVEPORT)
ALL_TARGET=     blaslib
BLASLIB=        ../../libblas.a
LIBS=           blas
PLIST_SUB+=     BLAS="" LAPACK="@comment " XLAPACK="@comment "
SVERSION=       2
TEST_TARGET=        blas_testing
.else
ALL_TARGET=     lib
BLASLIB?=       -L${LOCALBASE}/lib -lblas
LIB_DEPENDS+=       blas.2:${PORTSDIR}/math/blas
LIBS=           lapack tmglib
SVERSION=       4
TEST_TARGET=        lapack_testing
.if defined(MAINTAINER_MODE) || defined(PACKAGE_BUILDING)
S=          ${PYTHON_CMD}
USE_PYTHON_BUILD=   yes
.else
S=          \#
.endif
.if defined(XLAPACK_SLAVEPORT)
LIB_DEPENDS+=       xblas.0:${PORTSDIR}/math/xblas
MAKE_ENV+=      USEXBLAS=yes XBLASLIB="${XBLASLIB}"
P=          x
PLIST_SUB+=     BLAS="@comment " LAPACK="@comment " XLAPACK=""
XBLASLIB?=      -L${LOCALBASE}/lib -lxblas
.else
PLIST_SUB+=     BLAS="@comment " LAPACK="" XLAPACK="@comment "
.if defined(MAINTAINER_MODE)
BUILD_DEPENDS +=    doxygen:${PORTSDIR}/devel/doxygen
MAN_TARGET=     build-manpages
.endif
.endif
.endif

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

FFLAGS_PROFILE?=    -pg
FFLAGS_SHARED ?=    ${PICFLAG}

.if defined(WITH_PROFILE) && !exists(/usr/lib/libc_p.a)
IGNORE= you have chosen WITH_PROFILE, but have not installed the\
base system profiling libraries
.endif

.if defined(WITH_SHARED)
USE_LDCONFIG=   yes
.endif

.for o in PROFILE SHARED STATIC
.if defined(WITH_${o})
PLIST_SUB+= ${o}=""
.else
PLIST_SUB+= ${o}="@comment "
.endif
.endfor

post-patch:
    @${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}@; \
        \@(BLAS|RAN)LIB[[:blank:]]*=@d;' \
            ${WRKSRC}/make.inc.example > ${WRKSRC}/make.inc
    @${REINPLACE_CMD} -e 's@\./lapack_testing\.py@${S} &@' \
        ${WRKSRC}/Makefile
.for o in PROFILE SHARED
.if defined(WITH_${o})
    @${CP} -a ${WRKSRC} ${WRKSRC_${o}}
.endif
.endfor

do-build: ${MAN_TARGET} build-profile build-shared build-static

.for o in PROFILE SHARED STATIC
build-${o:L}: patch
.if defined(WITH_${o})
    ${PRINTF} "\n\nBuilding ${o:L} libraries:\n\n\n"
    cd ${WRKSRC_${o}}; ${SETENV} ${MAKE_ENV} EXTRAFLAGS="${FFLAGS_${o}}" \
    ${MAKE} ${_MAKE_JOBS} ${MAKE_ARGS} ARCH="${AR}" ${ALL_TARGET}

.endif
.endfor

.if defined (MAINTAINER_MODE)
build-manpages: patch
    @cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${_MAKE_JOBS} \
    ${MAKE_ARGS} man

.endif

post-build:
.if defined(WITH_SHARED)
.for L in ${LIBS}
    cd ${WRKSRC_SHARED} ; ${FC} ${FFLAGS} ${FFLAGS_SHARED} ${LDFLAGS} -shared \
    -o lib${P}${L}.so.${SVERSION} -Wl,-x -Wl,-soname,lib${P}${L}.so.${SVERSION} \
    -Wl,--whole-archive lib${L}.a -Wl,--no-whole-archive
.endfor
.endif

.if defined(WITH_SHARED)
TESTS ?=    test-shared
.elif defined(WITH_STATIC)
TESTS ?=    test-static
.elif defined(WITH_PROFILE)
TESTS ?=    test-profile
.endif

check regression-test test: ${TESTS}

.for o in PROFILE SHARED STATIC
test-${o:L}: build-${o:L}
.if defined(WITH_${o})
    @${PRINTF} "\n\nTesting ${o:L} libraries:\n\n\n"
    @cd ${WRKSRC_${o}}; ${SETENV} ${MAKE_ENV} EXTRAFLAGS="${FFLAGS_${o}}" \
    ${MAKE} ${_MAKE_JOBS} ${MAKE_ARGS} ARCH="${AR}" ${TEST_TARGET}
.if defined(BLAS_SLAVEPORT)
    @${CAT} ${WRKSRC_${o}}/BLAS/*.out
.endif

.endif
.endfor

do-install:
.for L in ${LIBS}
.if defined(WITH_STATIC)
    @${INSTALL_DATA} ${WRKSRC}/lib${L}.a ${PREFIX}/lib/lib${P}${L}.a
.endif
.if defined(WITH_SHARED)
    @${INSTALL_DATA} ${WRKSRC_SHARED}/lib${L}.a ${PREFIX}/lib/lib${P}${L}_pic.a
    @${INSTALL_DATA} ${WRKSRC_SHARED}/lib${P}${L}.so.${SVERSION} ${PREFIX}/lib
    @${LN} -sf lib${P}${L}.so.${SVERSION} ${PREFIX}/lib/lib${P}${L}.so
.endif
.if defined(WITH_PROFILE)
    @${INSTALL_DATA} ${WRKSRC_PROFILE}/lib${L}.a ${PREFIX}/lib/lib${P}${L}_p.a
.endif
.endfor

.include  <bsd.port.pre.mk>

.if !(defined(BLAS_SLAVEPORT) || defined(XLAPACK_SLAVEPORT))

.include "${FILESDIR}/manpages"

post-install:
    @cd ${WRKDIR}/man ; ${ECHO_CMD} ${MAN3:S|^|man3/|} \
    | ${XARGS} -J @ ${INSTALL_MAN} @ ${MAN3PREFIX}/man/man3

.if defined(MAINTAINER_MODE)
package-manpages: build-manpages
    @${RM} -f ${WRKDIR}/lapack-manpages-${PORTVERSION}.tar.gz ; \
    cd ${WRKSRC}/DOCS/man; \
    ${TAR} -czvf ${WRKDIR}/lapack-manpages-${PORTVERSION}.tar.gz \
    ${MAN3:S|^|man3/|}

.endif
.endif
.include <bsd.port.post.mk>