# U-Boot: UDOO
# Maintainer: André Silva <emulatorman@hyperbola.info>

buildarch=4

pkgbase=uboot4grub-udoo
pkgname=('uboot4grub-udoo_dl' 'uboot4grub-udoo_quad')
pkgver=2015.01
pkgrel=1
arch=('armv7h')
url="http://git.denx.de/u-boot.git/"
license=('GPL')
makedepends=('bc')
depends=('grub-udoo')
source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2"
        '0001-parabola-arm-modifications+grub-support.patch'
        '0002-kernel-add-support-for-gcc-5.patch')
md5sums=('7f08dc9e98a71652bd6968888ed6ec95'
         'e2176de47d43fc4e75e4752a7622021d'
         '721a46867e189d8dedc6b6f86a536a34')

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

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

build() {
  cd u-boot-${pkgver}
  
  unset CFLAGS CXXFLAGS LDFLAGS
  
  mkdir bins
  for i in dl quad; do
    make distclean
    make udoo_${i}_config
    make
    mv u-boot.imx bins/u-boot-${i}.imx
  done
}

package_uboot4grub-udoo_dl() {
  pkgdesc="U-Boot with GRUB support for UDOO Dual"
  replaces=('uboot-udoo-dual' 'uboot-udoo-dual-linux-libre'
            'uboot-udoo-dual-linux-libre-lts' 'uboot-udoo-dual-linux-libre-grsec'
            'uboot-udoo-dual-linux-libre-pck' 'uboot-udoo-dual-linux-libre-knock'
            'uboot-udoo-dual-linux-libre-lts-knock' 'uboot-udoo-dual-linux-libre-audit'
            'uboot-udoo-dual-linux-libre-rt' 'uboot-udoo-dual-linux-libre-grsec-knock')
  conflicts=('uboot4grub' 'uboot-udoo-dual' 'uboot-udoo-dual-linux-libre'
             'uboot-udoo-dual-linux-libre-lts' 'uboot-udoo-dual-linux-libre-grsec'
             'uboot-udoo-dual-linux-libre-pck' 'uboot-udoo-dual-linux-libre-knock'
             'uboot-udoo-dual-linux-libre-lts-knock' 'uboot-udoo-dual-linux-libre-audit'
             'uboot-udoo-dual-linux-libre-rt' 'uboot-udoo-dual-linux-libre-grsec-knock')
  provides=('uboot4grub' 'uboot-udoo-dual')
  install=${pkgbase}.install

  mkdir -p "${pkgdir}"/boot
  cp u-boot-${pkgver}/bins/u-boot-dl.imx "${pkgdir}"/boot/u-boot.imx
}

package_uboot4grub-udoo_quad() {
  pkgdesc="U-Boot with GRUB support for UDOO Quad"
  replaces=('uboot-udoo-quad' 'uboot-udoo-quad-linux-libre'
            'uboot-udoo-quad-linux-libre-lts' 'uboot-udoo-quad-linux-libre-grsec'
            'uboot-udoo-quad-linux-libre-pck' 'uboot-udoo-quad-linux-libre-knock'
            'uboot-udoo-quad-linux-libre-lts-knock' 'uboot-udoo-quad-linux-libre-audit'
            'uboot-udoo-quad-linux-libre-rt' 'uboot-udoo-quad-linux-libre-grsec-knock')
  conflicts=('uboot4grub' 'uboot-udoo-quad' 'uboot-udoo-quad-linux-libre'
             'uboot-udoo-quad-linux-libre-lts' 'uboot-udoo-quad-linux-libre-grsec'
             'uboot-udoo-quad-linux-libre-pck' 'uboot-udoo-quad-linux-libre-knock'
             'uboot-udoo-quad-linux-libre-lts-knock' 'uboot-udoo-quad-linux-libre-audit'
             'uboot-udoo-quad-linux-libre-rt' 'uboot-udoo-quad-linux-libre-grsec-knock')
  provides=('uboot4grub' 'uboot-udoo-quad')
  install=${pkgbase}.install

  mkdir -p "${pkgdir}"/boot
  cp u-boot-${pkgver}/bins/u-boot-quad.imx "${pkgdir}"/boot/u-boot.imx
}
