SUMMARY="A powerful file manager"
DESCRIPTION="GNU Midnight Commander is a text-mode full-screen file manager. \
It uses a two panel interface and a subshell for command execution. It \
includes an internal editor with syntax highlighting and an internal viewer \
with support for binary files. Also included is Virtual Filesystem (VFS), \
that allows files on remote systems (e.g. FTP, SSH servers) and files inside \
archives to be manipulated like real files."
HOMEPAGE="https://www.midnight-commander.org/"
COPYRIGHT="1994-2019, Free Software Foundation"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="http://ftp.midnight-commander.org/mc-$portVersion.tar.xz"
CHECKSUM_SHA256="31be59225ffa9920816e9a8b3be0ab225a16d19e4faf46890f25bdffa02a4ff4"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]
then
	commandBinDir=$prefix/bin
	commandSuffix=
fi

GLOBAL_WRITABLE_FILES="settings/mc directory keep-old"

PROVIDES="
	mc$secondaryArchSuffix = $portVersion
	cmd:mc$commandSuffix = $portVersion
	cmd:mcdiff$commandSuffix = $portVersion
	cmd:mcedit$commandSuffix = $portVersion
	cmd:mcview$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncursesw$secondaryArchSuffix
	lib:libssh2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libglib_2.0$secondaryArchSuffix >= 0.38
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libncursesw$secondaryArchSuffix
	devel:libssh2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	cmd:tar
	"

PATCH()
{
	sed -i '1i #define REAL_UNIX_SYSTEM' lib/tty/tty-slang.h
}

BUILD()
{
	CFLAGS="-D_BSD_SOURCE -D_XOPEN_SOURCE_EXTENDED" \
		LIBS="-lnetwork -lbsd" runConfigure --omit-dirs binDir configure \
		--bindir=$commandBinDir \
		--datarootdir="$dataRootDir" \
		--enable-vfs-smb \
		--with-smb-configdir="$settingsDir/samba" \
		--with-smb-codepagedir="$settingsDir/samba" \
		--with-homedir="$settingsDir/mc" \
		--with-screen=ncurses
	make $jobArgs
}

INSTALL()
{
	make $jobArgs install-strip
}

TEST()
{
	make check
}
