aboutsummaryrefslogtreecommitdiffstats
path: root/math/libflame/Makefile
blob: 6645ef70deea66885f0d4e875e073c894e062385 (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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# Created by: bf@FreeBSD.org
# $FreeBSD$

PORTNAME=   libflame
DISTVERSION=    r7421
PORTREVISION=   5
CATEGORIES= math
MASTER_SITES=   http://www.cs.utexas.edu/users/%SUBDIR%/:1,2 LOCAL/bf:3
MASTER_SITE_SUBDIR= flame/snapshots/:1 field/docs/:2
DISTFILES=  ${DISTNAME}${EXTRACT_SUFX}:3 libflame.pdf:3
EXTRACT_ONLY=   ${DISTNAME}${EXTRACT_SUFX}

MAINTAINER= bf@FreeBSD.org
COMMENT=    FLAME dense linear algebra library

LICENSE=    LGPL21

BUILD_DEPENDS=  bash:shells/bash

GNU_CONFIGURE=  yes
USE_CSTD=   c99
USES=       gmake

CONFIGURE_ARGS=     --enable-dynamic-build --enable-static-build

OPTIONS_DEFINE= BLAS3_CNTL BUILTIN_BLAS CBLAS EXTERNAL_LAPACK GOTOBLAS \
        LAPACK2FLAME LAPACK_SUBPROBLEMS OPENMP SHARED STATIC \
        SUPERMATRIX THREADS DOCS EXAMPLES
OPTIONS_DEFAULT=    BLAS3_CNTL LAPACK2FLAME SHARED SUPERMATRIX THREADS
BLAS3_CNTL_DESC=    Set Level-3 BLAS variant and blocksize
BUILTIN_BLAS_DESC=  Build the (suboptimal) internal BLAS
CBLAS_DESC=     Build an interface to an external C BLAS
EXTERNAL_LAPACK_DESC=   Build an interface to an external LAPACK
GOTOBLAS_DESC=      Build a full GotoBLAS interface
LAPACK2FLAME_DESC=  Build a LAPACK compatibility layer
LAPACK_SUBPROBLEMS_DESC=    Use an external LAPACK for subproblems
OPENMP_DESC=        Use multithreading via OpenMP
SHARED_DESC=        Build a shared library and PIC archive
STATIC_DESC=        Build a non-PIC archive
SUPERMATRIX_DESC=   Task scheduling and parallel execution

.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MBLAS3_CNTL}
CONFIGURE_ARGS+=    --enable-blas3-front-end-cntl-trees
.else
CONFIGURE_ARGS+=    --disable-blas3-front-end-cntl-trees
.endif

.if ${PORT_OPTIONS:MBUILTIN_BLAS}
IGNORE=     : BUILTIN_BLAS is an experimental option, for testing purposes only
.if ${PORT_OPTIONS:MCBLAS} || ${PORT_OPTIONS:MGOTOBLAS}
IGNORE=     : BUILTIN_BLAS is incompatible with CBLAS and GOTOBLAS
.endif
CONFIGURE_ARGS+=    --enable-builtin-blas
.else
CONFIGURE_ARGS+=    --disable-builtin-blas
.endif

.if ${PORT_OPTIONS:MCBLAS}
IGNORE=     : CBLAS yields an incomplete library, and is for testing purposes only
.if ${PORT_OPTIONS:MGOTOBLAS}
IGNORE=     : CBLAS is incompatible with GOTOBLAS
.endif
CONFIGURE_ARGS+=    --enable-cblas-interfaces
.else
CONFIGURE_ARGS+=    --disable-cblas-interfaces
.endif

.if ${PORT_OPTIONS:MEXTERNAL_LAPACK}
CONFIGURE_ARGS+=    --enable-external-lapack-interfaces
.else
CONFIGURE_ARGS+=    --disable-external-lapack-interfaces
.endif

.if ${PORT_OPTIONS:MGOTOBLAS}
CONFIGURE_ARGS+=    --enable-goto-interfaces
WITH_BLAS=  gotoblas
.else
CONFIGURE_ARGS+=    --disable-goto-interfaces
.for b in M K N
.if defined(${b}_BLOCKSIZE)
CONFIGURE_ARGS+=    --enable-default-${b:tl}-blocksize=${${b}_BLOCKSIZE}
.endif
.endfor
.endif

