4560e5806f3aa5a84d3a42bc824adfd9cab5b1c4
[gentoo.git] / app-misc / mc / mc-4.8.24.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit flag-o-matic
7
8 MY_P=${P/_/-}
9
10 DESCRIPTION="GNU Midnight Commander is a text based file manager"
11 HOMEPAGE="https://www.midnight-commander.org"
12 SRC_URI="http://ftp.midnight-commander.org/${MY_P}.tar.xz"
13
14 LICENSE="GPL-3"
15 SLOT="0"
16 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x86-solaris"
17 IUSE="+edit gpm nls samba sftp +slang spell test unicode X +xdg"
18
19 REQUIRED_USE="spell? ( edit )"
20
21 RDEPEND=">=dev-libs/glib-2.26.0:2
22         gpm? ( sys-libs/gpm )
23         kernel_linux? ( sys-fs/e2fsprogs )
24         samba? ( net-fs/samba )
25         sftp? ( net-libs/libssh2 )
26         slang? ( >=sys-libs/slang-2 )
27         !slang? ( sys-libs/ncurses:0=[unicode?] )
28         spell? ( app-text/aspell )
29         X? ( x11-libs/libX11
30                 x11-libs/libICE
31                 x11-libs/libXau
32                 x11-libs/libXdmcp
33                 x11-libs/libSM )"
34 DEPEND="${RDEPEND}
35         app-arch/xz-utils
36         virtual/pkgconfig
37         nls? ( sys-devel/gettext )
38         test? ( dev-libs/check )
39         "
40
41 RESTRICT="!test? ( test )"
42
43 S=${WORKDIR}/${MY_P}
44
45 PATCHES=("${FILESDIR}"/${P}-mc-lib-twice-4070.patch)
46
47 pkg_pretend() {
48         if use slang && use unicode ; then
49                 ewarn "\"unicode\" USE flag only takes effect when the \"slang\" USE flag is disabled."
50         fi
51 }
52
53 src_configure() {
54         [[ ${CHOST} == *-solaris* ]] && append-ldflags "-lnsl -lsocket"
55
56         local myeconfargs=(
57                 --enable-charset
58                 --enable-vfs
59                 --with-homedir=$(usex xdg 'XDG' '.mc')
60                 --with-screen=$(usex slang 'slang' "ncurses$(usex unicode 'w' '')")
61                 $(use_enable kernel_linux vfs-undelfs)
62                 # Today mclib does not expose any headers and is linked to
63                 # single 'mc' binary. Thus there is no advantage of having
64                 # a library. Let's avoid shared library altogether
65                 # as it also conflicts with sci-libs/mc: bug #685938
66                 --disable-mclib
67                 $(use_enable nls)
68                 $(use_enable samba vfs-smb)
69                 $(use_enable sftp vfs-sftp)
70                 $(use_enable spell aspell)
71                 $(use_enable test tests)
72                 $(use_with gpm gpm-mouse)
73                 $(use_with X x)
74                 $(use_with edit internal-edit)
75         )
76         econf "${myeconfargs[@]}"
77 }
78
79 src_test() {
80         # CK_FORK=no to avoid using fork() in check library
81         # as mc mocks fork() itself: bug #644462.
82         #
83         # VERBOSE=1 to make test failures contain detailed
84         # information.
85         CK_FORK=no emake check VERBOSE=1
86 }
87
88 src_install() {
89         emake DESTDIR="${D}" install
90         dodoc AUTHORS README NEWS
91
92         # fix bug #334383
93         if use kernel_linux && [[ ${EUID} == 0 ]] ; then
94                 fowners root:tty /usr/libexec/mc/cons.saver
95                 fperms g+s /usr/libexec/mc/cons.saver
96         fi
97
98         if ! use xdg ; then
99                 sed 's@MC_XDG_OPEN="xdg-open"@MC_XDG_OPEN="/bin/false"@' \
100                         -i "${ED}"/usr/libexec/mc/ext.d/*.sh || die
101         fi
102 }
103
104 pkg_postinst() {
105         elog "To enable exiting to latest working directory,"
106         elog "put this into your ~/.bashrc:"
107         elog ". ${EPREFIX}/usr/libexec/mc/mc.sh"
108 }