summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3bb9cd7ee279135d74f422e8585c0ebd74ce07b4 (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
120
121
122
123
124
125
126
127
128
129
130
131
# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Contributor: Damir Perisa <damir.perisa@bluewin.ch>
# Contributor: K. Piche <kpiche@rogers.com>

pkgname=r
pkgver=3.5.2
pkgrel=1
pkgdesc='Language and environment for statistical computing and graphics'
arch=('x86_64')
license=('GPL')
url='https://www.r-project.org/'
depends=(
    'blas' 'lapack' 'bzip2'  'libpng' 'libjpeg' 'libtiff' 'ncurses' 'pcre'
    'readline' 'zlib' 'perl' 'gcc-libs' 'libxt' 'libxmu' 'pango' 'xz' 'zip'
    'unzip' 'curl' 'icu'
)
makedepends=('jdk-openjdk' 'gcc-fortran' 'tk')
optdepends=(
    'tk: tcl/tk interface'
    'texlive-bin: latex sty files'
    'gcc-fortran: needed to compile some CRAN packages'
    'openblas: faster linear algebra'
)
backup=(
    'etc/R/Makeconf'
    'etc/R/Renviron'
    'etc/R/ldpaths'
    'etc/R/repositories'
    'etc/R/javaconf'
)
options=('!makeflags' '!emptydirs')
source=(
    "https://cran.r-project.org/src/base/R-${pkgver%%.*}/R-${pkgver}.tar.gz"
    'r.desktop'
    'r.png'
    'R.conf'
)
sha512sums=(
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
)

# Avoid the following linking issue:
# src.: https://bbs.archlinux.org/viewtopic.php?pid=1953816#p1953816
# src.: https://github.com/radfordneal/pqR/issues/41#issuecomment-649139014
# ---
# /usr/bin/ld: ../unix/sys-unix.o:(.bss+0x0): multiple definition of `ptr_R_ProcessEvents'; ../unix/system.o:(.bss+0x20): first defined here
export CFLAGS+=' -fcommon'
# Disable a check in the Fortran compiler as a call to a R function has
# inverted arguments
# src.: https://github.com/radfordneal/pqR/issues/41#issuecomment-649139014
# ---
#
#    91 |         call dqrsl(x, ldx, n, k, qraux, sigma, sigma, dummy,
#       |                                               2
# ......
#   111 |                call dqrsl(x, ldx, n, k, qraux, sigma, dummy, sigma,
#       |                                                      1
# Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
# make[5]: *** [../../../../etc/Makeconf:185: lminfl.o] Error 1
export FFLAGS+=' -fallow-argument-mismatch'

# Testing the package:
# mkdir ./chroot
# CHROOT=./chroot
# mkarchroot $CHROOT/root base-devel
# makechrootpkg -c -r $CHROOT
# src.: https://wiki.archlinux.org/title/DeveloperWiki:Building_in_a_clean_chroot

prepare() {
    cd R-${pkgver}
    # set texmf dir correctly in makefile
    sed -i 's|$(rsharedir)/texmf|${datarootdir}/texmf|' share/Makefile.in
}

build() {
    cd R-${pkgver}
    ./configure \
        --prefix=/usr \
        --libdir=/usr/lib \
        --sysconfdir=/etc/R \
        --datarootdir=/usr/share \
          rsharedir=/usr/share/R/ \
          rincludedir=/usr/include/R/ \
          rdocdir=/usr/share/doc/R/ \
        --with-x \
        --enable-R-shlib \
        --with-lapack \
        --with-blas \
        F77=gfortran \
        LIBnn=lib
    make

    # make libRmath.so
    cd src/nmath/standalone
    make shared
}

package() {
    cd R-${pkgver}
    make DESTDIR="${pkgdir}" install

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

    #  Fixup R wrapper scripts.
    sed -i "s|${pkgdir} ||" "${pkgdir}/usr/bin/R"
    rm "${pkgdir}/usr/lib/R/bin/R"
    cd "${pkgdir}/usr/lib/R/bin"
    ln -s ../../../bin/R

    # install some freedesktop.org compatibility
    install -Dm644 "${srcdir}/r.desktop" \
    "${pkgdir}/usr/share/applications/r.desktop"
    install -Dm644 "${srcdir}/r.png" \
    "${pkgdir}/usr/share/pixmaps/r.png"

    # move the config directory to /etc and create symlinks
    install -d "${pkgdir}/etc/R"
    cd "${pkgdir}/usr/lib/R/etc"
    for i in *; do
        mv -f ${i} "${pkgdir}/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 "${srcdir}/R.conf" "${pkgdir}/etc/ld.so.conf.d/R.conf"
}