# Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ EAPI=5 PYTHON_COMPAT=( python2_7 python3_4 ) inherit scons-utils python-r1 flag-o-matic toolchain-funcs DESCRIPTION="Integrated grounder and solver for answer set logic programs." HOMEPAGE="http://potassco.sourceforge.net/" SRC_URI="mirror://sourceforge/potassco/${P}-source.tar.gz -> ${P}.tar.gz doc? ( mirror://sourceforge/potassco/guide-2.0.pdf -> ${P}-doc.pdf examples? ( mirror://sourceforge/potassco/guide-2.0-examples.tar.gz -> ${P}-doc-examples.tar.gz ) )" LICENSE="GPL-3" SLOT="0" KEYWORDS="~amd64" IUSE="python lua threads doc examples" REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" RDEPEND="python? ( ${PYTHON_DEPS} ) lua? ( >=dev-lang/lua-5.1:* ) threads? ( >=dev-cpp/tbb-4.1 )" DEPEND="${RDEPEND} >=dev-util/re2c-0.13.5 >=sys-devel/bison-2.5 virtual/pkgconfig >=dev-util/scons-2.1 || ( >=sys-devel/gcc-4.8 >=sys-devel/clang-3.1 )" S="${WORKDIR}/${P}-source" pkg_setup() { scons_targets=( clingo gringo reify ) use lua && scons_targets+=( luaclingo ) append-cxxflags -std=c++11 scons_vars=( CXX="$(tc-getCXX)" CXXFLAGS="${CXXFLAGS}" --build-dir=release ) if use python ; then python_setup scons_vars+=( WITH_PYTHON=auto PYTHON_CONFIG="$(python_get_PYTHON_CONFIG)" ) fi } src_unpack() { default if use doc && use examples ; then mv guide-2.0-examples "${S}/examples/guide" || die fi } src_configure() { escons "${scons_vars[@]}" configure local varfile="${S}/build/release.py" if ! use python ; then sed -i -e 's/^WITH_PYTHON.*$/WITH_PYTHON = None/' "$varfile" \ || die "couldn't disable Python" fi if ! use lua ; then sed -i -e 's/^WITH_LUA.*$/WITH_LUA = None/' "$varfile" \ || die "couldn't disable Lua" fi if ! use threads ; then sed -i -e 's/^WITH_TBB.*$/WITH_TBB = None/' "$varfile" \ || die "couldn't disable TBB" fi sed -i -e 's/^WITH_CPPUNIT.*$/WITH_CPPUNIT = None/' "$varfile" \ || die "couldn't disable CppUnit" } src_compile() { escons "${scons_vars[@]}" "${scons_targets[@]}" python_build() { escons "${scons_vars[@]/#PYTHON_CONFIG=*/PYTHON_CONFIG="$(python_get_PYTHON_CONFIG)"}" \ pyclingo mkdir "${WORKDIR}/${EPYTHON}-mod" cp build/release/python/gringo.so "${WORKDIR}/${EPYTHON}-mod" } if use python ; then python_foreach_impl python_build if use doc ; then export PYTHONPATH="${WORKDIR}/${EPYTHON}-mod" pushd examples/clingo/pydoc > /dev/null || die # this example script works in both Python 2.* and 3.* "${PYTHON}" pydoc-lib.py || die "pydoc generation failed" popd > /dev/null || die fi fi } src_install() { dodoc CHANGES README if use doc ; then newdoc "${DISTDIR}/${P}-doc.pdf" potassco_user_guide.pdf use python && dohtml examples/clingo/pydoc/gringo.html fi if use examples ; then docompress -x "/usr/share/doc/${PF}/examples" dodoc -r examples fi dobin build/release/{clingo,gringo,reify} if use lua ; then exeinto "$($(tc-getPKG_CONFIG) --variable=INSTALL_CMOD lua)" doexe build/release/lua/gringo.so fi python_install() { python_domodule "${WORKDIR}/${EPYTHON}-mod/gringo.so" } use python && python_foreach_impl python_install }