# Template file for 'rstudio'
pkgname=rstudio
version=1.3.1093
revision=1
build_style=cmake
configure_args="-DRSTUDIO_TARGET=Desktop
 -DRSTUDIO_USE_SYSTEM_BOOST=ON
 -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 <me@johnnynator.dev>"
license="AGPL-3.0-only"
homepage="https://www.rstudio.com"
_aws="https://s3.amazonaws.com"
_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/gwt-${_gwt_version}.zip"
checksum="af8dc5e71ee934043856938af2e2065d1f1efef08aba37962ed03f6ccb8201bb
 4341a9630efb9dcf7f215c324136407f3b3d6003e1c96f2e5e1f9f14d5787494
 0b7af89fdadb4ec51cdb400ace94637d6fe9ffa401b168e2c3d372392a00a0a7"
skip_extraction="core-dictionaries.zip
 gwt-${_gwt_version}.zip"

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

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

	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-27
	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
}
