aboutsummaryrefslogtreecommitdiffstats
path: root/math/xblas/Makefile
blob: 5ccd37a5a470f3f30e6d1d576437f6b572c51dd2 (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
# ex:ts=8
# Ports collection makefile for:    xblas
# Date created:         5 January 2012
# Whom:             bf@FreeBSD.org
#
# $FreeBSD$
#

PORTNAME=   xblas
PORTVERSION=    1.0.248
CATEGORIES= math
MASTER_SITES=   NL/xblas LOCAL/bf
DISTNAME=   xblas

MAINTAINER= bf@FreeBSD.org
COMMENT=    Extra Precise Basic Linear Algebra Subroutines (BLAS)

LICENSE=    BSD

USE_LDCONFIG=   yes

CFLAGS+=    ${MANGLING}
HDIR=       include/xblas
HEADERS=    blas_dense_proto.h blas_enum.h blas_extended.h \
        blas_extended_private.h blas_extended_proto.h blas_fpu.h \
        blas_malloc.h f2c-bridge.h
MAKE_ENV=   EXTRA_LIBS="-lm" LINKER="${CC}" M4="${M4}" RANLIB="${RANLIB}"
OPTIONS=    SHARED "Build a shared library and PIC archive" on \
        STATIC "Build a non-PIC archive" off
PLIST_DIRS= ${HDIR}
PLIST_FILES=    ${HEADERS:S|^|${HDIR}/|}
SHLIB_MAJOR=    0
WRKSRC =    ${WRKDIR}/xblas-${PORTVERSION}

.include <bsd.port.options.mk>

M4?=    m4
M4_OPTS?=   #empty
MANGLING?=  -DCONFIG_FC_UNDERSCORE

.if ${ARCH} == "i386" || ${ARCH} == "amd64"
CFLAGS+=    -Dx86
.endif

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

.ifndef(NOPORTDOCS)
PORTDOCS=   report.ps
.endif

.ifdef(WITH_SHARED)
PLIST_FILES+=   lib/libxblas_pic.a lib/libxblas.so lib/libxblas.so.${SHLIB_MAJOR}
.endif

.ifdef(WITH_STATIC)
PLIST_FILES+=   lib/libxblas.a
.endif

post-patch:
    @${REINPLACE_CMD} -E \
    -e '/(ARCH|CC|(C|LD)FLAGS|EXTRA_LIBS|M4|M4_OPTS|RANLIB|XBLASLIB)[[:blank:]]*=/d' \
        ${WRKSRC}/make.inc
.ifdef(WITH_STATIC)
    @${CP} -af ${WRKSRC} ${WRKSRC}_STATIC
.endif
    @${PRINTF} "\nCFLAGS+=\t${PICFLAG}\n" >> ${WRKSRC}/make.inc

do-build: build-shared build-static

build-shared: patch
.ifdef(WITH_SHARED)
    @cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} XBLASLIB="libxblas_pic.a" ${MAKE} \
    ${_MAKE_JOBS} ${MAKE_ARGS} ARCH="${AR}" lib ; \
    ${CC} ${CFLAGS} ${PICFLAG} ${LDFLAGS} -shared -Wl,-x \
    -Wl,-soname,libxblas.so.${SHLIB_MAJOR} -o libxblas.so.${SHLIB_MAJOR} \
    -Wl,--whole-archive libxblas_pic.a -Wl,--no-whole-archive -Wl,--as-needed -lm
.endif

build-static: patch
.ifdef(WITH_STATIC)
    @cd ${WRKSRC}_STATIC; ${SETENV} ${MAKE_ENV} XBLASLIB="libxblas.a" ${MAKE} \
    ${_MAKE_JOBS} ${MAKE_ARGS} ARCH="${AR}" lib
.endif

do-install:
    @${MKDIR} ${PREFIX}/${HDIR}
    @cd ${WRKSRC}/src; ${INSTALL_DATA} ${HEADERS} ${PREFIX}/${HDIR}
.ifdef(WITH_SHARED)
    @cd ${WRKSRC}; ${INSTALL_DATA} libxblas_pic.a \
    libxblas.so.${SHLIB_MAJOR} ${PREFIX}/lib
    @${LN} -sf libxblas.so.${SHLIB_MAJOR} ${PREFIX}/lib/libxblas.so
.endif
.ifdef(WITH_STATIC)
    @${INSTALL_DATA} ${WRKSRC}_STATIC/libxblas.a ${PREFIX}/lib
.endif
.ifndef(NOPORTDOCS)
    @${MKDIR} ${DOCSDIR}
    @${INSTALL_DATA} ${WRKSRC}/doc/report.ps ${DOCSDIR}
.endif

check regression-test test: test-shared test-static

test-shared: build
.ifdef(WITH_SHARED)
    @cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} XBLASLIB="libxblas_pic.a" ${MAKE} \
    ${_MAKE_JOBS} ${MAKE_ARGS} ARCH="${AR}" tests
.endif

test-static: build
.ifdef(WITH_STATIC)
    @cd ${WRKSRC}_STATIC; ${SETENV} ${MAKE_ENV} XBLASLIB="libxblas.a" ${MAKE} \
    ${_MAKE_JOBS} ${MAKE_ARGS} ARCH="${AR}" tests
.endif

.include <bsd.port.mk>