aboutsummaryrefslogtreecommitdiffstats
path: root/math/atlas-devel/Makefile
blob: ae34482371b984d89b0efcbecca467cbd70a268e (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
# New ports collection makefile for:    atlas-devel
# Date created:     14 September 2003
# Whom:         Nakata Maho <maho@FreeBSD.org>
#
# $FreeBSD$
#

# NOTE: This port purposely ignores the CC and CFLAGS settings.
#       Program and compiler flags are finetuned to gcc.

PORTNAME=   atlas
PORTVERSION=    3.7.34
CATEGORIES= math
MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= math-atlas
PKGNAMESUFFIX=  -devel
DISTNAME=   ${PORTNAME}${PORTVERSION}

MAINTAINER= maho@FreeBSD.org
COMMENT=    Development version of math/atlas

NO_PACKAGE= Optimizes for the local machine, so a package is not generally useful.  Set FORCE_PACKAGE to override

USE_BZIP2=  yes
USE_GMAKE=  yes
WRKSRC=     ${WRKDIR}/ATLAS
USE_LDCONFIG=   yes

.include <bsd.port.pre.mk>

NOT_FOR_ARCHS=  alpha

USE_FORTRAN=    yes
CCOMPILER=  ${CC}
LIB_DEPENDS+=   blas.2:${PORTSDIR}/math/blas
LIB_DEPENDS+=   lapack.4:${PORTSDIR}/math/lapack
LIB_DEPENDS+=   f2c:${PORTSDIR}/lang/f2c

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

# only affects for lapack sub project
.if defined(WITH_OPTIMIZED_FLAGS)
.if defined(CPUTYPE)
FFLAGS+=    -mtune=${CPUTYPE} -pipe -O2 -ffast-math
.else
FFLAGS+=    -pipe -O2 -ffast-math
.endif
.endif
.if defined(WITH_STATICLIB)
PLIST_SUB+= WITH_STATICLIB=""
.else
PLIST_SUB+= WITH_STATICLIB="@comment "
.endif

post-extract:
.if !defined(WITH_STATICLIB)
    @${ECHO_MSG} "You can build static libraries with"
    @${ECHO_MSG} "make -DWITH_STATICLIB"
    @${ECHO_MSG}
.endif

pre-configure:
    @${REINPLACE_CMD} -e "s|%%CC%%|${CCOMPILER}|g" \
        -e "s|%%FC%%|${FC}|g"  ${WRKSRC}/CONFIG/src/atlcomp.txt
    @${REINPLACE_CMD} -e "s|%%PTHREAD_LIBS%%|${PTHREAD_LIBS}|g" \
              -e "s|%%PTHREAD_LIBS%%|${PTHREAD_CFLAGS}|g" \
              -e "s|%%LOCALBASE%%|${LOCALBASE}|g" \
        ${WRKSRC}/CONFIG/src/SpewMakeInc.c

do-configure:
#non threaded
#dummy f77lib, it is not used.
    ${MKDIR} ${WRKSRC}/NON_THREADED ; cd ${WRKSRC}/NON_THREADED ; \
        ../configure -t 0 -Si cputhrchk 0 -Ss f77lib " "
    ${MKDIR} ${WRKSRC}/NON_THREADED_PIC ; cd ${WRKSRC}/NON_THREADED_PIC ; \
        ../configure -t 0 -Fag al '${PICFLAG} -DPIC' -Si cputhrchk 0 -Ss f77lib " "
#threaded
#dummy f77lib, it is not used.
    cd ${WRKSRC}; ${PATCH} < ${FILESDIR}/thread-patch
    ${MKDIR} ${WRKSRC}/THREADED ; cd ${WRKSRC}/THREADED ; \
        ../configure -Fag al '${PTHREAD_CFLAGS} ' -Si cputhrchk 0 -Ss f77lib " "
    ${MKDIR} ${WRKSRC}/THREADED_PIC ; cd ${WRKSRC}/THREADED_PIC ; \
        ../configure -Fag al '${PTHREAD_CFLAGS} ${PICFLAG} -DPIC' -Si cputhrchk 0 -Ss f77lib " "

do-build:
# make lapack
.if ! exists(${WRKDIR}/lapack/Makefile)
    @${ECHO_MSG} "===>  Extracting lapack sub project"
    @${MKDIR} ${WRKDIR}/lapack
    @${CP} -r ${PORTSDIR}/math/lapack/files ${WRKDIR}/lapack
    @${CP} -r ${PORTSDIR}/math/lapack/scripts ${WRKDIR}/lapack
    @${CP} ${PORTSDIR}/math/lapack/Makefile ${WRKDIR}/lapack
    @${CP} ${PORTSDIR}/math/lapack/distinfo ${WRKDIR}/lapack
    @${CP} ${PORTSDIR}/math/lapack/pkg-descr ${WRKDIR}/lapack
    @cd ${WRKDIR}/lapack ; ${MAKE} "FFLAGS=${FFLAGS}" FC="${FC}" build WRKDIRPREFIX=""
.endif
.if defined(WITH_STATICLIB)
    (cd ${WRKSRC}/NON_THREADED ; ${MAKE})
    (cd ${WRKSRC}/THREADED ; ${MAKE})
.endif
    (cd ${WRKSRC}/NON_THREADED_PIC ; ${MAKE})
    (cd ${WRKSRC}/THREADED_PIC ; ${MAKE})
    @${MAKE} test

ATLAS_LIBS1=libalapack libatlas libcblas libf77blas #libtstatlas
ATLAS_LIBS2=libptcblas libptf77blas

post-build:
.if defined(WITH_STATICLIB)
# make atlas enhanced lapack (static ver)
    (cd ${WRKSRC}; ${MKDIR} tmp1 ; \
        ${CP} ${WRKDIR}/lapack/work/LAPACK/SRC/liblapack.a tmp1 ;\
        cd tmp1 ;\
        ar x liblapack.a ;\
        ar x ../NON_THREADED/lib/liblapack.a ;\
        ar r ../NON_THREADED/lib/libalapack.a *.o ;\
        ranlib ../NON_THREADED/lib/libalapack.a )
#  make atlas enhanced lapack (static and thread safe ver)
    (cd ${WRKSRC}; ${MKDIR} tmp2 ; \
        ${CP} ${WRKDIR}/lapack/work/LAPACK/SRC/liblapack.a tmp2 ;\
        cd tmp2 ;\
        ar x liblapack.a ;\
        ar x ../THREADED/lib/liblapack.a ;\
        ar r ../THREADED/lib/libalapack.a *.o ;\
        ranlib ../THREADED/lib/libalapack.a )
.endif
# make atlas enhanced lapack (shared ver)
    ( cd ${WRKSRC}; ${MKDIR} tmp3 ;\
    ${TAR} --exclude "*.f" --exclude "*.po" --exclude "*.o" -cf - -C ${WRKDIR}/lapack/work/LAPACK/SRC . | ${TAR} xf - -C tmp3 ;\
        for object in `${FIND} tmp3 -name "*.So"` ; do \
            n=`${ECHO_CMD} $${object}|${SED} -e 's#.So##'` ; \
            ${MV} $$n.So $$n.o ; \
        done ; \
        cd tmp3 ;\
        ar x ../NON_THREADED_PIC/lib/liblapack.a ;\
        ar r ../NON_THREADED_PIC/lib/libalapack.a *.o ;\
        ranlib ../NON_THREADED_PIC/lib/libalapack.a )
# make atlas enhanced lapack (shared and thread safe ver)
    ( cd ${WRKSRC}; ${MKDIR} tmp4 ;\
    ${TAR} --exclude "*.f" --exclude "*.po" --exclude "*.o" -cf - -C ${WRKDIR}/lapack/work/LAPACK/SRC . | ${TAR} xf - -C tmp4 ;\
        for object in `${FIND} tmp4 -name "*.So"` ; do \
            n=`${ECHO_CMD} $${object}|${SED} -e 's#.So##'` ; \
            ${MV} $$n.So $$n.o ; \
        done ; \
        cd tmp4 ;\
        ar x ../THREADED_PIC/lib/liblapack.a ;\
        ar r ../THREADED_PIC/lib/libalapack.a *.o ;\
        ranlib ../THREADED_PIC/lib/libalapack.a )

# make atlas shared library
.for i in ${ATLAS_LIBS1}
    ( cd ${WRKSRC}/NON_THREADED_PIC/lib ; \
        ld -Bshareable -o ${i}.so.2 -x -soname ${i}.so.2 ${i}.a )
.endfor

# make atlas shared (thread safe) library
.for i in ${ATLAS_LIBS1}
    ( cd ${WRKSRC}/THREADED_PIC/lib ; \
        ld -Bshareable -o ${i}_r.so.2 -x -soname ${i}_r.so.2 ${i}.a )
.endfor
.for i in ${ATLAS_LIBS2}
    ( cd ${WRKSRC}/THREADED_PIC/lib ; \
        ld -Bshareable -o ${i}.so.2 -x -soname ${i}.so.2 ${i}.a )
.endfor
do-install:
.for i in ${ATLAS_LIBS1}
.if defined(WITH_STATICLIB)
    @${INSTALL_DATA} ${WRKSRC}/NON_THREADED/lib/${i}.a       ${PREFIX}/lib
.endif
    @${INSTALL_DATA} ${WRKSRC}/NON_THREADED_PIC/lib/${i}.so.2    ${PREFIX}/lib
    @${LN} -sf ${i}.so.2 ${PREFIX}/lib/${i}.so
.endfor
.for i in ${ATLAS_LIBS1}
.if defined(WITH_STATICLIB)
    @${INSTALL_DATA} ${WRKSRC}/THREADED/lib/${i}.a       ${PREFIX}/lib/${i}_r.a
.endif
    @${INSTALL_DATA} ${WRKSRC}/THREADED_PIC/lib/${i}_r.so.2    ${PREFIX}/lib/${i}_r.so.2
    @${LN} -sf ${i}_r.so.2 ${PREFIX}/lib/${i}_r.so
.endfor
.for i in ${ATLAS_LIBS2}
.if defined(WITH_STATICLIB)
    @${INSTALL_DATA} ${WRKSRC}/THREADED/lib/${i}.a       ${PREFIX}/lib
.endif
    @${INSTALL_DATA} ${WRKSRC}/THREADED_PIC/lib/${i}.so.2    ${PREFIX}/lib
    @${LN} -sf ${i}.so.2 ${PREFIX}/lib/${i}.so
.endfor

    @${INSTALL_DATA} ${WRKSRC}/include/cblas.h   ${PREFIX}/include
    @${INSTALL_DATA} ${WRKSRC}/include/clapack.h ${PREFIX}/include
    @${INSTALL_DATA} ${FILESDIR}/blas.h    ${PREFIX}/include
    @${INSTALL_DATA} ${FILESDIR}/lapack.h  ${PREFIX}/include
.if !defined(NOPORTDOCS)
    @${MKDIR} ${DOCSDIR}
    ${INSTALL_DATA} ${WRKSRC}/doc/* ${DOCSDIR}
.endif
    ${MKDIR} ${EXAMPLESDIR}
    @for i in ${ALLTESTS} ; do \
    cd ${WRKDIR}/ATLAS/NON_THREADED_PIC/bin ; ${INSTALL_PROGRAM} $${i} ${EXAMPLESDIR} ; \
    done
    @for i in ${ALLTESTS_PT} ; do \
    cd ${WRKDIR}/ATLAS/THREADED_PIC/bin ; ${INSTALL_PROGRAM} $${i} ${EXAMPLESDIR} ; \
    done

.include <${FILESDIR}/Makefile.test>
.include <bsd.port.post.mk>