# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header:$ inherit eutils toolchain-funcs fortran DESCRIPTION="Automatically Tuned Linear Algebra Software BLAS implementation" HOMEPAGE="http://math-atlas.sourceforge.net/" MY_PN=${PN/blas-/} MY_PV=3.7.14 SRC_URI="mirror://sourceforge/math-atlas/${MY_PN}${PV}.tar.bz2" LICENSE="BSD" SLOT="0" KEYWORDS="~alpha ~amd64 ~ia64 ~ppc ~ppc64 ~sparc ~x86" IUSE="doc" RDEPEND="sci-libs/blas-config" DEPEND="${RDEPEND} >=sys-devel/libtool-1.5" PROVIDE="virtual/blas" S="${WORKDIR}/ATLAS" BUILDDIR="${S}/build" RPATH="${DESTTREE}/$(get_libdir)/blas" FORTRAN="g77 gfortran" src_unpack() { unpack "${A}" mkdir "${BUILDDIR}" cd "${S}" epatch "${FILESDIR}"/atlas3.7.14-shared-libs.patch # epatch "${FILESDIR}"/unbuffered.patch # epatch "${FILESDIR}"/${PV}-allow-any-gcc-version.patch # epatch "${DISTDIR}"/atlas3.6.0-shared-libs.3.patch.bz2 # epatch "${FILESDIR}"/${PV}-ppc-configure.patch sed -i \ -e "s:ASM:ASM VOLATILE:" \ include/contrib/camm_dpa.h \ || die "sed failed to fix clobbering" # sed -i \ # -e "s:\(\t./xconfig\):\1 -m $(tc-getCC) -c $(tc-getCC) -f ${FORTRANC}:g" \ # ${S}/Makefile \ # || die "Failed to fix compilers" # if [[ $(gcc-major-version) -ge 4 ]]; then # einfo "Updating Makefiles for gcc-4" # sed -i \ # -e "s:g2c:gfortran:g" \ # ${S}/Make.top \ # ${S}/makes/Make.lib \ # || die "Failed to update for gcc-4" # fi # make sure shared libs link against proper libraries if [[ ${FORTRANC} == "gfortran" ]]; then libs="-lpthread -lgfortran" else libs="-lpthread -lg2c" fi sed -e "s/SHRD_LNK/${libs}/g" -i Make.top || \ die "Failed to add addtional libs to shared object build" cp "${FILESDIR}"/war "${BUILDDIR}" chmod a+x "${BUILDDIR}"/war } # Added to allow compilation on sparc architecture. The default CCFLAG0 # and MMFLAGS are *bad*. # Danny van Dyk 2004/07/02 # # reconfigure() { # case "`uname -p`" in # "sun4m") # MY_CCFLAGS="-O3 -mcpu=v8" # MY_CXXFLAGS="${MY_CCFLAGS}" # MY_MMFLAGS="-O -mcpu=v8" # MY_LDFLAGS="" # ;; # "sun4u") # MY_CCFLAGS="-O3 -mcpu=ultrasparc" # MY_CXXFLAGS="${MY_CCFLAGS}" # MY_MMFLAGS="-O -mcpu=ultrasparc" # MY_LDFLAGS="" # ;; # *) # MY_CCFLAGS="${CFLAGS}" # MY_CXXFLAGS="${CXXFLAGS}" # MY_MMFLAGS="${CFLAGS}" # MY_LDFLAGS="${LDFLAGS}" # ;; # esac # MY_FILE="`find -name Make.Linux*`" # sed -i -e "s/CCFLAG0 =.*/CCFLAG0 = \$(CDEFS) ${MY_CCFLAGS}/" \ # -e "s/CCFLAGS =.*/CCFLAGS = \$(CDEFS) ${MY_CCFLAGS}/" \ # -e "s/CLINKFLAGS =.*/CLINKFLAGS =\$(CDEFS) ${MY_LDFLAGS}/" \ # -e "s/XCCFLAGS =.*/XCCFLAGS =\$(CDEFS) ${MY_CXXFLAGS}/" \ # -e "s/MMFLAGS =.*/MMFLAGS = ${MY_MMFLAGS}/" \ # ${MY_FILE} || die "sed didnt complete" # } src_compile() { cd "${BUILDDIR}" ../configure --cc="$(tc-getCC) -DUSE_LIBTOOL" \ --prefix="${DESTTREE}/$(get_libdir)" -Si cputhrchk 0 || die make CC="$(tc-getCC) -DUSE_LIBTOOL" || die # reconfigure # TMPSTR=$(ls Make.Linux*) # ATLAS_ARCH=${TMPSTR#'Make.'} # make install arch=${ATLAS_ARCH} || \ # die "Failed to install blas-atlas" make shared-strip RPATH=${RPATH}/atlas || \ die "Failed to build shared libraries" # Build shared versions of the threaded libs. # ATLAS only compiles threaded libs on multiprocessor machines. if [ -d gentoo/libptf77blas.a ] then make ptshared-strip \ arch=${ATLAS_ARCH} RPATH=${RPATH}/threaded-atlas || die fi } src_install () { dodir "${RPATH}"/atlas cd "${BUILDDIR}"/gentoo/libs cp -P libatlas* "${D}/${DESTTREE}/$(get_libdir)" || \ die "Failed to install libatlas" cp -P *blas* "${D}/${RPATH}"/atlas || \ die "Failed to install blas/cblas" insinto ${RPATH} doins ${FILESDIR}/c-ATLAS ${FILESDIR}/f77-ATLAS if [ -d "${S}"/gentoo/threaded-libs ] then dodir "${RPATH}"/threaded-atlas cd "${S}"/gentoo/threaded-libs cp -P * "${D}/${RPATH}"/threaded-atlas || \ die "Failed to install threaded atlas" doins ${FILESDIR}/c-threaded-ATLAS ${FILESDIR}/f77-threaded-ATLAS fi insinto "${DESTTREE}"/include/atlas doins "${S}"/include/cblas.h "${S}"/include/atlas_misc.h doins "${S}"/include/atlas_enum.h # These headers contain the architecture-specific # optimizations determined by ATLAS. The atlas-lapack build # is much shorter if they are available, so save them: doins "${S}/include/${ATLAS_ARCH}"/*.h #some docs cd "${S}" dodoc README doc/{AtlasCredits.txt,ChangeLog} use doc && dodoc doc/*.ps } pkg_postinst() { local THREADED if [ -d "${RPATH}"/threaded-atlas ] then THREADED="threaded-" fi ${DESTTREE}/bin/blas-config ${THREADED}ATLAS elog elog "Fortran users link using -lblas" elog elog "C users compile against the header ${ROOT}usr/include/atlas/cblas.h and" elog "link using -lcblas" elog elog "If using threaded ATLAS, you may also need to link with -lpthread." # elog # elog "Configuration now uses eselect rather than blas-config." }