# U-Boot: BeagleBoard and BeagleBoard-xM
# Maintainer: Isaac David <isacdaavid@at@isacdaavid@dot@info>
# Contributor: André Silva <emulatorman@hyperbola.info>

pkgname=uboot4extlinux-omap3_beagle
pkgver=2016.01
pkgrel=4.1
pkgdesc="U-Boot with Extlinux support for BeagleBoard and BeagleBoard-xM"
arch=('armv7h')
url="http://git.denx.de/u-boot.git/"
license=('GPL')
conflicts=('uboot-omap3_beagle' 'uboot4grub-omap3_beagle')
makedepends=('bc')
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=('e5792fba9399d9804aa2ef667f14ff771e2cdece72367d340250265bf095a5d5'
            'cf6519bab4270bf093eb6ff0d9f3b4d314d00af6c4ecad07c492977ae5c7f510'
            '9e80aa27cccdb07b03d56a970f247c91d586d0b936868c076c20acc2e68a3968'
            'bb489334db2d44562caa18ed6297068cf7df3afdf1bb8b1b1f27bce0d2b8e987'
            'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')

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 LDFLAGS CFLAGS CXXFLAGS

  make distclean
  make omap3_beagle_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
}
