summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 19fda5d1aa54066fb2c0f1deea47edcef93e7d31 (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
# Maintainer: Jiuyang Liu <liujiuyang1994@gmail.com>

# Follow the upstream of https://github.com/sifive/freedom-tools/blob/master/Makefile

_target=riscv-sifive-elf
pkgname=$_target-binutils
pkgver=2.32
pkgrel=1
pkgdesc='A set of programs to assemble and manipulate binary and object files for the RISC-V (bare-metal) target'
arch=(x86_64)
url='http://www.gnu.org/software/binutils/'
license=(GPL)
depends=(zlib)
source=("https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz"
        "0001-Add-support-for-SiFive-CLIC-CSRs.patch"
        "0002-RISC-V-Compress-3-operand-beq-bne-against-x0.patch")
md5sums=('0d174cdaf85721c5723bf52355be41e6'
         'SKIP'
         'SKIP')

prepare() {
  # hack! - some configure tests for header files using "$CPP $CPPFLAGS"
  sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" \
    "$srcdir/binutils-$pkgver/libiberty/configure"
  cd $srcdir/binutils-$pkgver
  echo "patch unmerged work from SiFive."
  patch --forward --strip=1 --input="${srcdir}/0001-Add-support-for-SiFive-CLIC-CSRs.patch"
  patch --forward --strip=1 --input="${srcdir}/0002-RISC-V-Compress-3-operand-beq-bne-against-x0.patch"
}

build() {
  cd binutils-$pkgver

  unset CPPFLAGS

  ./configure \
    --disable-gdb \
    --disable-libdecnumber \
    --disable-libreadline \
    --disable-sim \
    --disable-werror \
    --prefix=/usr \
    --target=$_target \
    --with-expat=yes \
    --with-gmp=no \
    --with-mpc=no \
    --with-mpfr=no \
    --with-python=no \
    --with-sysroot=/usr/$_target \
    CFLAGS="-O2" \
    CXXFLAGS="-O2"

  make
}

check() {
  # unset LDFLAGS as testsuite makes assumptions about which ones are active
  # do not abort on errors - manually check log files
  make -C "binutils-$pkgver" LDFLAGS="" -k check
}

package() {
  make -C "binutils-$pkgver" DESTDIR="$pkgdir" install

  # Remove file conflicting with host binutils and manpages for MS Windows tools
  #rm "$pkgdir"/usr/share/man/man1/arm-none-eabi-{dlltool,windres,windmc}*

  # Remove info documents that conflict with host version
  rm -r "$pkgdir/usr/share/"{info,locale}
}