Ticket #18173: Portfile

File Portfile, 6.8 KB (added by krunk7@…, 16 years ago)

Portfile

Line 
1# $Id: Portfile 38455 2008-07-21 14:30:08Z jmr@macports.org $
2# vim: set syn=tcl:
3PortSystem          1.0
4
5categories          math
6name                atlas
7version             3.8.2
8
9# additional versions
10set lapackversion   3.2
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           ${atlasdist} \
32                    md5 dd888f5d066c1fafeaaf2ae6b37e0b85 \
33                    sha1 2d1f2f789f57c9e7e8957f275b67c33176a36e0c \
34                    rmd160 8160ccb3af7cd7365ba87c77d636fb68b24c62ae \
35                    ${lapackdist} \
36                    md5 db2e9b01bd157b65440f8306c0ba5446 \
37                    sha1 398900bb2537f02578e5419c9d2e3580d705d2cc \
38                    rmd160 5ceea89d61e9738ac970875f794b7f5e7897e176
39# The following patch corrects an error in which Core 2 duos and Xeons
40# are mistakenly identified as PIII cpu's
41patchfiles          patch-CONFIG-src-backend-archinf_x86.c.diff
42set make_patch      patch-build-Make.top.diff
43use_parallel_build  no
44build.target build
45build.dir           ${workpath}/${name}-${version}/build
46
47destroot.dir        ${build.dir}
48destroot.destdir    DESTDIR=${destroot}${prefix}
49depends_lib         port:gcc43
50
51# Set fortran compiler flags
52set myf77           ${prefix}/bin/gfortran-mp-4.3
53
54configure.args      -C xc ${prefix}/bin/gcc-mp-4.3 \
55                    -C gc ${prefix}/bin/gcc-mp-4.3 \
56                    -C if ${myf77} \
57                    -C ic ${prefix}/bin/gcc-mp-4.3 \
58                    -C dm ${prefix}/bin/gcc-mp-4.3 \
59                    -C sm ${prefix}/bin/gcc-mp-4.3 \
60                    -C dk ${prefix}/bin/gcc-mp-4.3 \
61                    -C sk ${prefix}/bin/gcc-mp-4.3 \
62                    -b 32 \
63                    -Fa alg -fPIC
64
65       
66
67# we are configuring from the build directory
68configure.dir       ${workpath}/${name}-${version}/build
69configure.cmd       ../configure
70
71# change the default compilers to those of gcc43 and make into shared library
72
73extract {
74    # extract atlas and move to a consistent working directory name
75    system "cd ${workpath} && bunzip2 -dc ${distpath}/${atlasdist} | \
76         gnutar --no-same-owner -xf -"
77    system "mv ${workpath}/ATLAS ${workpath}/${name}-${version}"
78
79    # extract lapack
80    system "cd ${workpath} && gunzip -dc ${distpath}/${lapackdist} | \
81         gnutar --no-same-owner -xf -"
82}
83
84
85
86pre-configure {
87    # Get some system specific variables for maximum optimization
88    set cpufreq [expr {[exec sysctl -n hw.cpufrequency]/1000000}]
89    ui_debug "Setting CPU Frequency for: ${cpufreq}"
90    configure.args-append -D c -DPentiumCPS=${cpufreq}
91
92    # first do a 'fack configure' of atlas so we get optimized lapack libraries
93    # atlas docs: 3.1.2
94    set atlas_path ${workpath}/${name}-${version}
95    file mkdir ${workpath}/${name}-${version}/temp
96    system "cd ${atlas_path}/temp && \
97            ${configure.cmd} ${configure.args}"
98   
99    # Get the F77FLAGS
100    set atlas_f77    [join [lrange [split [exec grep "F77 = " $atlas_path/temp/Make.inc     ] =] 1 end] =]
101    ui_debug "Found atlas F77: ${atlas_f77}"
102   
103    set atlas_fflags [join [lrange [split [exec grep "F77FLAGS = " $atlas_path/temp/Make.inc] =] 1 end] =]
104    ui_debug "Found atlas F77FLAGS: ${atlas_fflags}"
105    # Remove the old test configure directory
106    system "rm -rf ${atlas_path}/temp"
107   
108    # compile lapack
109    system "cd ${workpath}/${lapackname}-${lapackversion} && \
110            cp INSTALL/make.inc.gfortran make.inc"
111   
112    reinplace "s|gfortran|${atlas_f77}|" \
113           ${workpath}/${lapackname}-${lapackversion}/make.inc
114   
115    reinplace "s|OPTS     = -O2|OPTS = ${atlas_fflags}|" \
116           ${workpath}/${lapackname}-${lapackversion}/make.inc
117   
118    reinplace "s|NOOPT    = -O0|NOOPT = -O2 -m32|" \
119           ${workpath}/${lapackname}-${lapackversion}/make.inc
120
121    reinplace "s|PLAT = _LINUX|PLAT = _darwin|" \
122           ${workpath}/${lapackname}-${lapackversion}/make.inc
123   
124    reinplace "s|LOADOPTS =|LOADOPTS = ${atlas_fflags}|" \
125           ${workpath}/${lapackname}-${lapackversion}/make.inc
126   
127    system "cd ${workpath}/${lapackname}-${lapackversion} && make lib"
128
129    # create a build directory for atlas
130    file mkdir ${workpath}/${name}-${version}/build
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
165#destroot {
166#  xinstall -m 755 -d ${destroot}${prefix}/bin
167#  xinstall -m 755 -d ${destroot}${prefix}/lib
168#  xinstall -m 755 -d ${destroot}${prefix}/include
169#
170#  xinstall -m 644 -d ${worksrcpath}/build/lib/libatlas.dylib     ${destroot}${prefix}/lib
171#  xinstall -m 644 -d ${worksrcpath}/build/lib/liblapack.dylib    ${destroot}${prefix}/lib
172#  xinstall -m 644 -d ${worksrcpath}/build/lib/libptcblas.dylib   ${destroot}${prefix}/lib
173#  xinstall -m 644 -d ${worksrcpath}/build/lib/libptf77blas.dylib ${destroot}${prefix}/lib
174#
175#
176#}
177#
178post-destroot {
179  # we make soft links to the parallel built libs
180  system "cd ${destroot}${prefix}/lib && \
181          ln -sf ./libptcblas.dylib libcblas.dylib && \
182          ln -sf ./libptf77blas.dylib libf77blas.dylib"
183}