# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 inherit fortran toolchain-funcs DESCRIPTION="Find total energy, charge density and electronic structure using density functional theory" HOMEPAGE="http://www.abinit.org/" SRC_URI="ftp://ftp.abinit.org/pub/abinitio/ABINIT_v${PV}/${P}.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64 ~ppc ~x86" IUSE="mpi fox netcdf etsf_io libxc bigdft wannier90 test" RDEPEND="virtual/blas virtual/lapack mpi? ( virtual/mpi ) fox? ( sci-libs/fox ) netcdf? ( sci-libs/netcdf ) etsf_io? ( sci-libs/etsf_io ) libxc? ( =sci-libs/libxc-0.9-r1 ) bigdft? ( =sci-libs/bigdft-1.0.1 ) wannier90? ( sci-libs/wannier90 )" DEPEND="${RDEPEND}" # F90 code, g77 won't work FORTRAN="gfortran ifc mpif90" pkg_setup() { fortran_pkg_setup # Doesn't compile with gcc-4.0, only >=4.1 local diemsg="Requires gcc-4.1 or newer" if [[ "${FORTRANC}" = "gfortran" ]]; then if [[ $(gcc-major-version) -eq 4 ]] \ && [[ $(gcc-minor-version) -lt 1 ]]; then die "${diemsg}" fi fi if use etsf_io && ! use netcdf; then eerror "USE etsf_io depends on USE netcdf, but USE netcdf disabled" eerror "Pleas, enable USE netcdf or disable USE etsf_io" die fi } src_unpack() { unpack ${A} cd "${S}" epatch "${FILESDIR}"/5.3.4-change-default-directories.patch epatch "${FILESDIR}"/5.6.4-FoX.patch # Yea for breaking compatibility with no ChangeLog entry in 2.60 if has_version '>=sys-devel/autoconf-2.60'; then sed -i -e "s:_AC_SRCPATHS:_AC_SRCDIRS:g" config/m4/init.m4 fi eautoreconf } src_compile() { local FoX_fcflags="" local FoX_libs="" if use fox; then FoX_fcflags=`FoX-config --fcflags` FoX_libs="-L/usr/lib `FoX-config --libs \ |sed -e's/\S*\/lib\([^/]\+\>\)\.a/-l\1/g'`" fi # --with--includes apparently not respected # passing -I/usr/lib/finclude with FFLAGS # --with-plugins-prefix=/usr \ econf \ $(use_enable mpi) \ $(use_enable fox) \ $(use_enable netcdf) \ $(use_enable etsf_io etsf-io) \ $(use_enable libxc etsf-xc) \ $(use_enable bigdft) \ $(use_enable wannier90) \ --with-linalg-libs="`pkg-config --libs lapack`" \ --with-fox-includes="${FoX_fcflags}" \ --with-fox-libs="${FoX_libs}" \ --with-netcdf-includes="-I/usr/include" \ --with-netcdf-libs="-L/usr/lib -lnetcdff" \ --with-etsf-io-includes="-I/usr/lib/finclude" \ --with-etsf-io-libs="-L/usr/lib -letsf_io -letsf_io_low_level -letsf_io_utils" \ --with-etsf-xc-includes="-I/usr/lib/finclude" \ --with-etsf-xc-libs="-L/usr/lib -lxc -lstring_f" \ --with-bigdft-includes="-I/usr/include/gcc" \ --with-bigdft-libs="-L/usr/lib -lpoissonsolver -lbigdft" \ --with-wannier90="/usr/bin/wannier90.x" \ --with-wannier90-includes="-I/usr/lib/finclude" \ --with-wannier90-libs="-L/usr/lib -lwannier" \ --with-cc-optflags="${CFLAGS}" \ --with-fc-optflags="${FFLAGS}" \ --with-fc-ld-optlibs='-lpthread' \ FC="${FORTRANC}" \ CC="$(tc-getCC)" \ LD="$(tc-getLD)" \ || die "configure failed" if use mpi; then emake multi || die "make multi failed" else emake || die "make failed" fi } src_test() { einfo "The tests take quite a while, on the order of 1-2 hours" einfo "on an Intel Penryn (2.5 GHz)." cd "${S}"/tests emake tests_dev local REPORT for REPORT in $(find . -name report); do REPORT=${REPORT#*/} elog "Parameters and unusual results for ${REPORT%%/*} tests" while read line; do elog "${line}" echo "${line}" >>tests_summary.txt done \ < <(grep -v -e succeeded -e passed ${REPORT}) done local testdir find . -name ",,test*" -print | \ while read testdir; do if [ -e tests_summary.tar ]; then tar rvf tests_summary.tar ${testdir} else tar cvf tests_summary.tar ${testdir} fi done gzip tests_summary.tar elog "The full test results will be installed as summary_tests.tar.gz." elog "Also a concise report tests_summary.txt is installed." } src_install() { emake DESTDIR="${D}" install || die "make install failed" if use test; then dodoc tests/tests_summary.txt || die "Copying tests summary failed" dodoc tests/summary_tests.tar.gz || die "Copying tests summary failed" fi dodoc KNOWN_PROBLEMS README || die "Copying doc files failed" } pkg_postinst() { if use test; then elog "The full test results will be installed as summary_tests.tar.gz." elog "Also a concise report tests_summary.txt is installed." fi }