.if ${PORT_OPTIONS:MLAPACK2FLAME}
.if ${PORT_OPTIONS:MLAPACK_SUBPROBLEMS}
IGNORE=     : LAPACK2FLAME is incompatible with LAPACK_SUBPROBLEMS
.endif
CONFIGURE_ARGS+=    --enable-lapack2flame
.else
CONFIGURE_ARGS+=    --disable-lapack2flame
.endif

.if ${PORT_OPTIONS:MLAPACK_SUBPROBLEMS}
.if ! ${PORT_OPTIONS:MEXTERNAL_LAPACK}
IGNORE=     : LAPACK_SUBPROBLEMS requires EXTERNAL_LAPACK
.endif
CONFIGURE_ARGS+=    --enable-external-lapack-for-subproblems
.else
CONFIGURE_ARGS+=    --disable-external-lapack-for-subproblems
.endif

.if ${PORT_OPTIONS:MEXTERNAL_LAPACK} || ! ${PORT_OPTIONS:MBUILTIN_BLAS}
.if ${PORT_OPTIONS:MCBLAS}
.if exists(${LOCALBASE}/lib/libatlas.so)
WITH_BLAS?= atlas_c
.else
WITH_BLAS?= reference_c
.endif
.if !(${WITH_BLAS} == "atlas_c" || ${WITH_BLAS} == "reference_c")
IGNORE= : CBLAS is incompatible with WITH_BLAS = ${WITH_BLAS}
.endif
.elif exists(${LOCALBASE}/lib/libgoto2.so)
WITH_BLAS?= gotoblas
.elif exists(${LOCALBASE}/lib/libatlas.so)
WITH_BLAS?= atlas
.else
WITH_BLAS?= reference
.endif  #WITH_CBLAS
.endif #WITH_EXTERNAL_LAPACK or WITH_BUILTIN_BLAS

.if ! ${PORT_OPTIONS:MBUILTIN_BLAS}
.if ${WITH_BLAS} == atlas
RUN_DEPENDS +=  ${LOCALBASE}/lib/libatlas.so:math/atlas
BLAS=       -lptf77blas
.elif ${WITH_BLAS} == atlas_c
RUN_DEPENDS +=  ${LOCALBASE}/lib/libatlas.so:math/atlas
BLAS=       -lptcblas
.elif ${WITH_BLAS} == gotoblas
RUN_DEPENDS +=  ${LOCALBASE}/lib/libgoto2p.so:math/gotoblas
BLAS=           -lgoto2p
.elif ${WITH_BLAS} == reference
RUN_DEPENDS +=  ${LOCALBASE}/lib/libblas.so:math/blas
BLAS=       -lblas
.elif ${WITH_BLAS} == reference_c
RUN_DEPENDS +=  ${LOCALBASE}/lib/libgslcblas.so:math/gsl
BLAS=       -lgslcblas
.endif #WITH_BLAS
.endif #WITH_BUILTIN_BLAS

.if ${PORT_OPTIONS:MEXTERNAL_LAPACK}
.if !empty(WITH_BLAS:Matlas*)
.if ${PORT_OPTIONS:MBUILTIN_BLAS}
RUN_DEPENDS +=  ${LOCALBASE}/lib/libatlas.so:math/atlas
.endif
LAPACK=     -lalapack -lptcblas -lptf77blas
.elif ${WITH_BLAS} == gotoblas
.if ${PORT_OPTIONS:MBUILTIN_BLAS}
RUN_DEPENDS +=  ${LOCALBASE}/lib/libgoto2p.so:math/gotoblas
.endif
LAPACK=     -lgoto2p
.elif !empty(WITH_BLAS:Mreference*)
RUN_DEPENDS +=  ${LOCALBASE}/lib/liblapack.so:math/lapack
LAPACK=     -llapack
.if ${PORT_OPTIONS:MBUILTIN_BLAS} || ${PORT_OPTIONS:MCBLAS}
RUN_DEPENDS +=  ${LOCALBASE}/lib/libblas.so:math/blas
LAPACK+=    -lblas
.endif
.endif #WITH_BLAS
.endif #WITH_EXTERNAL_LAPACK

