sci-mathematics/rstudio: Thanks to tomboy-64 for fixing bug Bug 534152 - sci-mathemat...
[gentoo.git] / app-admin / setools / setools-3.3.8-r7.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6 PYTHON_COMPAT=( python2_7 python3_4 )
7
8 inherit autotools java-pkg-opt-2 python-r1 eutils toolchain-funcs
9
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"
14
15 LICENSE="GPL-2"
16 SLOT="0"
17 KEYWORDS="amd64 x86"
18 IUSE="X debug java python"
19
20 COMMONDEPEND=">=sys-libs/libsepol-2.4
21         >=sys-libs/libselinux-2.4
22         >=dev-db/sqlite-3.2:3
23         dev-libs/libxml2:2
24         python? ( ${PYTHON_DEPS} )
25         X? (
26                 >=dev-lang/tk-8.4.9:0=
27                 >=gnome-base/libglade-2.0
28                 >=x11-libs/gtk+-2.8:2
29         )"
30
31 DEPEND="${COMMONDEPEND}
32         >=sys-devel/automake-1.12.1
33         sys-devel/bison
34         sys-devel/flex
35         virtual/pkgconfig
36         java? ( dev-lang/swig
37                 virtual/jdk:= )
38         python? ( dev-lang/swig )"
39
40 RDEPEND="${COMMONDEPEND}
41         java? ( >=virtual/jre-1.4:= )
42         X? ( >=dev-tcltk/bwidget-1.8 )"
43
44 RESTRICT="test"
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"
47
48 pkg_setup() {
49         if use java; then
50                 java-pkg-opt-2_pkg_setup
51         fi
52 }
53
54 src_prepare() {
55         EPATCH_MULTI_MSG="Applying various (Gentoo) setool fixes... " \
56         EPATCH_SUFFIX="patch" \
57         EPATCH_SOURCE="${WORKDIR}/gentoo-patches" \
58         EPATCH_FORCE="yes" \
59         epatch
60
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"
65
66         local dir
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"
72         done
73
74         epatch_user
75
76         eautoreconf
77
78         # Disable byte-compilation of Python modules.
79         echo '#!/bin/sh' > py-compile
80 }
81
82 src_configure() {
83         tc-ld-disable-gold #467136
84         econf \
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) \
91                 $(use_enable X gui) \
92                 $(use_enable debug)
93
94         # work around swig c99 issues.  it does not require
95         # c99 anyway.
96         sed -i -e 's/-std=gnu99//' "${S}/libseaudit/swig/python/Makefile"
97 }
98
99 src_compile() {
100         emake
101
102         if use python; then
103                 building() {
104                         python_export PYTHON_INCLUDEDIR
105                         python_export PYTHON_SITEDIR
106                         python_export PYTHON_LIBS
107                         emake \
108                                 SWIG_PYTHON_CPPFLAGS="-I${PYTHON_INCLUDEDIR}" \
109                                 PYTHON_LDFLAGS="${PYTHON_LIBS}" \
110                                 pyexecdir="${PYTHON_SITEDIR}" \
111                                 pythondir="${PYTHON_SITEDIR}" \
112                                 -C "$1"
113                 }
114                 local dir
115                 for dir in ${PYTHON_DIRS}; do
116                         python_foreach_impl building ${dir}
117                 done
118         fi
119 }
120
121 src_install() {
122         emake DESTDIR="${D}" install
123
124         if use python; then
125                 installation() {
126                         python_export PYTHON_SITEDIR
127                         emake DESTDIR="${D}" \
128                                 pyexecdir="${PYTHON_SITEDIR}" \
129                                 pythondir="${PYTHON_SITEDIR}" \
130                                 -C "$1" install
131                 }
132
133                 local dir
134                 for dir in ${PYTHON_DIRS}; do
135                         python_foreach_impl installation "${dir}"
136                 done
137         fi
138 }