SUMMARY="File manager and desktop icon manager (Qt port of PCManFM and libfm)"
DESCRIPTION="PCMan File Manager (PCManFM) is a file manager application \
developed by Hong Jen Yee from Taiwan which is meant to be a replacement \
for Nautilus, Konqueror and Thunar. Released under the GNU General Public \
License, PCManFM is free software. PCManFM is the standard file manager in \
LXDE, which is also developed by the same author in conjunction with other \
developers. Since 2010, PCManFM has undergone a complete rewrite from \
scratch. So the new PCManFM is totally different from the old 0.5.x series."
HOMEPAGE="https://wiki.lxde.org/en/PCManFM"
COPYRIGHT="2013-2019 LXQt team"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="https://github.com/lxqt/pcmanfm-qt/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="54b325919c0e767a0109119e7d63898d5292d9b25959b4e7a2b1ff1eac942747"
SOURCE_DIR="pcmanfm-qt-$portVersion"
PATCHES="pcmanfm_qt-$portVersion.patchset"
ADDITIONAL_FILES="pcmanfm-qt.rdef.in"

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

PROVIDES="
	pcmanfm_qt$secondaryArchSuffix = $portVersion
	app:PCManFM$secondaryArchSuffix = $portVersion
	cmd:pcmanfm_qt$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libexif$secondaryArchSuffix
	lib:libfm$secondaryArchSuffix
	lib:libfm_qt$secondaryArchSuffix
	lib:libgio_2.0$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgobject_2.0$secondaryArchSuffix
	lib:libgthread_2.0$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libmenu_cache$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libxcb$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	lxqt_build_tools$secondaryArchSuffix
	devel:libexif$secondaryArchSuffix
	devel:libfm$secondaryArchSuffix
	devel:libfm_extra$secondaryArchSuffix
	devel:libfm_qt$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libmenu_cache$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libxcb$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. $cmakeDirArgs \
		-Dfm-qt_DIR=/system/data/cmake/fm-qt \
		-DCMAKE_BUILD_TYPE=Release \
		-DPULL_TRANSLATIONS=no
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir $appsDir
	mv $binDir/pcmanfm-qt $appsDir/PCManFM
	rm -rf $binDir $dataDir/applications

	local APP_SIGNATURE="application/x-vnd.qt5-pcmanfm-qt"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/pcmanfm-qt.rdef.in > pcmanfm-qt.rdef

	addResourcesToBinaries pcmanfm-qt.rdef $appsDir/PCManFM
	addAppDeskbarSymlink $appsDir/PCManFM
}

TEST()
{
	make check
}