.if ${PORT_OPTIONS:MOPENMP}
.if ${PORT_OPTIONS:MTHREADS}
IGNORE=     OPENMP is incompatible with THREADS
.endif
.if !empty(CC:M*clang*)
IGNORE=     clang does not support OPENMP, use THREADS instead
.endif
OPENMP_CFLAGS ?=    -fopenmp
CFLAGS+=        ${OPENMP_CFLAGS}
LDFLAGS+=       ${OPENMP_CFLAGS}
CONFIGURE_ARGS+=    --enable-multithreading=openmp
.elif ${PORT_OPTIONS:MTHREADS}
CONFIGURE_ARGS+=    --enable-multithreading=pthreads
.else
CONFIGURE_ARGS+=    --enable-multithreading=no
.endif

.if ${PORT_OPTIONS:MSHARED}
USE_LDCONFIG=   yes
.endif

.for o in SHARED STATIC
.if ${PORT_OPTIONS:M${o}}
PLIST_SUB+= ${o}=""
.else
PLIST_SUB+= ${o}="@comment "
.endif
.endfor

.if ${PORT_OPTIONS:MSUPERMATRIX}
CONFIGURE_ARGS+=    --enable-supermatrix
.else
CONFIGURE_ARGS+=    --disable-supermatrix
.endif

.if !(defined(USE_GCC) || !empty(CC:M*gcc4*))
CONFIGURE_ARGS+=    --disable-autodetect-f77-ldflags \
            --disable-autodetect-f77-name-mangling
.endif

.if !empty(MACHINE_CPU:Msse3)
CFLAGS+=        -msse3
LDFLAGS+=       -msse3
CONFIGURE_ARGS+=    --enable-vector-intrinsics=sse
.else
CONFIGURE_ARGS+=    --enable-vector-intrinsics=none
.endif

.if ${ARCH} == "sparc64"
PICFLAG?=   -fPIC
.else
PICFLAG?=   -fpic
.endif
CFLAGS+=    ${PICFLAG}
LDFLAGS+=   ${PICFLAG} -Wl,-x

.if defined(MEMORY_ALIGNMENT)
CONFIGURE_ARGS+=    --enable-memory-alignment=${MEMORY_ALIGNMENT}
.if defined(LDIM_ALIGNMENT)
CONFIGURE_ARGS+=    --enable-ldim-alignment
.endif
.endif

.if ${PORT_OPTIONS:MDOCS}
PORTDOCS=   libflame.pdf
.endif

.if ${PORT_OPTIONS:MEXAMPLES}
PORTEXAMPLES=   *
.endif

SHLIB_MAJOR?=   0

post-patch:
    @${FIND} ${WRKSRC} -type f \( -name '*.sh' -o -name '*.sh.in' \) | \
    ${XARGS} ${REINPLACE_CMD} -E \
    -e 's@(#!)(/bin/bash)@\1${LOCALBASE}\2@'
    @${FIND} ${WRKSRC} -type f \( -name 'makefile' -o -name 'config.mk.in' \) | \
    ${XARGS} ${REINPLACE_CMD} \
    -e 's@-fPIC@${PICFLAG}@g'
    @${REINPLACE_CMD} \
    -e '\@MK_INCL_DIR_INST_W_ARCH_VERS[[:blank:]]*:=@ \
    s@-$$(ARCH_VERS)@/libflame@' \
    -e '\@MK_FLAMEC_...S_INST_W_ARCH_VERS[[:blank:]]*:=@ \
    {N; s@-$$(ARCH_VERS)@@; s@\.so@&.${SHLIB_MAJOR}@2;}' \
    -e '\@^$$(MK_INCL_DIR_INST):@,\@^endif@d' \
    -e '\@^$$(INSTALL_PREFIX)/lib/%\.a:@,\@^endif@d' \
    -e 's@^\($$(INSTALL_PREFIX)/lib/%\)\(-$$(ARCH_VERS)\)\(\.a:\)@\1\3@' \
    -e '\@^$$(INSTALL_PREFIX)/lib/%.*\.so:@ \
    s@\(-$$(ARCH_VERS)\)\(\.so\)@\2.${SHLIB_MAJOR}@' \
        ${WRKSRC}/Makefile
    @${REINPLACE_CMD} -e 's@gcc)@cc|gcc*)@g' \
        ${WRKSRC}/configure
    @${REINPLACE_CMD} \
    -e '\@FLA_LIB_PATH[[:blank:]]*:=@ \
    s@$$(INSTALL_PREFIX)/lib@../lib/$$(HOST)@' \
    -e '\@FLA_INC_PATH[[:blank:]]*:=@ \
    s@$$(INSTALL_PREFIX)@${WRKDIR}@' \
    -e '\@HOST[[:blank:]]*:=@ \
    s@sh $$(BUILD_DIRPATH)/ac-utils/config.guess@cat ../config.sys_type@' \
        ${WRKSRC}/test/Makefile

