# U-Boot: Beaglebone and Beaglebone Black
# Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>

buildarch=4

pkgname=uboot-beaglebone
pkgver=2017.07
pkgrel=1
pkgdesc="U-Boot for Beaglebone and Beaglebone Black"
arch=('armv7h')
url="http://git.denx.de/u-boot.git/"
makedepends=('bc' 'dtc' 'git')
license=('GPL')
install=${pkgname}.install
backup=('boot/boot.txt' 'boot/boot.scr')
source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver/rc/-rc}.tar.bz2"
        '0001-arch-linux-arm-modifications.patch'
        'boot.txt'
        'mkscr')
md5sums=('b74741e7a9ad1cf9a5bfa87302b80f2b'
         'a0bc17acb85fc3f04f74f6a87453ac97'
         'd9fd8313c6e8b6d217676a69c3813a95'
         '021623a04afd29ac3f368977140cfbfd')

prepare() {
  cd u-boot-${pkgver/rc/-rc}
  git apply ../0001-arch-linux-arm-modifications.patch
}

build() {
  cd u-boot-${pkgver/rc/-rc}

  unset CFLAGS CXXFLAGS LDFLAGS

  make distclean 
  make am335x_boneblack_defconfig
  echo 'CONFIG_IDENT_STRING=" Arch Linux ARM"' >> .config
  make EXTRAVERSION=-${pkgrel}
}

package() {
  cd u-boot-${pkgver/rc/-rc}
  mkdir -p "${pkgdir}"/boot
  cp MLO u-boot.img "${pkgdir}"/boot

  tools/mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d ../boot.txt "${pkgdir}"/boot/boot.scr
  cp ../{boot.txt,mkscr} "${pkgdir}"/boot
}