summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a6fae5fa474907c1e34525d008a1a700b4cfdbd7 (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
# Maintainer: taotieren <admin@taotieren.com>

pkgbase=mounriver-studio-toolchain-bin
pkgname=($pkgbase mounriver-studio-toolchain-openocd-bin mounriver-studio-toolchain-riscv-bin)
pkgver=1.10
pkgrel=2
arch=('x86_64')
url='http://www.mounriver.com/'
license=('GPL2' 'GPL3' 'custom')
provides=('MRS-Toolchain')
conflicts=()
depends=('bash')
makedepends=('tar')
optdepends=('ch34x-dkms-git: CH341SER driver with fixed bug'
            'i2c-ch341-dkms: CH341 USB-I2C adapter driver'
            'spi-ch341-usb-dkms: SPI/GPIO driver for CH341'
            'ch341eepromtool: An i2c serial EEPROM programming tool for the WCH CH341A'
            'ch341prog-git: A simple command line tool (programmer) interfacing with ch341a'
            'ch341eeprom-git: A libusb based programming tool for 24xx I²C EEPROMs using the WCH CH341A')
source=("${pkgbase}-${pkgver}.tar.gz::http://file.mounriver.com/tools/MRS_Toolchain_Linux_x64_V${pkgver}.tar.gz"
        )

sha256sums=('443a7392c42cd387a2b0445f265e9e98b020b7779d346f360a786f1c0c1a7b9b')

options=('!strip')

noextract=(${pkgbase}-${pkgver}.tar.gz)

_install(){
     find ${@: 2} -type f -exec install -Dm$1 {}  ${pkgdir}/opt/wch/${pkgname%-bin}/{} \;
} 

package_mounriver-studio-toolchain-bin() {
    pkgdesc="This MRS Toolchain includes the tool chain for RISC-V kernel chip under Linux x64 and the debug download tool OpenOCD."
    depends=(mounriver-studio-toolchain-openocd-bin mounriver-studio-toolchain-riscv-bin)
}

package_mounriver-studio-toolchain-openocd-bin() {
    depends=('bash'
             'libftdi-compat'
             'libusb'
             'hidapi'
             'libusb-compat'
             'libudev.so')

    pkgdesc="MRS Toolchain OpenOCD supports erasure, programming, verification and debugging of the chip."
    install -dm0755 "${pkgdir}/opt/wch/${pkgname%-bin}"

    tar -xf "${srcdir}/${pkgbase}-${pkgver}.tar.gz" --strip-components=2 -C "${srcdir}"
# cp -r "${srcdir}"/OPENOCD/* "${pkgdir}/opt/wch/${pkgname%-bin}"
    cd "${srcdir}"/OPENOCD/
    _install 644 bin -name "*.cfg"
    _install 755 bin -name "openocd"
    _install 644 share

    install -Dm0755 /dev/stdin "${pkgdir}/usr/bin/openocd-wch-arm" << EOF
#!/bin/env bash
cd /opt/wch/${pkgname%-bin}/bin
exec ./openocd -f wch-arm.cfg "\$@"

EOF
    install -Dm0755 /dev/stdin "${pkgdir}/usr/bin/openocd-wch-riscv" << EOF
#!/bin/env bash
cd /opt/wch/${pkgname%-bin}/bin
exec ./openocd -f wch-riscv.cfg "\$@"

EOF
}

package_mounriver-studio-toolchain-riscv-bin() {
    pkgdesc="MRS Toolchain Support for RISC-V assembly and GNU C compilation, link operation."
    install -dm0755 "${pkgdir}/opt/wch/${pkgname%-bin}"

    tar -xf "${srcdir}/${pkgbase}-${pkgver}.tar.gz" --strip-components=2 -C "${srcdir}"
    cp -r "${srcdir}"/RISC-V\ Embedded\ GCC/* "${pkgdir}/opt/wch/${pkgname%-bin}"

    install -Dm0755 /dev/stdin "${pkgdir}/etc/profile.d/${pkgname%-bin}.sh" << EOF
#!/bin/sh
[ -d /opt/wch/${pkgname%-bin}/bin ] && append_path '/opt/wch/${pkgname%-bin}/bin'

export PATH
EOF
}
# vim: ts=4 sw=4 et