# $Id: Portfile 105083 2013-04-09 10:43:39Z jmr@macports.org $ PortSystem 1.0 PortGroup muniversal 1.0 categories math license BSD name atlas version 3.10.1 revision 3 # additional versions set lapackversion 3.4.2 set lapackname lapack set atlasdist ${name}${version}.tar.bz2 set lapackdist ${lapackname}-${lapackversion}.tgz maintainers vince platforms darwin description Portable optimal linear algebra software long_description Provides a complete BLAS and LAPACK API.\nATLAS\ achieves performance on par\ with machine-specific tuned libraries. # No precompiled binaries archive_sites homepage http://math-atlas.sourceforge.net/ master_sites sourceforge:math-atlas:atlas \ http://www.netlib.org/lapack:lapack distfiles ${atlasdist}:atlas \ ${lapackdist}:lapack patchfiles patch-emit_mm_c.diff \ patch-ATL_cmm4x4x128_av_c.diff checksums atlas3.10.1.tar.bz2 \ rmd160 67f928ad900caa300b23e2f824b8a495f416c8d6 \ sha256 a215b492204aae0205f4028e7c4076492a5d6a564f8f859ff062fd79587bcc86 \ lapack-3.4.2.tgz \ rmd160 8740c35c9a85b71424fe1ffeed192256aebeb431 \ sha256 60a65daaf16ec315034675942618a2230521ea7adf85eea788ee54841072faf0 set gcc_version 0 set use_clang "" variant gcc48 conflicts gcc46 gcc47 \ clang mpclang32 mpclang33 \ description {build using macports-gcc-4.8} { depends_build-append port:gcc48 configure.compiler macports-gcc-4.8 set gcc_version 48 set use_clang "" } variant gcc47 conflicts gcc46 gcc48 \ clang mpclang32 mpclang33 \ description {build using macports-gcc-4.7} { depends_build-append port:gcc47 configure.compiler macports-gcc-4.7 set gcc_version 47 set use_clang "" } variant gcc46 conflicts gcc47 gcc48 \ clang mpclang32 mpclang33 \ description {build using macports-gcc-4.6} { depends_build-append port:gcc46 configure.compiler macports-gcc-4.6 set gcc_version 46 set use_clang "" } variant clang conflicts gcc46 gcc47 gcc48 \ mpclang32 mpclang33 \ description {use XCode clang and gfortran} { if {[vercmp $xcodeversion 4.3] < 0} { pre-fetch { return -code error "Your version of clang is too old!" } } configure.compiler clang set use_clang "XCode" set gcc_version 0 } variant mpclang32 conflicts gcc46 gcc47 gcc48 \ clang mpclang33 \ description {use mp-clang-3.2 and gfortran} { depends_build-append port:clang-3.2 configure.compiler macports-clang-3.2 set use_clang "32" set gcc_version 0 } variant mpclang33 conflicts gcc46 gcc47 gcc48 \ clang mpclang32 \ description {use mp-clang-3.3 and gfortran} { depends_build-append port:clang-3.3 configure.compiler macports-clang-3.3 set use_clang "33" set gcc_version 0 } variant nofortran description {Forgo use of fortran compiler} { } # AVX or higher? if {${os.major} > 10 && \ ![catch {sysctl hw.optional.avx1_0} result1] && $result1 == 1} { set has_avx "yes" } else { set has_avx "no" } # If none of the above variants is chosen, make gcc47 the default for # up to SSE4.2 (Core i1) capable processors, and mp-clang-3.3 for newer if {![variant_isset gcc46] && ![variant_isset gcc47] && \ ![variant_isset gcc48] && ![variant_isset clang] && \ ![variant_isset mpclang32] && ![variant_isset mpclang33]} { if {${has_avx} == "no"} { # Defaults to gcc47 default_variants +gcc47 set gcc_version 47 set use_clang "" } else { # Defaults to clang-mp-3.3 default_variants +mpclang33 set gcc_version 0 set use_clang "33" } } set universal [variant_isset universal] # Finds the type of CPU we are running on set native_arch $build_arch if {${os.arch} == "i386"} { set universal_archs_supported {i386 x86_64} if {![catch {sysctl hw.machine} result]} { set native_arch $result } } elseif {${os.arch} == "powerpc"} { set universal_archs_supported {ppc ppc64} if {![catch {sysctl hw.cpusubtype} result] && $result == 100} { set native_arch "ppc64" } else { set native_arch "ppc" } } configure.args \ --with-netlib-lapack-tarfile=${distpath}/${lapackdist} \ -O 12 \ -v 5 \ --dylibs # Chose the right flags for GCC and Clang compilers if {${build_arch} == "i386" || ${build_arch} == "x86_64"} { # General flags # GCC set gcc_flags "-fomit-frame-pointer -mfpmath=sse -O3\ -fno-schedule-insns2 -fPIC" # Clang if {${use_clang} == "32" || ${use_clang} == "XCode" } { pre-fetch { ui_warn "Compiling Atlas with this version of clang is\ likely *NOT* to work. Please use clang-3.3 or\ higher." } set clang_flags "-O3 -fomit-frame-pointer -fPIC" } else { # Clang 3.3 – Use loop and straight vectorizer set clang_flags "-O3 -fomit-frame-pointer -fPIC\ -fvectorize -fslp-vectorize" } # Vectorizing unit flags if {${has_avx} == "yes"} { # GCC compilers do not support AVX on OS X set gvct_flag "-msse4.2" set cvct_flag "-mavx" } elseif {${os.major} > 9 && \ ![catch {sysctl hw.optional.sse4_2} result1] && $result1 == 1} { set gvct_flag "-msse4.2" set cvct_flag "-msse4.2" } elseif {${os.major} > 9 && \ ![catch {sysctl hw.optional.sse4_1} result1] && $result1 == 1} { set gvct_flag "-msse4.1" set cvct_flag "-msse4.1" } elseif {${os.major} > 8 && \ ![catch {sysctl hw.optional.supplementalsse3} result1] && $result1 == 1} { set gvct_flag "-mssse3" set cvct_flag "-mssse3" } else { # Default vectorization flag is sse3 (CoreSolo / CoreDuo) set gvct_flag "-msse3" set cvct_flag "-msse3" } } elseif {${build_arch} == "ppc"} { # PPC set gcc_flags "-O3 -mcpu=7400 -mtune=7400\ -fno-schedule-insns -fschedule-insns2 -fPIC" set clang_flags "-O3 -arch ppc -fPIC" set gvct_flag "-maltivec -mabi=altivec" set cvct_flag "-maltivec" configure.args-append -A 4 # On Leopard, we may warn the user that ppc # is not as efficient as ppc64 pre-fetch { if {${native_arch} == "ppc64"} { ui_msg "Compiling for ppc on a G5 machine.\ This could lead to reduced performance." } } } else { # PPC64 set gcc_flags "-mcpu=970 -mtune=970 -mvrsave -mpowerpc64\ -fno-schedule-insns -fschedule-insns2 -fPIC" # Clang has no PPC64 target so compile for PPC set clang_flags "-O3 -arch ppc -fPIC" set gvct_flag "-maltivec -mabi=altivec" set cvct_flag "-maltivec" } # Basic universal config # Advanced config (flags) is done during pre-configure phase if {${universal} == 1} { configure.universal_args-delete --disable-dependency-tracking lappend merger_configure_args(ppc) --cflags=-m32 \ -b 32 \ -A 4 \ -V 2 \ -s gas_ppc \ -Fa alg -force_cpusubtype_ALL lappend merger_configure_args(ppc64) --cflags=-m64 \ -b 64 \ -A 5 \ -V 2 \ -s gas_ppc \ -Fa alg -force_cpusubtype_ALL lappend merger_configure_args(i386) --cflags=-m32 \ -b 32 \ -A 22 \ -V 6 \ -s gas_x86_32 lappend merger_configure_args(x86_64) --cflags=-m64 \ -b 64 \ -s gas_x86_64 } # Threading # If we run on a mono-processor machine (PPC), then disable threading if {![catch {sysctl hw.logicalcpu} result] && $result == 1} { configure.args-append -t 0 set no_threads 1 } else { set no_threads 0 # Threading relies on OpenMP if gcc compilers are selected if {${gcc_version} != 0} { configure.args-append -Si omp 1 } } # Phases (moonlike) extract { # extract Atlas and move to a consistent working directory name system -W ${workpath} "bunzip2 -dc ${distpath}/${atlasdist} | \ gnutar --no-same-owner -xf -" system "mv ${workpath}/ATLAS ${workpath}/${name}-${version}" } post-patch { if {${build_arch} == "ppc" || ${build_arch} == "ppc64"} { reinplace \ "s|cMVFLAGS=\\\\\"%s\\\\\"|cMVFLAGS=\\\\\"-force_cpusubtype_ALL\ %s\\\\\"|" \ ${worksrcpath}/include/atlas_mvtesttime.h # Remove all references to threads directories exec sed -i bak -E "/.*threads.*/d" ${worksrcpath}/Make.top } } # Change the default compilers pre-configure { # Inform user of selected C compiler ui_msg "Selected C compiler: ${configure.cc}" # Fortran stuff set fortran [expr ! [variant_isset nofortran]] # If we use clang, we must grasp a gfortran compiler to build # Fortran sources (do not impact overall Atlas performance) if {${use_clang} != "" && ${fortran} == 1} { set gflist [glob -noc ${prefix}/bin/gfortran-mp-4.*] if {[llength ${gflist}] == 0} { # No fortran compiler found. Act as if nofortran was set. ui_warn "No gfortran-mp-4.* compiler found.\ Disabling fortran API." set fortran 0 } else { # Select most recent gfortran global gcc_version configure.f77 [lindex [lsort -dec ${gflist}] 0] set gcc_version \ [join [split [string range ${configure.f77} end-2 end] "."] ""] } } if {${fortran} == 1} { # Output the F77 selected compiler ui_msg "Selected F77 compiler: gfortran${gcc_version}" } else { # No Fortran configure.args-append --nof77 } # Now set the flags according to the compiler family chosen # Also set “width” of the processor (32 or 64-bit) if {${gcc_version} != 0} { set libgccpath ${prefix}/lib/gcc${gcc_version} } # Non-universal builds if {${universal} == 0} { configure.args-append -C acg ${configure.cc} # If we build for the CPU of the machine, use # machine arch tuning (except on ppc) # -march=natives supersedes -msse4.2 so disable it on AVX # capable machines if {${has_avx} == "no" && ${build_arch} != "ppc"} { append gcc_flags " -march=native" } append clang_flags " -march=native" # AVX stuff. GCC compilers cannot use AVX instruction set because the # system as(1) is outdated # Clang 3.2 has a bug affecting some AVX instructions # Clang 3.3 should be fine if {${has_avx} == "yes"} { if {${use_clang} == ""} { # Force Core i1 arch for ASM kernels ui_warn "GCC compilers on MacOS do not support AVX:\ downgrading." configure.args-append -A 25 } else { # Clang: AVX only on versions >= 3.3 if {${use_clang} == "32" || ${use_clang} == "XCode" } { ui_warn "AVX support is broken in these versions\ of clang. Please use clang-3.3 or higher.\ Downgrading." configure.args-append -A 25 } } } if {${build_arch} == "ppc"} { # ppc uses altivec vectorizing unit configure.args-append -V 2 } if {${use_clang} == ""} { # GCC configure.args-append -F acg "'${gcc_flags} ${gvct_flag}'" if {${fortran} == 1} { configure.args-append -C if ${configure.f77} configure.args-append -F if "'${gcc_flags} ${gvct_flag}'" configure.args-append -Ss f77lib \ ${libgccpath}/libgfortran.dylib } if {${build_arch} == "x86_64" || ${build_arch} == "ppc64"} { configure.args-append -b 64 } else { configure.args-append -b 32 } } else { # clang configure.args-append -F acg "'${clang_flags} ${cvct_flag}'" if {${fortran} == 1} { configure.args-append -C if ${configure.f77} configure.args-append -F if "'${gcc_flags} ${gvct_flag}'" configure.args-append -Ss f77lib \ ${libgccpath}/libgfortran.dylib } if {${build_arch} == "x86_64"} { configure.args-append -b 64 } else { # Clang has no ppc64 target so ppc64 ➸ regular ppc (32 bit) configure.args-append -b 32 } } # Create build directory file mkdir ${worksrcpath}/build } else { # Universal builds foreach arch ${universal_archs_to_use} { # Init ‘universal’ flags set gcc_univ_flags ${gcc_flags} set gvct_univ_flag ${gvct_flag} set clang_univ_flags ${clang_flags} set cvct_univ_flag ${cvct_flag} set gcc_supp_flags "" set clang_supp_flags "" # We build for the native architecture if {${arch} == ${native_arch} && ${build_arch} != "ppc"} { if {${has_avx} == "no"} { append gcc_supp_flags "-march=native " } append clang_supp_flags "-march=native " } # Non-native targets. Apply a priori flags. # Clamp i386 optimization to -sse3 in universal builds and # forces clang/gcc to use -m32 flag if {${arch} == "i386" && ${native_arch} != "i386"} { set gvct_univ_flag "-msse3" set cvct_univ_flag "-msse3" append gcc_supp_flags "-m32" append clang_supp_flags "-m32" } # For x86_64 builds, be conservative and use only -ssse3 # Core2 CPU and SSE3 ASM kernels if {${arch} == "x86_64" && ${native_arch} != "x86_64"} { set gvct_univ_flag "-mssse3" set cvct_univ_flag "-mssse3" append gcc_supp_flags "-m64" append clang_supp_flags "-m64" lappend merger_configure_args("x86_64") -A 25 -V 6 } # ppc (on Intel or ppc64 machines) if {${arch} == "ppc" && ${native_arch} != "ppc"} { set gcc_univ_flags "-O3 -mcpu=7400 -mtune=7400\ -fno-schedule-insns -fschedule-insns2\ -fPIC" set clang_univ_flags "-O3 -arch ppc -fPIC" set gvct_univ_flag "-maltivec -mabi=altivec" set cvct_univ_flag "-maltivec" append gcc_supp_flags "-m32" append clang_supp_flags "-m32" } # ppc64 (only for gcc, for clang this is taken to be the # same target as ppc) if {${arch} == "ppc64" && ${native_arch} != "ppc64"} { set gcc_univ_flags "-mcpu=970 -mtune=970 -mvrsave \ -mpowerpc64 -fno-schedule-insns\ -fschedule-insns2 -fPIC" set clang_univ_flags "-O3 -arch ppc -fPIC" set gvct_univ_flag "-maltivec -mabi=altivec" set cvct_univ_flag "-maltivec" append gcc_supp_flags "-m64" append clang_supp_flags "-m64" } # Now add the flags to merger_configure_args(${arch}) # Same code as the non-universal case lappend merger_configure_args(${arch}) -C acg ${configure.cc} if {${use_clang} == ""} { # GCC lappend merger_configure_args(${arch}) \ -F acg "'${gcc_univ_flags} ${gcc_supp_flags}\ ${gvct_univ_flag}'" if {${fortran} == 1} { lappend merger_configure_args(${arch}) \ -C if ${configure.f77} \ -F if "'${gcc_univ_flags} ${gcc_supp_flags}\ ${gvct_univ_flag}'" set libgccarchpath ${libgccpath}/${arch} if {[file exists ${libgccarchpath}/libgfortran.dylib]} { lappend merger_configure_args(${arch}) \ -Ss f77lib ${libgccarchpath}/libgfortran.dylib } else { lappend merger_configure_args(${arch}) \ -Ss f77lib ${libgccpath}/libgfortran.dylib } } } else { # clang lappend merger_configure_args(${arch}) \ -F acg "'${clang_univ_flags} ${clang_supp_flags}\ ${cvct_univ_flag}'" if {${fortran} == 1} { lappend merger_configure_args(${arch}) \ -C if ${configure.f77} \ -F if "'${gcc_univ_flags} ${gcc_supp_flags}\ ${gvct_univ_flag}'" set libgccarchpath ${libgccpath}/${arch} if {[file exists ${libgccarchpath}/libgfortran.dylib]} { lappend merger_configure_args(${arch}) \ -Ss f77lib ${libgccarchpath}/libgfortran.dylib } else { lappend merger_configure_args(${arch}) \ -Ss f77lib ${libgccpath}/libgfortran.dylib } } } # Remove spurious { } from arguments list set merger_configure_args(${arch}) \ [join [split $merger_configure_args(${arch}) "{}"]] # Create ${arch} build tree copy ${workpath}/${name}-${version} \ ${workpath}/${name}-${version}-${arch} file mkdir ${workpath}/${name}-${version}-${arch}/build } } # Overrides goodgcc reinplace -E "s|GOODGCC =.*|GOODGCC = ${configure.cc}\");|" \ ${worksrcpath}/CONFIG/src/SpewMakeInc.c # Some further tweaks reinplace "s|cc=gcc|cc=${configure.cc}|g" \ ${worksrcpath}/configure reinplace "s|-no-cpp-precomp||g" \ ${worksrcpath}/CONFIG/src/atlcomp.txt # On PPC64 we need extra flags for configuring if {${native_arch} == "ppc64"} { configure.args-append --cc="\"${configure.cc} -m32 \ -force_cpusubtype_ALL\"" } # Get some system specific variables for maximum optimization set cpufreq [expr {[sysctl hw.cpufrequency] / 1000000}] if {${os.arch} == "powerpc"} { configure.args-append -D c -DWALL } else { configure.args-append -D c -DPentiumCPS=${cpufreq} } } # We configure from the build directory configure.dir ${worksrcpath}/build configure.cmd ../configure post-configure { # Store in ${atlas_paths} the ${worksrcpath}s corresponding to the # archs Atlas is being built for. set atlas_paths {} if {${universal} == 1} { foreach arch ${universal_archs_to_use} { lappend atlas_paths ${workpath}/${name}-${version}-${arch} } } else { lappend atlas_paths ${worksrcpath} } foreach path ${atlas_paths} { # Recursively remove directories ui_debug "Patch to recursively remove directories on clean." reinplace "s|rm -f|rm -rf|g" ${path}/build/Makefile # Threading — ensure libgomp is correctly pulled in during link if {${gcc_version} != 0 && ${no_threads} == 0} { set gmpfx ${prefix}/lib/gcc${gcc_version} set arch [lindex [split [lindex [split $path "/"] end] "-"] 2] if {${arch} != "" && \ [file exists ${gmpfx}/${arch}/libgomp.dylib]} { reinplace -E \ "s|(LIBS =.*)|\\1 ${gmpfx}/${arch}/libgomp.dylib|" \ ${path}/build/Make.inc } else { reinplace -E \ "s|(LIBS =.*)|\\1 ${gmpfx}/libgomp.dylib|" \ ${path}/build/Make.inc } } } } build.env-append "CC=${configure.cc} CXX=${configure.cxx}" use_parallel_build no build.target build build.dir ${worksrcpath}/build post-build { if {${universal} == 0} { set libdir ${build.dir}/lib reinplace "s|^LIBTOOL=.*$|LIBTOOL=\$\(GCC\) \$\(GCCFLAGS\)|" \ ${libdir}/Makefile reinplace "s|dynamic|dynamiclib|g" ${libdir}/Makefile # On mono-processors machines, build libsatlas.dylib only if {${no_threads} == 1} { system -W ${libdir} "${build.cmd} dylib" } else { system -W ${libdir} "${build.cmd} shared_all" } } else { foreach arch ${universal_archs_to_use} { set libdir ${workpath}/${name}-${version}-${arch}/build/lib reinplace "s|^LIBTOOL=.*$|LIBTOOL=\$\(GCC\) \$\(GCCFLAGS\)|" \ ${libdir}/Makefile reinplace "s|dynamic|dynamiclib|g" ${libdir}/Makefile # Same as above if {${no_threads} == 1} { system -W ${libdir} "${build.cmd} dylib" } else { system -W ${libdir} "${build.cmd} shared_all" } } } } destroot.dir ${build.dir} destroot.destdir DESTDIR=${destroot}${prefix} post-destroot { # On monoprocessor machines, make tatlas and satlas synonymous if {${no_threads} == 1} { set libdir ${destroot}${prefix}/lib system -W ${libdir} "ln -s libsatlas.dylib libtatlas.dylib" } } livecheck.name math-atlas livecheck.distname Stable