aboutsummaryrefslogtreecommitdiffstats
path: root/math/gotoblas/Makefile
blob: 8082fad140172755dc0958f7e7ed0257ad62b1af (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
# Created by: Sato Hiroki <hrs@FreeBSD.org>
# $FreeBSD$

PORTNAME=   gotoblas
PORTVERSION=    2.${GOTOBLAS2VER}.${LAPACKVER}
PORTREVISION=   9
CATEGORIES= math
MASTER_SITES=   LOCAL/maho/gotoblas \
        NL/lapack:lapack NL/lapack/timing:lapack_tmg
DISTFILES=  GotoBLAS2-${GOTOBLAS2VER}_bsd.tar.gz \
        lapack-${LAPACKVER}.tgz:lapack \
        large.tgz:lapack_tmg timing.tgz:lapack_tmg
DIST_SUBDIR=    gotoblas
EXTRACT_ONLY=   ${GOTOBLAS2_SRCFILE}

MAINTAINER= ports@FreeBSD.org
COMMENT=    Fast implementation of Basic Linear Algebra Subprograms

LICENSE=    BSD2CLAUSE
LICENSE_FILE=   ${WRKSRC}/00License.txt

BROKEN_aarch64=     does not build: undefined reference to get_libname
BROKEN_armv6=       does not build: undefined reference to get_libname
BROKEN_powerpc64=   does not build: error: macro names must be identifiers
BROKEN_i386=        does not build (terminates with SIGBUS)

GOTOBLAS2VER=   1.13
GOTOBLAS2_SRCFILE=  GotoBLAS2-${GOTOBLAS2VER}_bsd.tar.gz
LAPACKVER=  3.4.0
LAPACK_SRCFILE= lapack-${LAPACKVER}.tgz
LARGE_FILE= large.tgz
TIMING_FILE=    timing.tgz
USE_LDCONFIG=   yes
WRKSRC=     ${WRKDIR}/GotoBLAS2

USES=       fortran gmake perl5
USE_GCC=    yes
USE_PERL5=  build
GOTOLIBS=   libgoto2 libgoto2p
GOTOFILES=  ${GOTOLIBS:S|$|.so|} ${GOTOLIBS:S|$|.so.1|} ${GOTOLIBS:S|$|.a|}
PLIST_FILES=    ${GOTOFILES:S|^|lib/|}
SUB_FILES=  pkg-message
SUB_LIST=   MAXTHREADS=${MAXTHREADS}
MAKE_JOBS_UNSAFE=   yes

OPTIONS_DEFINE_i386=    DYNAMIC_ARCH
OPTIONS_DEFINE_amd64=   DYNAMIC_ARCH
OPTIONS_DEFINE= INTERFACE64 OPENMP

OPTIONS_DEFAULT_i386=   DYNAMIC_ARCH
OPTIONS_DEFAULT_amd64=  DYNAMIC_ARCH

DYNAMIC_ARCH_DESC=  Support multiple CPU types on i386 and amd64
INTERFACE64_DESC=   Use 8 byte integers on 64-bit architectures
OPENMP_DESC=        Use OpenMP for threading
#QUAD_PRECISION=    Support IEEE quad precision (experimental)

.include <bsd.port.options.mk>

MAXTHREADS?=    8

.if ${ARCH:M*64} == ""
GOTOFLAGS+= BINARY32=1
.else
GOTOFLAGS+= BINARY64=1
.endif

.if ${PORT_OPTIONS:MDYNAMIC_ARCH}
GOTOFLAGS+= DYNAMIC_ARCH=1
.endif

.if ${PORT_OPTIONS:MINTERFACE64}
GOTOFLAGS+= INTERFACE64=1
.endif

.if ${PORT_OPTIONS:MOPENMP}
GOTOFLAGS+= USE_OPENMP=1
.endif

#.if ${PORT_OPTIONS:MQUAD_PRECISION}
#BROKEN=    WITH_QUAD_PRECISION is broken; please disable this option
#GOTOFLAGS+=    QUAD_PRECISION=1
#.endif

post-extract:
    ${FIND} ${WRKSRC} -type f -name '.*' -delete
    cd ${DISTDIR}/${DIST_SUBDIR} ; \
    ${CP} ${LAPACK_SRCFILE} ${LARGE_FILE} ${TIMING_FILE} ${WRKSRC}
    ${MKDIR} ${STAGEDIR}${PREFIX}/lib

post-patch:
    ${REINPLACE_CMD} -e "s+%%FC%%+${FC}+" -e "s+%%CC%%+${CC}+" \
        ${WRKSRC}/Makefile.rule
    ${REINPLACE_CMD} -e "s+%%LAPACKVER%%+${LAPACKVER}+g" \
        ${WRKSRC}/Makefile
    ${REINPLACE_CMD} -e "s+%%LAPACKVER%%+${LAPACKVER}+g" \
        ${WRKSRC}/exports/gensymbol
    ${REINPLACE_CMD} -e "s+(ARCH)+(ARCH_)+" \
        ${WRKSRC}/Makefile.rule \
        ${WRKSRC}/Makefile.tail \
        ${WRKSRC}/driver/level3/Makefile \
        ${WRKSRC}/driver/others/Makefile \
        ${WRKSRC}/exports/Makefile \
        ${WRKSRC}/interface/Makefile \
        ${WRKSRC}/kernel/Makefile \
        ${WRKSRC}/kernel/Makefile.L3 \
        ${WRKSRC}/lapack/laswp/Makefile \
        ${WRKSRC}/reference/Makefile
    ${REINPLACE_CMD} -e "s+(ARCH)+(ARCH_)+" \
    -e 's+%%_GCC_RUNTIME%%+${_GCC_RUNTIME}+' \
    -e 's+$$(CROSS_SUFFIX)+${LOCALBASE}/bin/+' \
        ${WRKSRC}/Makefile.system

.if ${PORT_OPTIONS:MOPENMP}
    ${REINPLACE_CMD} -e "s+GOTO_NUM_THREADS+OMP_NUM_THREADS+g" \
        ${WRKSRC}/test/Makefile \
        ${WRKSRC}/ctest/Makefile
.endif

do-build:
    cd ${WRKSRC} ; ${SETENV} ${GOTOFLAGS} NUM_THREADS=1 USE_THREAD=0 \
    ${MAKE_CMD} ${MAKE_ARGS}
    ${CP} ${WRKSRC}/libgoto2.a ${STAGEDIR}${PREFIX}/lib/libgoto2.a
    ${CP} ${WRKSRC}/libgoto2.so ${STAGEDIR}${PREFIX}/lib/libgoto2.so.1
    cd ${WRKSRC} ; ${MAKE_CMD} ${MAKE_ARGS} clean
    cd ${WRKSRC} ; ${SETENV} ${GOTOFLAGS} NUM_THREADS=${MAXTHREADS} \
    USE_THREAD=1 ${MAKE_CMD} ${MAKE_ARGS}
    ${CP} ${WRKSRC}/libgoto2.a ${STAGEDIR}${PREFIX}/lib/libgoto2p.a
    ${CP} ${WRKSRC}/libgoto2.so ${STAGEDIR}${PREFIX}/lib/libgoto2p.so.1
    ${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/*.so.1

BENCHMARK_MAXTHREADS?=  ${MAXTHREADS}
.if ${PORT_OPTIONS:MOPENMP}
BENCHMARK_THREADS_FLAG=     OMP_NUM_THREADS=${BENCHMARK_MAXTHREADS}
.else
BENCHMARK_THREADS_FLAG=     GOTO_NUM_THREADS=${BENCHMARK_MAXTHREADS}
.endif

benchmark: build
    cd ${WRKSRC} ; ${SETENV} ${GOTOFLAGS} NUM_THREADS=${MAXTHREADS} \
    USE_THREAD=1 ${MAKE_CMD} ${MAKE_ARGS} hpl
    cd ${WRKSRC}/benchmark ; ${SETENV} ${GOTOFLAGS} NUM_THREADS=${MAXTHREADS} \
    USE_THREAD=1 ${BENCHMARK_THREADS_FLAG} ${MAKE_CMD} ${MAKE_ARGS}

do-install:
    cd ${STAGEDIR}${PREFIX}/lib ; \
    ${INSTALL_DATA} ${GOTOLIBS:S|$|.a|} ${GOTOLIBS:S|$|.so.1|} \
    ${STAGEDIR}${PREFIX}/lib/
    cd ${STAGEDIR}${PREFIX}/lib ; \
    for i in ${GOTOLIBS:S|$|.so|}; do \
        ${LN} -sf $$i.1 $$i ; \
    done

.include <bsd.port.mk>