# Tanım: İstatistiksel hesaplama ve grafik için programlama dili
# URL: https://www.r-project.org/
# Paketçi: milisarge
# Gerekler: tk lapack libpng libjpeg-turbo libtiff pcre xorg-libxt xorg-libxmu pango zip unzip icu 
# Grup: geliştirme

isim=r-lang
surum=3.5.1
devir=1
kaynak=(https://cran.r-project.org/src/base/R-${surum%%.*}/R-3.5.1.tar.gz
		r.desktop
		r.png
		R.conf)

derle() {
	cd R-${surum}
	# set texmf dir correctly in makefile
	sed -i 's|$(rsharedir)/texmf|${datarootdir}/texmf|' share/Makefile.in
	./configure  --prefix=/usr \
	--libdir=/usr/lib \
	--sysconfdir=/etc/R \
	--datarootdir=/usr/share \
	rsharedir=/usr/share/R/ \
	rincludedir=/usr/include/R/ \
	--with-x \
	--enable-R-shlib \
	--with-lapack \
	F77=gfortran \
	LIBnn=lib
	make
	# make libRmath.so
	cd src/nmath/standalone
	make shared
	cd $SRC/R-${surum}
	make DESTDIR="${PKG}" install
	# install libRmath.so
	make DESTDIR="${PKG}" install
	#  Fixup R wrapper scripts.
	sed -i "s|${PKG} ||" "${PKG}/usr/bin/R"
	rm "${PKG}/usr/lib/R/bin/R"
	cd "${PKG}/usr/lib/R/bin"
	ln -s ../../../bin/R
	# install some freedesktop.org compatibility
	install -Dm644 "${SRC}/r.desktop" "${PKG}/usr/share/applications/r.desktop"
	install -Dm644 "${SRC}/r.png" "${PKG}/usr/share/pixmaps/r.png"
	# move the config directory to /etc and create symlinks
	install -d "${PKG}/etc/R"
	cd "${PKG}/usr/lib/R/etc"
	for i in *; do
	mv -f ${i} "${PKG}/etc/R"
	ln -s /etc/R/${i} ${i}
	done
	# Install ld.so.conf.d file to ensure other applications access the shared lib
	install -Dm644 "${SRC}/R.conf" "${PKG}/etc/ld.so.conf.d/R.conf"
	rm -rf $PKG/usr/share/doc
}
