18940acd6a1bb33d1a852e1ed221d52039e08bc7
[gentoo.git] / sys-devel / flex / flex-2.6.4-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit eutils flag-o-matic libtool 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/${PN}/releases/download/v${PV}/${P}.tar.gz"
11
12 LICENSE="FLEX"
13 SLOT="0"
14 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sh sparc x86 ~ppc-aix ~x64-cygwin ~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 PATCHES=(
26         "${FILESDIR}"/${PN}-2.6.4-libobjdir.patch
27         "${FILESDIR}"/${PN}-2.6.4-fix-build-with-glibc2.6+.patch
28 )
29
30 src_prepare() {
31         default
32
33         # Disable running in the tests/ subdir as it has a bunch of built sources
34         # that cannot be made conditional (automake limitation). #568842
35         if ! use test ; then
36                 sed -i \
37                         -e '/^SUBDIRS =/,/^$/{/tests/d}' \
38                         Makefile.in || die
39         fi
40         elibtoolize # Prefix always needs this
41 }
42
43 src_configure() {
44         use static && append-ldflags -static
45
46         multilib-minimal_src_configure
47 }
48
49 multilib_src_configure() {
50         # Do not install shared libs #503522
51         ECONF_SOURCE=${S} \
52         econf \
53                 --disable-shared \
54                 $(use_enable nls) \
55                 --docdir='$(datarootdir)/doc/'${PF}
56 }
57
58 multilib_src_compile() {
59         if multilib_is_native_abi; then
60                 default
61         else
62                 cd src || die
63                 emake -f Makefile -f - lib <<< 'lib: $(lib_LTLIBRARIES)'
64         fi
65 }
66
67 multilib_src_test() {
68         multilib_is_native_abi && emake check
69 }
70
71 multilib_src_install() {
72         if multilib_is_native_abi; then
73                 default
74         else
75                 cd src || die
76                 emake DESTDIR="${D}" install-libLTLIBRARIES install-includeHEADERS
77         fi
78 }
79
80 multilib_src_install_all() {
81         einstalldocs
82         dodoc ONEWS
83         prune_libtool_files --all
84         rm "${ED}"/usr/share/doc/${PF}/COPYING || die
85         dosym flex /usr/bin/lex
86 }