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

pkgname=uboot4extlinux-udoo
pkgver=2016.11
pkgrel=1.1
pkgdesc="U-Boot with Extlinux support for UDOO Dual and Quad"
arch=('armv7h')
url="http://git.denx.de/u-boot.git/"
conflicts=('uboot-udoo' 'uboot4grub-udoo')
replaces=('uboot4extlinux-udoo_dl' 'uboot4extlinux-udoo_quad')
license=('GPL')
makedepends=('bc' 'swig')
backup=(boot/extlinux/extlinux.conf)
install=${pkgname}.install
source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver/rc/-rc}.tar.bz2"
        '0001-parabola-arm-modifications.patch'
        '0002-kernel-add-support-for-gcc-7.patch'
        'extlinux.conf')
sha256sums=('45813e6565dcc0436abe6752624324cdbf5f3ac106570d76d32b46ec529bcdc8'
            '5a93f489208f0f2e9415779770827024e24ca717438c0998499b59b59cd6189d'
            '9e80aa27cccdb07b03d56a970f247c91d586d0b936868c076c20acc2e68a3968'
            '7398bad545ed40e7809badc2ef0211796402187c1e307e7bd86972624ce4e1bb')

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

  patch -Np1 -i ../0001-parabola-arm-modifications.patch
  patch -Np1 -i ../0002-kernel-add-support-for-gcc-7.patch
}

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

  unset CFLAGS CXXFLAGS LDFLAGS

  make distclean
  make udoo_defconfig
  make EXTRAVERSION=-${pkgrel}
}

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

  mkdir -p "${pkgdir}"/boot/extlinux
  cp "${srcdir}"/extlinux.conf "${pkgdir}"/boot/extlinux
  cp SPL u-boot.img "${pkgdir}"/boot
}
