summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5dcaf0ee8edcf867387bfef3f981f3f96c25184e (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
#
# Maintainer: Mark Barbone <mark.l.barbone at gmail>
# Co-maintainer: Thomas Hansen <thomas-e-hansen at teh6 dot eu>
# 

pkgname=idris2
pkgver=0.7.0
pkgrel=1
pkgdesc="Functional Programming Language with Dependent Types"
url="https://idris-lang.github.io/"
license=('BSD-3-Clause')
arch=('x86_64')
depends=('chez-scheme')
optdepends=('nodejs: for the node backend'
            'racket: for the racket backend')
# TODO: Revert to this? Depends on https://github.com/idris-lang/Idris2/issues/3173
#       which is likely to be open for a while (again, no full-time devs).
# source=("https://www.idris-lang.org/idris2-src/idris2-${pkgver}.tgz")
source=("https://github.com/idris-lang/Idris2/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('7a8612a1cd9f1f737893247260c6942bf93f193375d4b3df0148f7abf74d6e14')

_srcname="Idris2-$pkgver"

build() {
    cd "$srcdir/$_srcname"

    unset MAKEFLAGS # Parallel builds cause problems
    export SCHEME=chez

    mkdir -p "$srcdir/bootstrap"
    PREFIX="$srcdir/bootstrap" make bootstrap
    PREFIX="$srcdir/bootstrap" make install
    make distclean

    PATH="$srcdir/bootstrap/bin:$PATH" \
        PREFIX=/usr/lib \
        make all
}

check() {
    cd "$srcdir/$_srcname"

    unset MAKEFLAGS
    export SCHEME=chez

    # The refc backend tests contains a bunch of unused variables, presumably
    # they're actually used for FFI things and this is just impossible to
    # statically spot.
    export CFLAGS="-Wno-error=unused-variable ${CFLAGS}"

    PATH="$srcdir/$_srcname/build/exec:$PATH" \
        make test INTERACTIVE=""
}

package() {
    cd "$srcdir/$_srcname"

    unset MAKEFLAGS
    export SCHEME=chez

    # Install compiler and runtime
    PREFIX="$pkgdir/usr/lib" make install-idris2
    PREFIX="$pkgdir/usr/lib" make install-support

    IDRIS2_BINARY="$srcdir/$_srcname/build/exec/idris2"

    # Install libraries
    install_lib() {
        IDRIS2_PREFIX="$pkgdir/usr/lib" \
            "$IDRIS2_BINARY" --install-with-src $1.ipkg
    }
    for lib in prelude base contrib linear network test ; do
        ( cd libs/$lib ; install_lib $lib )
    done
    install_lib idris2api

    # Fix permissions
    find "$pkgdir" -type d -exec chmod 755 {} \;

    install -Dm644 <("$IDRIS2_BINARY" --bash-completion-script idris2) \
        "$pkgdir/usr/share/bash-completion/completions/idris2"
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

    # Put a symlink to executable in the expected place
    # (see: man 7 file-hierarchy)
    mkdir "$pkgdir/usr/bin"
    ln -s "$pkgdir/usr/lib/bin/idris2" "$pkgdir/usr/bin/idris2"
}