SUMMARY="Crossplatform Jabber/XMPP client"
DESCRIPTION="Vacuum IM is a free/libre cross-platform Qt4-based Jabber client."
HOMEPAGE="http://www.vacuum-im.org"
SOURCE_URI="https://github.com/Vacuum-IM/vacuum-im/archive/$portVersion.tar.gz"
SOURCE_FILENAME="vacuum-im-$portVersion.tar.gz"
SOURCE_DIR="vacuum-im-$portVersion"
CHECKSUM_SHA256="3237933f68884fb5b3422ad0fc97083b40a7aae9d8c105a23720c09599ffe5da"
REVISION="1"
LICENSE="GNU GPL v3"
COPYRIGHT="2008-2015 Vacuum Team"

ARCHITECTURES="x86"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	# x86_gcc2 is fine as primary target architecture as long as we're building
	# for a different secondary architecture.
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi

SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	vacuum$secondaryArchSuffix = $portVersion
	app:Vacuum$secondaryArchSuffix
	"
REQUIRES="
	haiku${secondaryArchSuffix}
	libqt4${secondaryArchSuffix} >= 4.8
	lib:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++${secondaryArchSuffix}
	cmd:cmake
	cmd:make
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	libqt4${secondaryArchSuffix}_devel >= 4.8
	devel:libz${secondaryArchSuffix}
	"
PATCH()
{
	sed -i 's/#ifdef __FreeBSD__/#if defined(__FreeBSD__) || defined(__HAIKU__)/g' \
		src/thirdparty/minizip/ioapi.h
}	

BUILD()
{
	# TODO: Force usage of external libraries
	#rm -rf src/thirdparty/{idn,minizip,zlib}
	cmake -DINSTALL_APP_DIR=$appsDir/Vacuum-IM -DINSTALL_LIB_DIR=$appsDir/Vacuum-IM/lib \
		-DINSTALL_SDK=ON -DLANGS="de pl ru uk" \
		-DINSTALL_DOCS=OFF #-DFORCE_BUNDLED_MINIZIP=OFF
	make $jobArgs	
}

INSTALL()
{
	# TODO: fix make install
	mkdir -p $appsDir/Vacuum-IM/lib

	cp vacuum $appsDir/Vacuum-IM/Vacuum
	cp -r resources plugins $appsDir/Vacuum-IM
	cp -r src/libs/*.so* $appsDir/Vacuum-IM/lib
	cp -r src/translations $appsDir/Vacuum-IM
	rm -rf $appsDir/Vacuum-IM/translations/{ts*,.tx}

	addResourcesToBinaries $portDir/additional-files/vacuum.rdef $appsDir/Vacuum-IM/Vacuum
	# For some reason attributes are missing without mimeset
	mimeset -f $appsDir/Vacuum-IM/Vacuum
	addAppDeskbarSymlink $appsDir/Vacuum-IM/Vacuum

}
