summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9f9e1c815ed3cfa930123920bef56ccc57778eef (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
# Maintainer: taotieren <admin@taotieren.com>
# Maintainer: yjun <jerrysteve1101 at gmail dot com>

pkgbase=mounriver-studio-toolchain-bin
pkgname=($pkgbase mounriver-studio-toolchain-openocd-bin mounriver-studio-toolchain-riscv-gcc-bin mounriver-studio-toolchain-riscv-gcc12-bin)
pkgver=230
pkgrel=1
arch=('x86_64')
url='http://www.mounriver.com/'
license=('LicenseRef-custom')
provides=('MRS-Toolchain')
makedepends=('tar')
optdepends=('ch34x-dkms-git: CH341SER driver with fixed bug'
    'i2c-ch341-dkms: CH341 USB-I2C adapter driver'
    'spi-ch341-usb-dkms-git: 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'
    'ch343ser-dkms: USB serial driver for ch342/ch343/ch344/ch347/ch347f/ch9101/ch9102/ch9103/ch9104, etc (dkms).'
    'wchisp: WCH ISP Tool in Rust')

_pkg_file_name="MRS_Toolchain_Linux_x64_V${pkgver}.tar.xz"
source=("local://${_pkg_file_name}")
sha256sums=('6232a52866e9ed425ced6838f99b46126f821d9a896c766579b790d8e1eede54')
options=('!strip')
noextract=("${_pkg_file_name}")

_download_page=https://www.mounriver.com/download
if [ ! -f "${_pkg_file_name}" ]; then
	echo ""
	echo "Package not found!"
	echo "Download from: ${_download_page}"
	echo "Put a downloaded package ${_pkg_file_name} into the build directory (${PWD}) before build."
	echo ""
fi

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

prepare() {
    mkdir -pv ${srcdir}/${pkgbase}-${pkgver}
    tar -xf "${srcdir}/${_pkg_file_name}" -C "${srcdir}/${pkgbase}-${pkgver}"
    #     --strip-components=1
}

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-gcc-bin mounriver-studio-toolchain-riscv-gcc12-bin)
}

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

    pkgdesc="MRS Toolchain OpenOCD supports erasure, programming, verification and debugging of the chip."

    cd "${srcdir}"/${pkgbase}-${pkgver}/OpenOCD/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
exec /opt/wch/${pkgname%-bin}/bin/openocd -f /opt/wch/${pkgname%-bin}/bin/wch-arm.cfg "\$@"

EOF

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

EOF
}

package_mounriver-studio-toolchain-riscv-gcc-bin() {
    pkgdesc="MRS Toolchain Support for RISC-V assembly and GNU C compilation, link operation."
    depends=('bash'
        'glibc'
        'python')
    install -dm0755 "${pkgdir}/opt/wch/${pkgname%-bin}"
    cd "${srcdir}/${pkgbase}-${pkgver}/Toolchain/RISC-V Embedded GCC/"
    cp -a * "${pkgdir}/opt/wch/${pkgname%-bin}"

    install -Dm0644 /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
}

package_mounriver-studio-toolchain-riscv-gcc12-bin() {
    pkgdesc="MRS Toolchain Support for RISC-V assembly and GNU C compilation, link operation."
    depends=('bash'
        'glibc'
        'python')
    install -dm0755 "${pkgdir}/opt/wch/${pkgname%-bin}"
    cd "${srcdir}/${pkgbase}-${pkgver}/Toolchain/RISC-V Embedded GCC12/"
    cp -a * "${pkgdir}/opt/wch/${pkgname%-bin}"

    install -Dm0644 /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