*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-libs / stfl / stfl-0.24.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5 PYTHON_COMPAT=( python{2_7,3_6} )
6 GENTOO_DEPEND_ON_PERL=no
7 inherit eutils multilib perl-module python-r1 toolchain-funcs
8
9 DESCRIPTION="A library which implements a curses-based widget set for text terminals"
10 HOMEPAGE="http://www.clifford.at/stfl/"
11 SRC_URI="http://www.clifford.at/${PN}/${P}.tar.gz"
12
13 LICENSE="LGPL-3"
14 SLOT="0"
15 KEYWORDS="amd64 ppc ~ppc64 x86"
16 IUSE="examples perl python ruby static-libs"
17 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
18
19 RDEPEND="
20         sys-libs/ncurses:0=[unicode]
21         perl? ( dev-lang/perl:= )
22         ruby? ( dev-lang/ruby:* )
23         python? ( ${PYTHON_DEPS} )
24 "
25 DEPEND="${RDEPEND}
26         perl? ( dev-lang/swig )
27         python? ( >=dev-lang/swig-1.3.40 )
28         ruby? ( dev-lang/swig )
29 "
30
31 src_prepare() {
32         sed -i \
33                 -e 's/-Os -ggdb//' \
34                 -e 's/^\(all:.*\) example/\1/' \
35                 -e 's/$(CC) -shared/$(CC) $(LDFLAGS) -shared/' \
36                 -e 's/ -o $@ $(LDLIBS) $^/ $^ $(LDLIBS) -o $@/' \
37                 -e 's/-lncursesw/-lncursesw -pthread/' \
38                 Makefile || die "sed failed"
39
40         if ! use static-libs ; then
41                 sed -i -e "/install .* libstfl.a/d" Makefile || die
42         fi
43
44         epatch "${FILESDIR}"/${PN}-0.21-python.patch
45         epatch "${FILESDIR}"/${PN}-0.22-soname-symlink.patch
46         epatch "${FILESDIR}"/${PN}-0.22-ruby-sharedlib.patch
47
48         if use perl ; then
49                 echo "FOUND_PERL5=1" >> Makefile.cfg
50         else
51                 echo "FOUND_PERL5=0" >> Makefile.cfg
52         fi
53
54         if use ruby ; then
55                 echo "FOUND_RUBY=1" >> Makefile.cfg
56         else
57                 echo "FOUND_RUBY=0" >> Makefile.cfg
58         fi
59
60         echo "FOUND_PYTHON=0" >> Makefile.cfg
61 }
62
63 src_configure() { :; }
64
65 src_compile() {
66         emake CC="$(tc-getCC)"
67
68         if use python ; then
69                 local BUILD_DIR="${S}/python"
70                 python_copy_sources
71
72                 # Based on code from python/Makefile.snippet.
73                 building() {
74                         pushd "${BUILD_DIR}" &>/dev/null || die
75                         echo swig -python -threads stfl.i
76                         swig -python -threads stfl.i || die
77                         echo "$(tc-getCC)" ${CFLAGS} ${LDFLAGS} -shared -pthread -fPIC stfl_wrap.c -I$(python_get_includedir) -I.. ../libstfl.so.${PV} -lncursesw -o _stfl.so
78                         "$(tc-getCC)" ${CFLAGS} ${LDFLAGS} -shared -pthread -fPIC stfl_wrap.c -I$(python_get_includedir) -I.. ../libstfl.so.${PV} -lncursesw -o _stfl.so || die
79                         popd &>/dev/null || die
80                 }
81                 python_foreach_impl building
82         fi
83 }
84
85 src_install() {
86         emake prefix="/usr" DESTDIR="${D}" libdir="$(get_libdir)" install
87
88         if use python ; then
89                 local BUILD_DIR="${S}/python"
90
91                 installation() {
92                         pushd "${BUILD_DIR}" &>/dev/null || die
93                         python_domodule stfl.py _stfl.so
94                         popd &>/dev/null || die
95                 }
96                 python_foreach_impl installation
97         fi
98
99         dodoc README
100
101         local exdir="/usr/share/doc/${PF}/examples"
102         if use examples ; then
103                 insinto ${exdir}
104                 doins example.{c,stfl}
105                 insinto ${exdir}/python
106                 doins python/example.py
107                 if use perl ; then
108                         insinto ${exdir}/perl
109                         doins perl5/example.pl
110                 fi
111                 if use ruby ; then
112                         insinto ${exdir}/ruby
113                         doins ruby/example.rb
114                 fi
115         fi
116
117         perl_delete_localpod
118 }