SUMMARY="An open source application that offers secure chat and file sharing"
DESCRIPTION="RetroShare creates encrypted connections to your friends. Nobody \
can spy on you. RetroShare is completely decentralized. This means there are \
no central servers. It is entirely Open-Source and free. There are no costs, \
no ads and no Terms of Service."
HOMEPAGE="http://retroshare.sourceforge.net/"
COPYRIGHT="2006-2021 RetroShare Team
	1989-1991 Free Software Foundation Inc.
	1995-1998 Eric Young
	1996-2001 Takuya OOURA
	1997, 2000, 2001, 2002, 2006 Benjamin Sittler
	2001-2004 Roger Dingledine
	2003 Justin Karneges
	2003 Kristen Wegner
	2004 Xavier Decoret
	2004-2005 John Gruber
	2004-2006 Robert Fernie.
	2004-2006 Roger Dingledine Nick Mathewson
	2004-2007 Kefei Zhou.
	2004-2007 Trolltech ASA.
	2004-2008 Cyril Soler
	2004-2009 Marcelo Roberto Jimenez
	2005 Thomas Bernard
	2005-2009 Nominet UK
	2005-2010 Thorvald Natvig
	2006 Christophe Dumez
	2006 Matt Edman Justin Hipple
	2006 Raul E.
	2006-2009 aMule Team
	2006-2010 Arseny Kapoulkine
	2006, 2007, 2008 crypton
	2007 2012 Ian Piumarta
	2007 Ariya Hidayat
	2007 Ian Piumarta
	2007 Ramiro Polla
	2007 Stefan Goessner
	2007-2011 drbob
	2007-2008 Christopher Evi-Parker Cyril Soler
	2007-2008 Cyril Soler
	2007-2008 Horatio
	2007-2008 Kashif Kaleem
	2007-2008 Robert Fernie Horatio Chris Parker
	2007-2014 Thunder
	2007-2008 Vinny Do Chris Evi-Parker
	2007-2008 Xesc & Technology
	2007-2010 Robert Fernie
	2007-2010 The Tor Project Inc.
	2007-2010 Xesc & Technology
	2007-2011 Robert Fernie
	2008 Ariya Hidayat
	2008 Cyril Soler
	2008 defnax
	2008 djhasis
	2008 edmanm
	2008 Matt Edman Justin Hipple
	2008 Timo Bingmann
	2008 Unipro Russia
	2008-2008 Robert Fernie.
	2008-2009 Golnaz Nilieh
	2008-2009 John MacFarlane
	2008-2009 Mehrdad Momeny
	2008-2009 Raghu Dev R.
	2009 defnax
	2009 lsn752
	2009 Nokia Corporation andor its subsidiary(-ies).
	2010 csoler
	2010 Peter Zotov
	2010 Thomas Kister
	2011 csoler
	2012 Romain Pokrzywka (KDAB)
	2013 Digia Plc andor its subsidiary(-ies).
	2013 Jeff Weinstein
	2013-2014 Colin Duquesnoy
	2014 John Brooks
	2015 electron128
	2016 defnax
	2016 John Brooks
	2016 Manu Pineda
	2016 Mr.Alice
	2016-2018 Gioacchino Mazzurco
	2017 Konrad Dębiec"
LICENSE="GNU GPL v2
	GNU LGPL v2.1"
REVISION="3"
SOURCE_URI="https://github.com/RetroShare/RetroShare/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="c545b9249ac7dbfef72a2d636bc0f8b729c7ce05f21a54dd9284b2a387592d4a"
SOURCE_DIR="RetroShare-$portVersion"
srcGitRev_2="f3a3103a6c52e5707629e8d0a7e279a7758fe845"
SOURCE_URI_2="https://github.com/truvorskameikin/udp-discovery-cpp/archive/$srcGitRev_2.tar.gz"
SOURCE_FILENAME_2="udp-discovery-cpp-$srcGitRev_2.tar.gz"
SOURCE_DIR_2="udp-discovery-cpp-$srcGitRev_2"
CHECKSUM_SHA256_2="ec00c4da0d43769351ff94cef81b30afe0dd1932a80ded497a338b2f2364d232"
srcGitRev_3="c27c6726d28c42e2e1b7537ba63eeb23e944789d"
SOURCE_URI_3="https://github.com/Corvusoft/restbed/archive/$srcGitRev_3.tar.gz"
SOURCE_FILENAME_3="restbed-$srcGitRev_3.tar.gz"
SOURCE_DIR_3="restbed-$srcGitRev_3"
CHECKSUM_SHA256_3="e01389d3f0481458e14861ee33abc2f7aec3a382bd70e91dee495ac6e943d403"
srcGitRev_4="b9c7a496ba7dd9c3495bae2ff2855899e47b245d"
SOURCE_URI_4="https://github.com/commonmark/cmark/archive/$srcGitRev_4.tar.gz"
SOURCE_FILENAME_4="cmark-$srcGitRev_4.tar.gz"
SOURCE_DIR_4="cmark-$srcGitRev_4"
CHECKSUM_SHA256_4="1327a76d0d24a9160b34c722d31bf3c6e65d646ed51ad212b4803160fe27da35"

