# Template file for 'rstudio'
pkgname=rstudio
version=1.2.5033
revision=1
build_style=cmake
configure_args="-DRSTUDIO_TARGET=Desktop
 -DRSTUDIO_BOOST_SIGNALS_VERSION=2
 -DQT_QMAKE_EXECUTABLE=/usr/lib/qt5/bin/qmake
 -DCMAKE_INSTALL_PREFIX=/usr/lib/rstudio"
hostmakedepends="unzip pandoc openjdk apache-ant qt5-qmake R mathjax which"
makedepends="zlib-devel libuuid-devel libressl-devel pam-devel
 boost-devel pango-devel hunspell-devel qt5-devel qt5-webkit-devel
 qt5-declarative-devel qt5-location-devel qt5-sensors-devel qt5-svg-devel
 qt5-xmlpatterns-devel qt5-webchannel-devel qt5-webengine-devel
 qt5-plugin-pgsql qt5-plugin-mysql qt5-plugin-sqlite qt5-plugin-tds qt5-plugin-odbc"
depends="R"
short_desc="Integrated development environment (IDE) for R"
maintainer="John <johnz@posteo.net>"
license="AGPL-3.0-only"
homepage="https://www.rstudio.com"
_aws="https://s3.amazonaws.com"
_gin_version=2.1.2
_gwt_version=2.8.1
distfiles="https://github.com/rstudio/rstudio/archive/v${version}.tar.gz
 ${_aws}/rstudio-dictionaries/core-dictionaries.zip
 ${_aws}/rstudio-buildtools/gin-${_gin_version}.zip
 ${_aws}/rstudio-buildtools/gwt-${_gwt_version}.zip"
checksum="ff5115bda56ee0fdee0ae2eb014ce5379774aeb3714a257a52da5b91a95e4408
 4341a9630efb9dcf7f215c324136407f3b3d6003e1c96f2e5e1f9f14d5787494
 b98e704164f54be596779696a3fcd11be5785c9907a99ec535ff6e9525ad5f9a
 0b7af89fdadb4ec51cdb400ace94637d6fe9ffa401b168e2c3d372392a00a0a7"
skip_extraction="core-dictionaries.zip
 gin-${_gin_version}.zip
 gwt-${_gwt_version}.zip"

LDFLAGS="-Wl,-z,stack-size=2097152"

post_extract() {
	_srcdir="${XBPS_SRCDISTDIR}/${pkgname}-${version}"
	mkdir -p src/gwt/lib/{gin/${_gin_version},gwt}

	unzip -qd src/gwt/lib/gin/${_gin_version} ${_srcdir}/gin-${_gin_version}.zip
	unzip -qd src/gwt/lib ${_srcdir}/gwt-${_gwt_version}.zip
	mv src/gwt/lib/gwt-${_gwt_version} src/gwt/lib/gwt/${_gwt_version}

	unzip -qd ${wrksrc}/dependencies/common/dictionaries ${_srcdir}/core-dictionaries.zip
}

pre_configure() {
	ln -sfT /usr/share/mathjax dependencies/common/mathjax-26
	ln -sfT /usr/bin dependencies/common/pandoc
}

post_install() {
	mkdir -p ${DESTDIR}/usr/bin

	for f in {diagnostics,rpostback,rsession,rstudio}; do
		ln -sf /usr/lib/rstudio/bin/${f} ${DESTDIR}/usr/bin/
	done
	vlicense COPYING
}