pre-configure:
    @${FIND} ${WRKSRC} -type f \( -name '*.bak' -o -name '*.fbsd10bak' \
    -o -name '*.orig' \) -delete

post-configure:
.if ${PORT_OPTIONS:MSTATIC}
    @${CP} -af ${WRKSRC} ${WRKSRC}_STATIC
    @${REINPLACE_CMD} -e 's@${PICFLAG}@@' \
    -e '\@FLA_ENABLE_DYNAMIC_BUILD[[:blank:]]*:=@s@yes@no@' \
        ${WRKSRC}_STATIC/config/*/config.mk
.endif
.if ${PORT_OPTIONS:MSHARED}
    @${REINPLACE_CMD} \
    -e '\@MK_FLAMEC_LIBS_INST.*[[:blank:]]*:=@ \
    {N; s@$$(INSTALL_PREFIX)/lib/%@&_pic@;}' \
    -e '\@^$$(INSTALL_PREFIX)/lib/%\.a:@s@%@&_pic@1' \
        ${WRKSRC}/Makefile
.endif

do-build:
.for o in SHARED STATIC
.if ${PORT_OPTIONS:M${o}}
    @${PRINTF} "\n\n\n===> Building ${o:tl} library:\n\n\n\n"
    @cd ${WRKSRC}${o:S|^|_|:M*STATIC}; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} \
    ${_MAKE_JOBS} ${MAKE_ARGS} libs
.endif
.endfor

do-install:
    @cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${_MAKE_JOBS} \
    ${MAKE_ARGS} install-headers
.if ${PORT_OPTIONS:MSHARED}
    @cd ${WRKSRC}/lib; ${STRIP_CMD} */libflame.so
    @cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${_MAKE_JOBS} \
    ${MAKE_ARGS} install-libs install-lib-symlinks
.endif
.if ${PORT_OPTIONS:MSTATIC}
    @cd ${WRKSRC}_STATIC; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${_MAKE_JOBS} \
    ${MAKE_ARGS} install-libs
.endif
.if ${PORT_OPTIONS:MDOCS}
    @${MKDIR} ${STAGEDIR}${DOCSDIR}
    @${INSTALL_DATA} ${DISTDIR}/${DIST_SUBDIR}/${PORTDOCS} ${STAGEDIR}${DOCSDIR}
.endif
.if ${PORT_OPTIONS:MEXAMPLES}
    @${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
    @cd ${WRKSRC}/examples; ${COPYTREE_SHARE} \* ${STAGEDIR}${EXAMPLESDIR}
.endif

.if defined(MAINTAINER_MODE)
BUILD_DEPENDS +=    ${RUN_DEPENDS}
CONFIGURE_ARGS+=    --enable-verbose-make-output

check regression-test test: build
    @cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${_MAKE_JOBS} \
    ${MAKE_ARGS} MK_INCL_DIR_INST_W_ARCH_VERS="${WRKDIR}/include" \
    install-headers
.for o in SHARED STATIC
.if ${PORT_OPTIONS:M${o}}
    @${PRINTF} "\n\n\n===> Testing ${o:tl} library:\n\n\n\n"
    @cd ${WRKSRC}${o:S|^|_|:M*STATIC}/test;  ${SETENV} ${MAKE_ENV} \
    ${MAKE_CMD} ${_MAKE_JOBS} ${MAKE_ARGS} \
    LIBBLAS="-L${LOCALBASE}/lib ${BLAS} -lm" \
    LIBLAPACK="-L${LOCALBASE}/lib ${LAPACK}" test_libflame ; \
    ./test_libflame.x
.endif
.endfor

.endif #MAINTAINER_MODE
.include <bsd.port.mk>