Ticket #24923: Portfile.diff

File Portfile.diff, 12.3 KB (added by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), 14 years ago)
  • Portfile

    old new  
    11# $Id: Portfile 67706 2010-05-16 16:35:35Z mcalhoun@macports.org $
    22
    33PortSystem          1.0
     4PortGroup           muniversal 1.0
    45
    56categories          math
    67name                atlas
     
    4748build.target        build
    4849build.dir           ${workpath}/${name}-${version}/build
    4950
     51variant gcc43 conflicts gcc42 conflicts universal {}
     52variant gcc42 conflicts gcc43 conflicts universal {}
     53
     54if { [variant_isset gcc42] } {
     55  set gccversion    4.2
     56} elseif { [variant_isset gcc43] } {
     57  set gccversion    4.3
     58} else {
     59  set gccversion    4.4
     60}
     61
     62set gccnumber       [join [split ${gccversion} .] ""]
     63
    5064destroot.dir        ${build.dir}
    5165destroot.destdir    DESTDIR=${destroot}${prefix}
    52 depends_lib         port:gcc43 \
     66depends_lib         port:gcc${gccnumber} \
    5367                    port:bzip2 \
    5468                    port:gzip
    5569
    56 universal_variant   no
     70configure.compiler  macports-gcc-${gccversion}
    5771
    58 # Set fortran compiler flags
    59 set myf77           ${prefix}/bin/gfortran-mp-4.3
     72if { ${os.arch}=="i386" } {
     73    set universal_archs_supported { i386 x86_64 }
     74} else {
     75    set universal_archs_supported { ppc  ppc64 }
     76}
    6077
    6178if {${build_arch} == "x86_64" || ${build_arch} == "ppc64" } {
    6279  set my_arch 64
     
    6481  set my_arch 32
    6582}
    6683
    67 configure.args      -C xc ${prefix}/bin/gcc-mp-4.3 \
    68                     -C gc ${prefix}/bin/gcc-mp-4.3 \
    69                     -C if ${myf77} \
    70                     -C ic ${prefix}/bin/gcc-mp-4.3 \
    71                     -C dm ${prefix}/bin/gcc-mp-4.3 \
    72                     -C sm ${prefix}/bin/gcc-mp-4.3 \
    73                     -C dk ${prefix}/bin/gcc-mp-4.3 \
    74                     -C sk ${prefix}/bin/gcc-mp-4.3 \
    75                     --cc=${prefix}/bin/gcc-mp-4.3 \
     84configure.args      -C xc ${configure.cc} \
     85                    -C gc ${configure.cc} \
     86                    -C if ${configure.f77} \
     87                    -C ic ${configure.cc} \
     88                    -C dm ${configure.cc} \
     89                    -C sm ${configure.cc} \
     90                    -C dk ${configure.cc} \
     91                    -C sk ${configure.cc} \
     92                    --cc=${configure.cc} \
    7693                    -b ${my_arch} \
    7794                    -Fa alg -fPIC
    7895                   
    79 configure.compiler  macports-gcc-4.3
    80 configure.cc        ${prefix}/bin/gcc-mp-4.3 
    81 configure.cxx       ${prefix}/bin/g++-mp-4.3
    82 build.env-append    "CC=${prefix}/bin/gcc-mp-4.3 CXX=${prefix}/bin/g++-mp-4.3"
     96if { [variant_isset universal] } {
     97    configure.universal_args-delete --disable-dependency-tracking
     98    configure.args-delete -b ${my_arch}
     99    lappend merger_configure_args(ppc)     -b 32
     100    lappend merger_configure_args(ppc64)   -b 64
     101    lappend merger_configure_args(i386)    -b 32
     102    lappend merger_configure_args(x86_64)  -b 64
     103} else {
     104    lappend merger_configure_args(ppc)
     105    lappend merger_configure_args(ppc64)
     106    lappend merger_configure_args(i386)
     107    lappend merger_configure_args(x86_64)
     108}
     109
     110build.env-append    "CC=${configure.cc} CXX=${configure.cxx}"
    83111       
    84112
    85113# we are configuring from the build directory
     
    87115configure.cmd       ../configure
    88116
    89117
    90 # change the default compilers to those of gcc43 and make into shared library
     118# change the default compilers to those of gcc and make into shared library
    91119extract {
    92120    # extract atlas and move to a consistent working directory name
    93121    system "cd ${workpath} && bunzip2 -dc ${distpath}/${atlasdist} | \
     
    103131    reinplace "s|__MACPORTS_GCC__|${configure.cc}|g" ${workpath}/${name}-${version}/CONFIG/src/SpewMakeInc.c
    104132}
    105133
    106 
    107134pre-configure {
    108     reinplace "s|cc=gcc|cc=${prefix}/bin/gcc-mp-4.3|g" ${worksrcpath}/configure
     135    if { [variant_isset universal] } {
     136        foreach arch ${universal_archs_to_use} {
     137            copy ${workpath}/${name}-${version} ${workpath}/${name}-${version}-${arch}
     138            copy ${workpath}/${lapackname}-${lapackversion} ${workpath}/${lapackname}-${lapackversion}-${arch}
     139        }
     140    }
     141
     142    reinplace "s|cc=gcc|cc=${configure.cc}|g" ${worksrcpath}/configure
    109143    reinplace "s|-no-cpp-precomp||g" ${workpath}/${name}-${version}/CONFIG/src/atlcomp.txt
    110144   
    111145    # Get some system specific variables for maximum optimization
     
    117151    } else {
    118152      configure.args-append -D c -DPentiumCPS=${cpufreq}
    119153    }
     154
     155    if { [variant_isset universal] } {
     156        set archs ${universal_archs_to_use}
     157    } else {
     158        set archs ${build_arch}
     159    }
     160
     161    foreach arch ${archs} {
    120162 
    121163    # first do a 'fake configure' of atlas so we get optimized lapack libraries
    122164    ui_debug "performing fake configure of atlas for optimized lapack"
    123165    # atlas docs: 3.1.2
    124     set atlas_path ${workpath}/${name}-${version}
     166    if { ! [variant_isset universal] } {
     167        set atlas_path  ${workpath}/${name}-${version}
     168        set lapack_path ${workpath}/${lapackname}-${lapackversion}
     169    } else {
     170        set atlas_path ${workpath}/${name}-${version}-${arch}
     171        set lapack_path ${workpath}/${lapackname}-${lapackversion}-${arch}
     172    }
    125173    ui_debug "Clean out old temp directory if exists"
    126174    file delete -force ${atlas_path}/temp
    127175    file mkdir ${atlas_path}/temp
    128     ui_debug "Assembled Command: '${configure.cmd} ${configure.args}"
     176    ui_debug "Assembled Command: '${configure.cmd} ${configure.args} $merger_configure_args(${arch})"
    129177    system "cd ${atlas_path}/temp && \
    130             ${configure.cmd} ${configure.args}"
     178            ${configure.cmd} ${configure.args} $merger_configure_args(${arch})"
    131179
    132180    # Get the F77FLAGS
    133181    set atlas_f77    [join [lrange [split [exec grep "F77 = " $atlas_path/temp/Make.inc     ] =] 1 end] =]
     
    140188    file delete -force ${atlas_path}/temp
    141189
    142190    # compile lapack
    143     system "cd ${workpath}/${lapackname}-${lapackversion} && \
     191    system "cd ${lapack_path} && \
    144192            cp INSTALL/make.inc.gfortran make.inc"
    145193    reinplace "s|gfortran|${atlas_f77}|" \
    146            ${workpath}/${lapackname}-${lapackversion}/make.inc
     194           ${lapack_path}/make.inc
    147195    reinplace "s|OPTS     = -O2|OPTS = ${atlas_fflags}|" \
    148            ${workpath}/${lapackname}-${lapackversion}/make.inc
     196           ${lapack_path}/make.inc
    149197     
    150     reinplace "s|NOOPT    = -O0|NOOPT = -O2 -m${my_arch}|" \
    151            ${workpath}/${lapackname}-${lapackversion}/make.inc
     198    if { ! [variant_isset universal] } {
     199        reinplace "s|NOOPT    = -O0|NOOPT = -O2 -m${my_arch}|" \
     200               ${lapack_path}/make.inc
     201    } else {
     202        if { ${arch}=="i386" || ${arch}=="ppc" } {
     203            reinplace "s|NOOPT    = -O0|NOOPT = -O2 -m32|" \
     204                   ${lapack_path}/make.inc
     205        } else {
     206            reinplace "s|NOOPT    = -O0|NOOPT = -O2 -m64|" \
     207                   ${lapack_path}/make.inc
     208        }
     209    }
    152210
    153211    reinplace "s|PLAT = _LINUX|PLAT = _darwin|" \
    154            ${workpath}/${lapackname}-${lapackversion}/make.inc
     212           ${lapack_path}/make.inc
    155213
    156214    reinplace "s|LOADOPTS =|LOADOPTS = ${atlas_fflags}|" \
    157            ${workpath}/${lapackname}-${lapackversion}/make.inc
     215           ${lapack_path}/make.inc
    158216
    159     system "cd ${workpath}/${lapackname}-${lapackversion} && make lib"
     217    system "cd ${lapack_path} && make lib"
    160218
    161219    # create a build directory for atlas
    162     file mkdir ${workpath}/${name}-${version}/build
     220    file mkdir ${atlas_path}/build
    163221
    164 
    165     configure.args-append --with-netlib-lapack=${workpath}/${lapackname}-${lapackversion}/lapack_darwin.a
     222    if { ! [variant_isset universal] } {
     223        configure.args-append --with-netlib-lapack=${lapack_path}/lapack_darwin.a
     224    } else {
     225        lappend merger_configure_args(${arch}) --with-netlib-lapack=${lapack_path}/lapack_darwin.a
     226    }
     227}
    166228}
    167229
    168230post-configure {
     231    if { [variant_isset universal] } {
     232        set archs ${universal_archs_to_use}
     233    } else {
     234        set archs ${build_arch}
     235    }
     236 
     237    foreach arch ${archs} {
     238        if { ! [variant_isset universal] } {
     239            set atlas_path  ${workpath}/${name}-${version}
     240        } else {
     241            set atlas_path ${workpath}/${name}-${version}-${arch}
     242        }
     243
    169244    # recursively remove directories
    170245    ui_debug "reinplace for make to recursively remove directories on clean"
    171     reinplace "s|rm -f|rm -rf|g" ${workpath}/${name}-${version}/build/Makefile
     246    reinplace "s|rm -f|rm -rf|g" ${atlas_path}/build/Makefile
     247    }
    172248}
    173249
    174 proc make_dylib { lib libs } {
    175     global destroot prefix myarch
    176     system "cd ${destroot}/${prefix}/lib && \
     250proc make_dylib { lib lib_dir arch libs } {
     251    global destroot prefix gccnumber
     252    system "cd ${lib_dir} && \
    177253            ( test ! -e ${lib}.a ||
    178               ld -arch ${myarch} -dynamic -dylib -single_module -dead_strip \
    179               -x -all_load -L. -L${prefix}/lib/gcc43 -ldylib1.o \
     254              /usr/bin/ld -arch ${arch} -dynamic -dylib -single_module -dead_strip \
     255              -x -all_load -L. -L${prefix}/lib/gcc${gccnumber}/${arch} -L${prefix}/lib/gcc${gccnumber} -ldylib1.o \
    180256              -dylib_install_name ${prefix}/lib/${lib}.dylib \
    181               ${lib}.a -o ${lib}.dylib ${libs} && rm -f ${lib}.a)"
     257              ${lib}.a -o ${lib}.dylib ${libs} )"
    182258}
    183259
    184 
    185 post-destroot {
     260post-build {
    186261  # We have to manually create the dylib shared libs as the default build does not do this
    187   global myarch
    188262
    189   if {[string equal "${os.arch}" "powerpc"]} {
    190     if {${my_arch} == "64" } {
    191       set myarch "ppc64"
    192     } else {
    193       set myarch "ppc"
    194     }
    195   } else {
    196     if {${my_arch} == "64" } {
    197       set myarch "x86_64"
     263  set ncpu [exec sysctl -n hw.ncpu]
     264
     265    if { [variant_isset universal] } {
     266        set archs ${universal_archs_to_use}
    198267    } else {
    199       set myarch "i386"
     268        set archs ${build_arch}
    200269    }
    201   }
    202 
    203   set ncpu [exec sysctl -n hw.ncpu]
     270 
     271    foreach arch ${archs} {
     272        if { ! [variant_isset universal] } {
     273            set atlas_path  ${workpath}/${name}-${version}
     274        } else {
     275            set atlas_path ${workpath}/${name}-${version}-${arch}
     276        }
     277        set lib_dir ${atlas_path}/build/lib
    204278
    205   make_dylib libatlas { -lSystem }
     279  make_dylib libatlas ${lib_dir} ${arch} { -lSystem }
    206280
    207281  if {${ncpu} == "1" } {
    208282    # there are no threaded libraries (libpt*) on single-core machines
    209     make_dylib libcblas   { -latlas -lSystem }
    210     make_dylib libf77blas { -lgfortran -latlas -lSystem }
     283    make_dylib libcblas   ${lib_dir} ${arch} { -latlas -lSystem }
     284    make_dylib libf77blas ${lib_dir} ${arch} { -lgfortran -latlas -lSystem }
    211285  } else {
    212     make_dylib libptcblas   { -latlas -lSystem }
    213     make_dylib libptf77blas { -lgfortran -latlas -lSystem }
     286    make_dylib libptcblas   ${lib_dir} ${arch} { -latlas -lSystem }
     287    make_dylib libptf77blas ${lib_dir} ${arch} { -lgfortran -latlas -lSystem }
     288  }
    214289
    215     # we make soft links to the parallel built libs
    216     system "cd ${destroot}${prefix}/lib && \
    217             ln -s ./libptcblas.dylib libcblas.dylib && \
    218             ln -s ./libptf77blas.dylib libf77blas.dylib"
     290  make_dylib liblapack ${lib_dir} ${arch} { -lf77blas -lcblas -latlas -lgfortran -lgcc_s.1 -lSystem }
     291}
     292}
    219293
    220     file delete ${destroot}/${prefix}/lib/libcblas.a
    221     file delete ${destroot}/${prefix}/lib/libf77blas.a
    222   }
     294pre-destroot {
     295   if { [variant_isset universal] } {
     296        set archs ${universal_archs_to_use}
     297    } else {
     298        set archs ${build_arch}
     299    }
     300 
     301    foreach arch ${archs} {
     302        if { ! [variant_isset universal] } {
     303            set atlas_path  ${workpath}/${name}-${version}
     304            set dest_path   ${destroot}${prefix}/lib/
     305        } else {
     306            set atlas_path ${workpath}/${name}-${version}-${arch}
     307            set dest_path  ${destroot}-${arch}${prefix}/lib/
     308        }
     309        set lib_dir ${atlas_path}/build/lib
    223310
    224   make_dylib liblapack { -lf77blas -lcblas -latlas -lgfortran -lgcc_s.1 -lSystem }
     311        file mkdir ${dest_path}
     312        eval xinstall -m 755 [glob ${lib_dir}/*.dylib] ${dest_path}
     313    }
     314}
     315
     316post-destroot {
     317    if { ![file exists ${destroot}${prefix}/lib/libcblas.dylib] && [file exists ${destroot}${prefix}/lib/libptcblas.dylib]} {
     318        ln -s libptcblas.dylib ${destroot}${prefix}/lib/libcblas.dylib
     319    }
     320    if { ![file exists ${destroot}${prefix}/lib/libf77blas.dylib] && [file exists ${destroot}${prefix}/lib/libptf77blas.dylib]} {
     321        ln -s libptf77blas.dylib ${destroot}${prefix}/lib/libf77blas.dylib
     322    }
    225323}
    226324
    227325livecheck.name      math-atlas