PATCHES="retroshare-$portVersion.patchset"
ADDITIONAL_FILES="
	retroshare.rdef.in
	icons.zip
	"

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

PROVIDES="
	retroshare$secondaryArchSuffix = $portVersion
	app:RetroShare = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libgpgme$secondaryArchSuffix
	lib:libixml$secondaryArchSuffix
	lib:libmicrohttpd$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libsqlcipher$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libupnp$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libxslt$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libavcodec$secondaryArchSuffix
	devel:libavformat$secondaryArchSuffix
	devel:libavutil$secondaryArchSuffix
	devel:libbz2$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	devel:libgl$secondaryArchSuffix
	devel:libgpgme$secondaryArchSuffix
	devel:libixml$secondaryArchSuffix
	devel:libmicrohttpd$secondaryArchSuffix
	devel:libopencv_core$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Multimedia$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:librapidjson$secondaryArchSuffix
	devel:libspeex$secondaryArchSuffix
	devel:libspeexdsp$secondaryArchSuffix
	devel:libsqlcipher$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libupnp$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libxslt$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make	
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix
	cmd:unzip
	"

PATCH()
{
	unzip -o $sourceDir/../../additional-files/icons.zip -d $sourceDir
}

BUILD()
{
	echo "Link submodules..."
	rm -rf $sourceDir/supportlibs/{cmark,restbed,udp-discovery-cpp}
	ln -s $sourceDir2 $sourceDir/supportlibs/udp-discovery-cpp
	ln -s $sourceDir3 $sourceDir/supportlibs/restbed
	ln -s $sourceDir4 $sourceDir/supportlibs/cmark
	echo "Building pegmarkdown..."
	cd supportlibs/pegmarkdown && qmake && make clean && make $jobArgs && cd ../..

	echo "Building RetroShare..."	
	qmake -r \
		PREFIX=$appsDir/RetroShare \
		RS_BIN_DIR=$appsDir/RetroShare \
		RS_DATA_DIR=$appsDir/RetroShare \
		RS_LIB_DIR=$appsDir/RetroShare/lib \
		RS_PLUGIN_DIR=$appsDir/RetroShare/plugins \
		CONFIG+=release \
		CONFIG+=rs_gui_cmark \
		CONFIG+=retroshare_plugins \
		CONFIG+=no_rs_broadcast_discovery

	make $jobArgs
}

INSTALL()
{
	make install
	
	rm -rf $appsDir/RetroShare/share
	strip $appsDir/RetroShare/{retroshare,retroshare-service}
	mv $appsDir/RetroShare/retroshare $appsDir/RetroShare/RetroShare

	mkdir -p $appsDir/RetroShare/{plugins,lib}
	cp -r $sourceDir4/build/src/*.so* $appsDir/RetroShare/lib
	cp -r plugins/FeedReader/lib/*.so* $appsDir/RetroShare/plugins
#	cp -r plugins/VOIP/lib/*.so* $appsDir/RetroShare/plugins
	strip $appsDir/RetroShare/plugins/*.so

	APP_SIGNATURE="application/x-vnd.RetroShare"
	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/retroshare.rdef.in > retroshare.rdef

	addResourcesToBinaries retroshare.rdef $appsDir/RetroShare/RetroShare
	addAppDeskbarSymlink $appsDir/RetroShare/RetroShare
}
