# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils toolchain-funcs DESCRIPTION="The Scalable Parallel Random Number Generators Library" HOMEPAGE="http://sprng.cs.fsu.edu" SRC_URI="http://sprng.cs.fsu.edu/Version4.0/${PN}4.tar.gz" LICENSE="as-is" SLOT="0" KEYWORDS="~x86 ~amd64 ~mips" IUSE="doc fortran mpi" DEPEND="dev-libs/gmp mpi? ( || (sys-cluster/mpich sys-cluster/mpich2 ) )" # package folder is explicit #S="${WORKDIR}/${PN}4" # Where should the executables go? EXECDIR="${ROOT}/usr/bin" # BIG WARNING! # The fortran interface currently does not work. Do not use fortran! # This is currently believed to be a problem with the sprng source code. src_compile() { PLAT="GENERIC" ARCH=`uname -m` # Edit make.CHOICES to refer to make.GENERIC einfo "Compiling sprng for ${PLAT} platform" sed -i "s/^PLAT = INTEL/#PLAT = INTEL/g" make.CHOICES sed -i "s/^#PLAT = GENERIC/PLAT = GENERIC/g" make.CHOICES # Get the proper c compiler sed -i "s:^CC = gcc:CC = $(tc-getCC):g" SRC/make.GENERIC # Edit make.CHOICES and make.GENERIC if using MPI if use mpi; then einfo "compiling with mpi support" sed -i "s/^#MPIDEF = -DSPRNG_MPI/MPIDEF = -DSPRING-MPI/g" make.CHOICES sed -i "s/^MPIF77 = \$(F77)/MPIF77 = mpif77/g" SRC/make.GENERIC sed -i "s/^MPICC = \$(CC)/MPICC = mpicc/g" SRC/make.GENERIC sed -i "s/^MPILIB =/MPILIB = -lmpich -lrt/g" SRC/make.GENERIC else einfo "compiling without mpi support" fi # Edit make.GENERIC for fortran use if use fortran; then einfo "compiling with fortran support" sed -i "s:^F77 = f77:F77 = $(tc-getF77):g" SRC/make.GENERIC sed -i "s/-DAdd_/-DAdd__/g" SRC/make.GENERIC else einfo "compiling without fortran support" sed -i "s/^F77 = f77/F77 = echo/g" SRC/make.GENERIC fi # Edit make.GENERIC to add ranlib support sed -i "s/^RANLIB = echo/#RANLIB = echo/g" SRC/make.GENERIC sed -i "s/^#RANLIB = ranlib/RANLIB=ranlib/g" SRC/make.GENERIC # Change -O flag to -O2 sed -i "s/-O/-O2/g" SRC/make.GENERIC # The compilation of pmlcg is complicated by sprng including gmp.h in the # sprng/SRC/pmlcg directory. The resident gentoo developer (joelm) # thinks that this is the wrong way to do things. The following # makes it work the right way by: # # 1) removing gmp.h from .../SRC/pmlcg # 2) creating a new gmp.h in .../SRC/pmlcg # with line #include # # Remove gmp.h from sprng-2.0/SRC/pmlcg rm SRC/pmlcg/gmp.h # add #include to gmp.h echo "#include " > SRC/pmlcg/gmp.h # Compile. Sprng Makefile is weird and emake doesn't like it. # Using make. cd SRC make || die "make failed" cd .. } src_test() { ARCH=`uname -m` cd ${S} # We need to change the default example make to serial + parallel # if using mpi if use mpi ; then sed -i "s/^serial : \$(EX)/serial : \$(EX) \$(MPIEX)/g" EXAMPLES/Makefile fi # make examples and tests make || die "Test/Examples make failed" # Run Tests einfo "Beginning test suite" ./checksprng | tee tests.log } src_install() { #Examples List: EXLIST="sprng seed checkpoint invalid_ID sprng-simple simple-simple \ seed-simple checkpoint-simple spawn sprngf seedf checkpointf invalid_IDf \ spawnf sprngf-simple simplef-simple seedf-simple checkpointf-simple \ pi-simple pif-simple" #Mpi Examples List: MPIEXLIST="sprng_mpi fsprng_mpi 2streams_mpi seed_mpi message_mpi \ sprng-simple_mpi fsprng-simple_mpi seed-simple_mpi message-simple_mpi \ sprngf_mpi fsprngf_mpi seedf_mpi messagef_mpi 2streamsf_mpi \ sprngf-simple_mpi fsprngf-simple_mpi seedf-simple_mpi \ messagef-simple_mpi pi-simple_mpi" #Tests List: TESTSLIST="maxt collisions equidist serial gap perm runs coupon poker \ sumrandom_walk wolff metropolis" cd ${S} dolib lib/libsprng*.a insinto /usr/include doins include/interface.h include/sprng.h if use fortran; then doins include/sprng_f.h fi dodoc DOCS/README if use doc; then echo ">>> Unpacking ${PN}.html.tar.Z to $PWD/DOCS" cd DOCS && tar -Zxf ${PN}.html.tar.Z dohtml www/* fi cd ${S}/EXAMPLES dobin ${EXLIST} use mpi && dobin ${MPIEXLIST} cd ${S}/TESTS dobin *.sprng }