# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/sci-libs/blas-goto/blas-goto-1.26.ebuild,v 1.2 2009/08/18 14:22:19 bicatali Exp $ inherit eutils fortran flag-o-matic toolchain-funcs EAPI="2" MY_PN="GotoBLAS2" MY_P="${MY_PN}-${PV}" DESCRIPTION="Fast implementations of the Basic Linear Algebra Subroutines" HOMEPAGE="http://www.tacc.utexas.edu/research-development/tacc-projects/" SRC_URI="${MY_P}.tar.gz" LICENSE="tacc" SLOT="0" KEYWORDS="~x86 ~amd64" IUSE="int64 threads doc openmp" RESTRICT="fetch" DOWNLOAD_URL="${HOMEPAGE}" RDEPEND="app-admin/eselect-blas doc? ( app-doc/blas-docs ) openmp? ( >=sys-devel/gcc-4.3[openmp] )" DEPEND="app-admin/eselect-blas >=sys-devel/binutils-2.17" S="${WORKDIR}/${MY_PN}" FORTRAN="gfortran g77 ifc" ESELECT_PROF=goto pkg_nofetch() { einfo "Please download ${SRC_URI} from" einfo "${DOWNLOAD_URL}" einfo "and place it in ${DISTDIR}." } src_unpack() { unpack ${A} cd "${S}" # patch to link with m and fortran libs, works with asneeded epatch "${FILESDIR}"/${P}-sharedlibs.patch # Get and test C (cross-) compiler C_COMPILER=$(tc-getCC) if [[ $(tc-getCC) != *gcc ]]; then ewarn "Your C compiler is set to $(tc-getCC)." ewarn "${PN} needs gcc to inline assembler, others compilers have reported failures." die "Incompatible C compiler, need gcc." fi # Get Fortran compiler case ${FORTRANC} in g77) F_COMPILER=G77;; gfortran) F_COMPILER=GFORTRAN;; ifc|ifort) F_COMPILER=INTEL;; *) die "Invalid Fortran compiler: ${FORTRANC}; valid are ${FORTRAN}." esac # Set compilers sed -i \ -e "s:^# \(CC\s*=\).*:\1 ${C_COMPILER}:g" \ -e "s:^# \(FC\s*=\).*:\1 ${F_COMPILER}:g" \ Makefile.rule \ || die "sed for compilers failed" # Set Threads use threads && THREADS=1 || THREADS=0 sed -i \ -e "s:^# \(USE_THREAD\s*=\).*:\1 ${THREADS}:g" \ Makefile.rule \ || die "sed for threads failed" # Set BINARY use amd64 && BINARY=64 || BINARY=32 sed -i \ -e "s:^# \(BINARY\s*=\).*:\1 ${BINARY}:g" \ Makefile.rule \ || die "sed for binary failed" # Set integer interface use int64 && INT64=1 || INT64=0 use int64 && ESELECT_PROF="${ESELECT_PROF}-int64" sed -i \ -e "s:^# \(INTERFACE64\s*=\).*:\1 ${INT64}:g" \ Makefile.rule \ || die "sed for 64 integers failed" # Set OpenMP use openmp && OPENMP=1 || OPENMP=0 sed -i \ -e "s:^# \(USE_OPENMP\s*=\).*:\1 ${OPENMP}:g" \ Makefile.rule \ || die "sed for 64 binary failed" } src_compile() { # Make static library emake LDFLAGS="$(raw-ldflags)" || die "emake failed" # Make shared library cd exports emake so -j1 || die "emake failed" } src_test() { cd test emake || die "emake test failed" make clean } src_install() { local install_dir=/usr/$(get_libdir)/blas/goto dodir ${install_dir} # dolib.so doesn't support our alternate locations exeinto ${install_dir} doexe libgoto2_*.so || die "installing shared lib failed" dosym libgoto2_*.so ${install_dir}/libgoto2.so dosym libgoto2_*.so ${install_dir}/libgoto2.so.0 dosym libgoto2_*.so ${install_dir}/libgoto2.so.0.0.0 # dolib.a doesn't support our alternate locations insinto ${install_dir} doins libgoto2_*.a || die "installing static lib failed" dosym libgoto2_*.a ${install_dir}/libgoto2.a dodoc 01Readme.txt 03FAQ.txt || die cp "${FILESDIR}"/blas.pc.in blas.pc local extlibs="" use threads && extlibs="${extlibs} -lpthread" sed -i \ -e "s/@LIBDIR@/$(get_libdir)/" \ -e "s/@PV@/${PV}/" \ -e "s/@EXTLIBS@/${extlibs}/" \ blas.pc || die "sed blas.pc failed" insinto /usr/$(get_libdir)/blas/goto doins blas.pc eselect blas add $(get_libdir) "${FILESDIR}"/eselect.blas.goto ${ESELECT_PROF} } pkg_postinst() { local p=blas local current_lib=$(eselect ${p} show | cut -d' ' -f2) if [[ ${current_lib} == ${ESELECT_PROF} || -z ${current_lib} ]]; then # work around eselect bug #189942 local configfile="${ROOT}"/etc/env.d/${p}/$(get_libdir)/config [[ -e ${configfile} ]] && rm -f ${configfile} eselect ${p} set ${ESELECT_PROF} elog "${p} has been eselected to ${ESELECT_PROF}" else elog "Current eselected ${p} is ${current_lib}" elog "To use ${p} ${ESELECT_PROF} implementation, you have to issue (as root):" elog "\t eselect ${p} set ${ESELECT_PROF}" fi }