# U-Boot: BeagleBone and BeagleBone Black
# Maintainer: Isaac David <isacdaavid@at@isacdaavid.info>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor: Jookia <166291@gmail.com>
# Contributor: Márcio Silva <coadde@hyperbola.info>

pkgname=uboot4extlinux-am335x_bone
pkgver=2015.04
pkgrel=4.1
pkgdesc="U-Boot with Extlinux support for BeagleBone and BeagleBone Black"
arch=('armv7h')
url="http://git.denx.de/u-boot.git/"
conflicts=('uboot-am335x_bone' 'uboot4grub-am335x_bone')
makedepends=('bc')
license=('GPL')
backup=(boot/extlinux/extlinux.conf)
install=${pkgname}.install
source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2"
        '0001-parabola-arm-modifications.patch'
        '0002-kernel-add-support-for-gcc-7.patch'
        'extlinux.conf'
        'uEnv.txt')
sha256sums=('0a1a70df586655f527befa6f12e184e96ed61b126e5a567382321b17200f5d60'
            'ba5c395e5250fa13d608823e278936862d4fc472cfbf24dc94d9d90e5d9360b7'
            '9e80aa27cccdb07b03d56a970f247c91d586d0b936868c076c20acc2e68a3968'
            '5cdafa8abc97f1f7b9395b4f1d39494509d0f225f41bd8f030d6f31d549ba64f'
            '4ef3c3177e4476cdb1790dd021d2383ef9913c029d005ffbeb61b958e753672e')

prepare() {
  cd u-boot-${pkgver}
  patch -Np1 -i ../0001-parabola-arm-modifications.patch
  patch -Np1 -i ../0002-kernel-add-support-for-gcc-7.patch
}

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

  unset CFLAGS CXXFLAGS LDFLAGS
  make distclean
  make am335x_evm_config
  make
}

package() {
  cd u-boot-${pkgver}
  mkdir -p "${pkgdir}"/boot/extlinux
  cp MLO u-boot.img "${srcdir}"/uEnv.txt "${pkgdir}"/boot
  cp "${srcdir}"/extlinux.conf "${pkgdir}"/boot/extlinux
}
