Ticket #18173: Portfile.2

File Portfile.2, 6.3 KB (added by jameskyle@…, 15 years ago)

Updated to include lapack 3.2.1

Line 
1# $Id: Portfile 38455 2008-07-21 14:30:08Z jmr@macports.org $
2
3PortSystem          1.0
4
5categories          math
6name                atlas
7version             3.8.2
8
9# additional versions
10set lapackversion   3.2.1
11set lapackname      lapack
12set atlasdist       ${name}${version}.tar.bz2
13set lapackdist      ${lapackname}.tgz
14
15maintainers         cornell.edu:ajb78
16platforms           darwin
17
18description         Portable optimal linear algebra software
19long_description    The current version provides a complete BLAS and LAPACK API.\
20                    For many operations, ATLAS achieves performance on par with\
21                    machine-specific tuned libraries.
22
23homepage            http://math-atlas.sourceforge.net/
24
25master_sites        sourceforge:math-atlas/${name}${version}.tar.bz2:atlas \
26                    http://www.netlib.org/lapack:lapack
27
28distfiles           ${atlasdist}:atlas \
29                    ${lapackdist}:lapack
30
31checksums           atlas3.8.2.tar.bz2 \
32                    md5     dd888f5d066c1fafeaaf2ae6b37e0b85 \
33                    sha1    2d1f2f789f57c9e7e8957f275b67c33176a36e0c \
34                    rmd160  8160ccb3af7cd7365ba87c77d636fb68b24c62ae \
35                    lapack.tgz \
36                    md5     a3202a4f9e2f15ffd05d15dab4ac7857 \
37                    sha1    c75223fdef3258c461370af5d2b889d580d7f38a \
38                    rmd160  e8fabba2fdd944afbc02a83599cf45a0d721030d
39
40# The following patch corrects an error in which Core 2 duos and Xeons
41# are mistakenly identified as PIII cpu's
42patchfiles          patch-CONFIG-src-backend-archinf_x86.c.diff
43set make_patch      patch-build-Make.top.diff
44use_parallel_build  no
45build.target build
46build.dir           ${workpath}/${name}-${version}/build
47
48destroot.dir        ${build.dir}
49destroot.destdir    DESTDIR=${destroot}${prefix}
50depends_lib         port:gcc43
51
52# Set fortran compiler flags
53set myf77           ${prefix}/bin/gfortran-mp-4.3
54
55configure.args      -C xc ${prefix}/bin/gcc-mp-4.3 \
56                    -C gc ${prefix}/bin/gcc-mp-4.3 \
57                    -C if ${myf77} \
58                    -C ic ${prefix}/bin/gcc-mp-4.3 \
59                    -C dm ${prefix}/bin/gcc-mp-4.3 \
60                    -C sm ${prefix}/bin/gcc-mp-4.3 \
61                    -C dk ${prefix}/bin/gcc-mp-4.3 \
62                    -C sk ${prefix}/bin/gcc-mp-4.3 \
63                    -b 32 \
64                    -Fa alg -fPIC
65
66       
67
68# we are configuring from the build directory
69configure.dir       ${workpath}/${name}-${version}/build
70configure.cmd       ../configure
71
72# change the default compilers to those of gcc43 and make into shared library
73
74extract {
75    # extract atlas and move to a consistent working directory name
76    system "cd ${workpath} && bunzip2 -dc ${distpath}/${atlasdist} | \
77         gnutar --no-same-owner -xf -"
78    system "mv ${workpath}/ATLAS ${workpath}/${name}-${version}"
79
80    # extract lapack
81    system "cd ${workpath} && gunzip -dc ${distpath}/${lapackdist} | \
82         gnutar --no-same-owner -xf -"
83}
84
85
86
87pre-configure {
88    # Get some system specific variables for maximum optimization
89    set cpufreq [expr {[exec sysctl -n hw.cpufrequency]/1000000}]
90    ui_debug "Setting CPU Frequency for: ${cpufreq}"
91    configure.args-append -D c -DPentiumCPS=${cpufreq}
92
93    # first do a 'fack configure' of atlas so we get optimized lapack libraries
94    # atlas docs: 3.1.2
95    set atlas_path ${workpath}/${name}-${version}
96    file mkdir ${workpath}/${name}-${version}/temp
97    system "cd ${atlas_path}/temp && \
98            ${configure.cmd} ${configure.args}"
99   
100    # Get the F77FLAGS
101    set atlas_f77    [join [lrange [split [exec grep "F77 = " $atlas_path/temp/Make.inc     ] =] 1 end] =]
102    ui_debug "Found atlas F77: ${atlas_f77}"
103   
104    set atlas_fflags [join [lrange [split [exec grep "F77FLAGS = " $atlas_path/temp/Make.inc] =] 1 end] =]
105    ui_debug "Found atlas F77FLAGS: ${atlas_fflags}"
106    # Remove the old test configure directory
107    system "rm -rf ${atlas_path}/temp"
108   
109    # compile lapack
110    system "cd ${workpath}/${lapackname}-${lapackversion} && \
111            cp INSTALL/make.inc.gfortran make.inc"
112    reinplace "s|gfortran|${atlas_f77}|" \
113           ${workpath}/${lapackname}-${lapackversion}/make.inc
114    reinplace "s|OPTS     = -O2|OPTS = ${atlas_fflags}|" \
115           ${workpath}/${lapackname}-${lapackversion}/make.inc
116   
117    reinplace "s|NOOPT    = -O0|NOOPT = -O2 -m32|" \
118           ${workpath}/${lapackname}-${lapackversion}/make.inc
119
120    reinplace "s|PLAT = _LINUX|PLAT = _darwin|" \
121           ${workpath}/${lapackname}-${lapackversion}/make.inc
122   
123    reinplace "s|LOADOPTS =|LOADOPTS = ${atlas_fflags}|" \
124           ${workpath}/${lapackname}-${lapackversion}/make.inc
125   
126    system "cd ${workpath}/${lapackname}-${lapackversion} && make lib"
127
128    # create a build directory for atlas
129    file mkdir ${workpath}/${name}-${version}/build
130
131
132    configure.args-append --with-netlib-lapack=${workpath}/${lapackname}-${lapackversion}/lapack_darwin.a
133}
134
135post-configure {
136    # recursively remove directories
137    reinplace "s|rm -f|rm -rf|g" ${workpath}/${name}-${version}/build/Makefile
138
139    # patch ${name}-${version}/build/Make.top to install dynamic libs
140    system "cd ${worksrcpath}/build/ && \
141            patch -p0 < ${filespath}/${make_patch}"
142}
143
144pre-destroot {
145  # We have to manually create the dylib shared libs as the default build does not do this
146  set ld "ld -dynamic -arch i386 -dylib -single_module -dead_strip -x \
147          -all_load -L. -L${prefix}/lib/gcc43 -ldylib1.o -dylib_install_name"
148 
149  system "cd ${workpath}/${name}-${version}/build/lib && \
150          ${ld} libatlas.dylib libatlas.a -o libatlas.dylib -lSystem"
151 
152  system "cd ${workpath}/${name}-${version}/build/lib && \
153          ${ld} libptcblas.dylib libptcblas.a -o libptcblas.dylib -latlas -lSystem"
154 
155  system "cd ${workpath}/${name}-${version}/build/lib && \
156          ${ld} libptf77blas.dylib libptf77blas.a -o libptf77blas.dylib -lgfortran \
157          -latlas -lSystem"
158
159  system "cd ${workpath}/${name}-${version}/build/lib && \
160          ${ld} liblapack.dylib liblapack.a -o liblapack.dylib -lptf77blas \
161          -lgfortran -lptcblas -latlas -lgcc_s.1 -lSystem"
162
163}
164
165post-destroot {
166  # we make soft links to the parallel built libs
167  system "cd ${destroot}${prefix}/lib && \
168          ln -sf ./libptcblas.dylib libcblas.dylib && \
169          ln -sf ./libptf77blas.dylib libf77blas.dylib"
170}