1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_4 )
8 inherit autotools java-pkg-opt-2 python-r1 eutils toolchain-funcs
10 DESCRIPTION="SELinux policy tools"
11 HOMEPAGE="http://www.tresys.com/selinux/selinux_policy_tools.shtml"
12 SRC_URI="http://oss.tresys.com/projects/setools/chrome/site/dists/${P}/${P}.tar.bz2
13 https://dev.gentoo.org/~perfinion/patches/setools/${P}-04-gentoo-patches.tar.bz2"
18 IUSE="X debug java python"
20 COMMONDEPEND=">=sys-libs/libsepol-2.4
21 >=sys-libs/libselinux-2.4
24 python? ( ${PYTHON_DEPS} )
26 >=dev-lang/tk-8.4.9:0=
27 >=gnome-base/libglade-2.0
31 DEPEND="${COMMONDEPEND}
32 >=sys-devel/automake-1.12.1
38 python? ( dev-lang/swig )"
40 RDEPEND="${COMMONDEPEND}
41 java? ( >=virtual/jre-1.4:= )
42 X? ( >=dev-tcltk/bwidget-1.8 )"
45 # setools dirs that contain python code to build
46 PYTHON_DIRS="libapol/swig/python libpoldiff/swig/python libqpol/swig/python libseaudit/swig/python libsefs/swig/python python"
50 java-pkg-opt-2_pkg_setup
55 EPATCH_MULTI_MSG="Applying various (Gentoo) setool fixes... " \
56 EPATCH_SUFFIX="patch" \
57 EPATCH_SOURCE="${WORKDIR}/gentoo-patches" \
61 # Fix build failure due to double __init__.py installation
62 sed -e "s/^wrappedpy_DATA = qpol.py \$(pkgpython_PYTHON)/wrappedpy_DATA = qpol.py/" -i libqpol/swig/python/Makefile.am || die
63 # Disable broken check for SWIG version. Bug #542032
64 sed -e "s/AC_PROG_SWIG(2.0.0)/AC_PROG_SWIG/" -i configure.ac || die "sed failed"
67 for dir in ${PYTHON_DIRS}; do
68 # Python bindings are built/installed manually.
69 sed -e "s/MAYBE_PYSWIG = python/MAYBE_PYSWIG =/" -i ${dir%python}Makefile.am || die "sed failed"
70 # Make PYTHON_LDFLAGS replaceable during running `make`.
71 sed -e "/^AM_LDFLAGS =/s/@PYTHON_LDFLAGS@/\$(PYTHON_LDFLAGS)/" -i ${dir}/Makefile.am || die "sed failed"
78 # Disable byte-compilation of Python modules.
79 echo '#!/bin/sh' > py-compile
83 tc-ld-disable-gold #467136
85 --with-java-prefix=${JAVA_HOME} \
86 --disable-selinux-check \
87 --disable-bwidget-check \
88 $(use_enable python swig-python) \
89 $(use_enable java swig-java) \
90 $(use_enable X swig-tcl) \
94 # work around swig c99 issues. it does not require
96 sed -i -e 's/-std=gnu99//' "${S}/libseaudit/swig/python/Makefile"
104 python_export PYTHON_INCLUDEDIR
105 python_export PYTHON_SITEDIR
106 python_export PYTHON_LIBS
108 SWIG_PYTHON_CPPFLAGS="-I${PYTHON_INCLUDEDIR}" \
109 PYTHON_LDFLAGS="${PYTHON_LIBS}" \
110 pyexecdir="${PYTHON_SITEDIR}" \
111 pythondir="${PYTHON_SITEDIR}" \
115 for dir in ${PYTHON_DIRS}; do
116 python_foreach_impl building ${dir}
122 emake DESTDIR="${D}" install
126 python_export PYTHON_SITEDIR
127 emake DESTDIR="${D}" \
128 pyexecdir="${PYTHON_SITEDIR}" \
129 pythondir="${PYTHON_SITEDIR}" \
134 for dir in ${PYTHON_DIRS}; do
135 python_foreach_impl installation "${dir}"