aboutsummaryrefslogtreecommitdiffstats
path: root/community/R/APKBUILD
blob: 5b192f2e787414660d73b42154f0038be9f0a6fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Contributor: Nirosan <pnirosan@gmail.com>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=R
pkgver=4.1.0
pkgrel=1
pkgdesc="Language and environment for statistical computing"
url="https://www.r-project.org/"
# mips64 and riscv64 blocked by java-jre-headless
arch="all !mips64 !riscv64"
license="(GPL-2.0-only OR GPL-3.0-only) AND LGPL-2.1-or-later"
depends="$pkgname-mathlib"
depends_dev="gcc gfortran icu-dev libjpeg-turbo libpng-dev make openblas-dev>=0.3.0
	pcre2-dev readline-dev xz-dev zlib-dev bzip2-dev curl-dev>=7.28
	"
makedepends="$depends_dev cairo-dev libxmu-dev java-jre-headless pango-dev
	perl tiff-dev tk-dev
	"
install="$pkgname.post-install"
subpackages="$pkgname-mathlib $pkgname-dev:_dev $pkgname-doc"
source="https://cran.r-project.org/src/base/R-${pkgver%%.*}/R-$pkgver.tar.gz"

_rhome="usr/lib/R"
ldpath="/$_rhome/lib"

build() {
	# Performance is more important than size for R. Moreover, -O2 has
	# only minimal impact on the R package size (less than 1 %).
	export CFLAGS="${CFLAGS/-Os/-O2}"
	export CXXFLAGS="${CXXFLAGS/-Os/-O2}"

	# CXXFLAGS is propagated to /etc/R/Makeconf that is read when building
	# additional R modules. -D__MUSL__ is needed for some modules like Rcpp.
	# htps://github.com/RcppCore/Rcpp/issues/448
	export CXXFLAGS="$CXXFLAGS -D__MUSL__"

	./configure \
		--prefix=/usr \
		--sysconfdir=/etc/R \
		--localstatedir=/var \
		--mandir=/usr/share/man \
		--libdir=/usr/lib \
		rdocdir=/usr/share/doc/R \
		rincludedir=/usr/include/R \
		rsharedir=/usr/share/R \
		--disable-nls \
		--enable-R-shlib \
		--enable-java \
		--without-recommended-packages \
		--with-blas=openblas \
		--with-cairo \
		--with-ICU \
		--with-jpeglib \
		--with-lapack \
		--with-libpng \
		--with-libtiff \
		--with-tcltk \
		--with-x

	make -j1
	make -j1 -C src/nmath/standalone
}

# TODO: Run provided test suite.
check() {
	./bin/R --version
	./bin/R --slave --vanilla -e 'print("Hello, world!")'
}

package() {
	local destdir="$pkgdir/$_rhome"

	make DESTDIR="$pkgdir" install

	# Install libRmath.so.
	cd src/nmath/standalone
	make DESTDIR="$pkgdir" install
	cd -

	# Fixup R wrapper script (taken from Arch).
	rm "$destdir"/bin/R
	ln -sf /usr/bin/R "$destdir"/bin/R

	# Remove some useless files (COPYING is duplicated, it will be
	# in -doc, don't worry).
	rm "$destdir"/COPYING "$destdir"/SVN-REVISION

	mkdir -p "$pkgdir"/etc/R

	# R apparently ignores --sysconfdir, so we must manually move configs
	# to /etc/R and make symlinks.
	cd "$destdir"/etc
	local f; for f in *; do
		mv "$f" "$pkgdir"/etc/R/ && ln -sf /etc/R/$f $f
	done
	cd -

	# Fix #8918
	# R expects iconv -l to return whitespace-separated list of
	# locales, our returns ', ' separated so it adds a , for every
	# locale
	sed -i 's/,//g' "$pkgdir"/usr/lib/R/library/utils/iconvlist
}

mathlib() {
	pkgdesc="Standalone math library from the R project"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libRmath.so* "$subpkgdir"/usr/lib
}

_dev() {
	depends="R=$pkgver-r$pkgrel"
	default_dev
}

sha512sums="
41519bf06a1ebc2bb582e9a7c35d0e82e213312dec8147861a7f9b28ee750cd40dfbf02737602d05698641fcea6182b0da8131e83edacc358e98eca0a393b729  R-4.1.0.tar.gz
"