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

pkgname=uboot4extlinux-chiliboard
pkgver=2014.07
pkgrel=3.1
pkgdesc="U-Boot with Extlinux support for ChiliBoard"
arch=('armv7h')
url="http://git.denx.de/u-boot.git/"
conflicts=('uboot-chiliboard' 'uboot4grub-chiliboard')
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-kernel-add-support-for-gcc-7.patch'
        '0002-ARM-asm-io.h-use-static-inline.patch'
        '0003-common-main.c-make-show_boot_progress-__weak.patch'
        '0004-common-board_f-cosmetic-use-__weak-for-leds.patch'
        '0005-chiliboard-support.patch'
        '0006-parabola-arm-modifications.patch'
        'extlinux.conf'
        'uEnv.txt')
sha256sums=('b4f83b8db325c21671a997198ec3a373e2e00dde2fcf17be9b9afd7cfd727f56'
            '9e80aa27cccdb07b03d56a970f247c91d586d0b936868c076c20acc2e68a3968'
            '91b2711f36fbe1bae5d02b3a1eec81383ffd50a4b71426b82920cfd70af40237'
            '0bb7ddee0b33ba7ca830f09b6aaacc945c7a662749a19b128eb1cab71f5b100a'
            '2795b55f0ef03aef6c05fd074ab9839d0f89fdc5a3c99dd849eb74cd09e59045'
            'af804b3dd8167c61c79dfc831d34558cf8ce981dfea3df9da7f98acaee2a0edf'
            '1fca49c07c65708a1b167560c73af12d59d7e5da92794f47ecf2a27d4f765793'
            '5cdafa8abc97f1f7b9395b4f1d39494509d0f225f41bd8f030d6f31d549ba64f'
            '7882bc2f75089c83c0c3b0a22bfb5a10d3700545e600f616910bd6cdecc79237')

prepare() {
  cd u-boot-${pkgver}
  patch -Np1 -i ../0001-kernel-add-support-for-gcc-7.patch
  patch -Np1 -i ../0002-ARM-asm-io.h-use-static-inline.patch
  patch -Np1 -i ../0003-common-main.c-make-show_boot_progress-__weak.patch
  patch -Np1 -i ../0004-common-board_f-cosmetic-use-__weak-for-leds.patch
  patch -Np1 -i ../0005-chiliboard-support.patch
  patch -Np1 -i ../0006-parabola-arm-modifications.patch
}

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

  unset CFLAGS CXXFLAGS LDFLAGS

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