b644c1057e26e9884a8ace33e038dda63f57d20a
[gentoo.git] / sys-devel / flex / flex-2.6.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5
6 inherit eutils flag-o-matic ltprune multilib-minimal
7
8 DESCRIPTION="The Fast Lexical Analyzer"
9 HOMEPAGE="https://flex.sourceforge.net/ https://github.com/westes/flex"
10 SRC_URI="https://github.com/westes/flex/releases/download/v${PV}/${P}.tar.xz"
11
12 LICENSE="FLEX"
13 SLOT="0"
14 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 m68k ~mips ppc ppc64 s390 sparc x86 ~ppc-aix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
15 IUSE="nls static test"
16 RESTRICT="!test? ( test )"
17
18 # We want bison explicitly and not yacc in general #381273
19 RDEPEND="sys-devel/m4"
20 DEPEND="${RDEPEND}
21         app-arch/xz-utils
22         nls? ( sys-devel/gettext )
23         test? ( sys-devel/bison )"
24
25 src_prepare() {
26         # Disable running in the tests/ subdir as it has a bunch of built sources
27         # that cannot be made conditional (automake limitation). #568842
28         if ! use test ; then
29                 sed -i \
30                         -e '/^SUBDIRS =/,/^$/{/tests/d}' \
31                         Makefile.in || die
32         fi
33 }
34
35 src_configure() {
36         use static && append-ldflags -static
37
38         multilib-minimal_src_configure
39 }
40
41 multilib_src_configure() {
42         # Do not install shared libs #503522
43         ECONF_SOURCE=${S} \
44         econf \
45                 --disable-shared \
46                 $(use_enable nls) \
47                 --docdir='$(datarootdir)/doc/'${PF}
48 }
49
50 multilib_src_compile() {
51         if multilib_is_native_abi; then
52                 default
53         else
54                 cd src || die
55                 emake -f Makefile -f - lib <<< 'lib: $(lib_LTLIBRARIES)'
56         fi
57 }
58
59 multilib_src_test() {
60         multilib_is_native_abi && emake check
61 }
62
63 multilib_src_install() {
64         if multilib_is_native_abi; then
65                 default
66         else
67                 cd src || die
68                 emake DESTDIR="${D}" install-libLTLIBRARIES install-includeHEADERS
69         fi
70 }
71
72 multilib_src_install_all() {
73         einstalldocs
74         dodoc ONEWS
75         prune_libtool_files --all
76         rm "${ED}"/usr/share/doc/${PF}/COPYING || die
77         dosym flex /usr/bin/lex
78 }