sys-fs/xfsprogs: Use use_enable for static-libs
[gentoo.git] / sys-fs / xfsprogs / xfsprogs-4.14.0.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit toolchain-funcs multilib
7
8 DESCRIPTION="xfs filesystem utilities"
9 HOMEPAGE="https://xfs.wiki.kernel.org/"
10 SRC_URI="https://www.kernel.org/pub/linux/utils/fs/xfs/${PN}/${P}.tar.xz"
11
12 LICENSE="LGPL-2.1"
13 SLOT="0"
14 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86"
15 IUSE="libedit nls readline static static-libs"
16 REQUIRED_USE="static? ( static-libs )"
17
18 LIB_DEPEND=">=sys-apps/util-linux-2.17.2[static-libs(+)]
19         readline? ( sys-libs/readline:0=[static-libs(+)] )
20         !readline? ( libedit? ( dev-libs/libedit[static-libs(+)] ) )"
21 RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs(+)]} )
22         !<sys-fs/xfsdump-3"
23 DEPEND="${RDEPEND}
24         static? (
25                 ${LIB_DEPEND}
26                 readline? ( sys-libs/ncurses:0=[static-libs] )
27         )
28         nls? ( sys-devel/gettext )"
29
30 PATCHES=(
31         "${FILESDIR}"/${PN}-4.12.0-sharedlibs.patch
32         "${FILESDIR}"/${PN}-4.7.0-libxcmd-link.patch
33         "${FILESDIR}"/${PN}-4.9.0-underlinking.patch
34 )
35
36 pkg_setup() {
37         if use readline && use libedit ; then
38                 ewarn "You have USE='readline libedit' but these are exclusive."
39                 ewarn "Defaulting to readline; please disable this USE flag if you want libedit."
40         fi
41 }
42
43 src_prepare() {
44         default
45
46         # LLDFLAGS is used for programs, so apply -all-static when USE=static is enabled.
47         # Clear out -static from all flags since we want to link against dynamic xfs libs.
48         sed -i \
49                 -e "/^PKG_DOC_DIR/s:@pkg_name@:${PF}:" \
50                 -e "1iLLDFLAGS += $(usex static '-all-static' '')" \
51                 include/builddefs.in || die
52         find -name Makefile -exec \
53                 sed -i -r -e '/^LLDFLAGS [+]?= -static(-libtool-libs)?$/d' {} +
54
55         # TODO: Write a patch for configure.ac to use pkg-config for the uuid-part.
56         if use static && use readline ; then
57                 sed -i \
58                         -e 's|-lreadline|& -lncurses|' \
59                         -e 's|-lblkid|& -luuid|' \
60                         configure || die
61         fi
62 }
63
64 src_configure() {
65         export DEBUG=-DNDEBUG
66         export OPTIMIZER=${CFLAGS}
67         unset PLATFORM # if set in user env, this breaks configure
68
69         local myconf=(
70                 $(use_enable nls gettext)
71                 $(use_enable readline)
72                 $(usex readline --disable-editline $(use_enable libedit editline))
73         )
74         if use static || use static-libs ; then
75                 myconf+=( --enable-static )
76         else
77                 myconf+=( --disable-static )
78         fi
79
80         econf "${myconf[@]}"
81
82         MAKEOPTS+=" V=1"
83 }
84
85 src_install() {
86         emake DIST_ROOT="${ED}" install
87         # parallel install fails on this target for >=xfsprogs-3.2.0
88         emake -j1 DIST_ROOT="${ED}" install-dev
89
90         # handle is for xfsdump, the rest for xfsprogs
91         gen_usr_ldscript -a handle xcmd xfs xlog
92         # removing unnecessary .la files if not needed
93         use static-libs || find "${ED}" -name '*.la' -delete
94 }