# U-Boot: Boundary Devices Nitrogen6X/Sabre Lite
# Maintainer: Isaac David <isacdaavid@at@isacdaavid@dot@info>
# Contributor: André Silva <emulatorman@hyperbola.info>

pkgname=uboot4extlinux-nitrogen6q
pkgver=2014.07
pkgrel=3.1
arch=('armv7h')
pkgdesc="U-Boot with Extlinux support for Nitrogen6X/Sabre Lite"
url="https://github.com/boundarydevices/u-boot-imx6/tree/production"
license=('GPL')
makedepends=('bc')
conflicts=('uboot-nitrogen6q' 'uboot4grub-nitrogen6q')
backup=(boot/extlinux/extlinux.conf)
install=${pkgname}.install
_commit=bb9dde563768731423fd6c560e95e1793a90710a
source=("https://github.com/boundarydevices/u-boot-imx6/archive/${_commit}.tar.gz"
        '0001-parabola-arm-modifications.patch'
        '0002-kernel-add-support-for-gcc-7.patch'
        '0003-ARM-asm-io.h-use-static-inline.patch'
        '0004-common-main.c-make-show_boot_progress-__weak.patch'
        '0005-common-board-use-__weak.patch'
        '0006-common-board_f-cosmetic-use-__weak-for-leds.patch'
        'extlinux.conf')
sha256sums=('d06ad5e6b9adb84e7bfa99f8d5335ef06d48b351809e6f65e83a92c0e8a4d3ce'
            '1592a845ef7a229e5d370586edf344502f3ded5c24c853c790b600e8ef0128c7'
            '9e80aa27cccdb07b03d56a970f247c91d586d0b936868c076c20acc2e68a3968'
            '2fb98981885fbffba32fadb7b4a321e5540278c2a97f39b2700ad14c2ddb4d2a'
            '83f56e80b09d010a7d0f9cc18d4df43c7f100ee3a815421f2ccbf2c337ae5431'
            'bb9f0bde66266998db0eae3204346364568bab963fe7be1086d633339652b70c'
            'dd2d912d4e14dc7ea83fbe6148feecc65f104ae367292278f668cdfc11f947a5'
            '38db7f68084a5727a7c7cb101bb96c82f384b8ed4b14c3e1c2f9fcfc07ac164c')

prepare() {
  cd u-boot-imx6-${_commit}

  patch -Np1 -i ../0001-parabola-arm-modifications.patch
  patch -Np1 -i ../0002-kernel-add-support-for-gcc-7.patch
  patch -Np1 -i ../0003-ARM-asm-io.h-use-static-inline.patch
  patch -Np1 -i ../0004-common-main.c-make-show_boot_progress-__weak.patch
  patch -Np1 -i ../0005-common-board-use-__weak.patch
  patch -Np1 -i ../0006-common-board_f-cosmetic-use-__weak-for-leds.patch
}

build() {
  cd u-boot-imx6-${_commit}

  unset CFLAGS
  unset CXXFLAGS

  make distclean
  make nitrogen6q_config
  make
}

package() {
  cd u-boot-imx6-${_commit}

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