# Copyright (C) 2018, 2019 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the CC0 1.0 License.
# Maintainer: Parabola Hackers <dev@lists.parabola.nu>

_pkgname=barebox
pkgname=barebox-am335x
pkgver=2019.02.0
pkgrel=1
pkgdesc="Barebox for devices with an am335x system on a chip"
arch=('armv7h')
makedepends=('lzop')
url="http://barebox.org/"
license=('GPL2')
install=${_pkgname}.install
source=("http://barebox.org/download/${_pkgname}-${pkgver}.tar.bz2")
sha512sums=('648827efeec7b2591eaf43daf98368be1902e3f8157c8acd88b9f103078e9989bb158d81eda013e360d6dfdfbb3c7aae0e334fce957663b72ca46f419c33e981')

build() {
  cd ${_pkgname}-${pkgver}
  unset CFLAGS CXXFLAGS LDFLAGS

  if [ "$CARCH" = "armv7h" ]; then
    export ARCH=arm
    make am335x_mlo_defconfig
    make

    make omap_defconfig
    make
    # TODO: Add support for more ARM SOCs and
    # CPU architectures (Barebox also supports
    # x86 and PowerPC)
  fi
}

package() {
  cd ${_pkgname}-${pkgver}
  mkdir -p "${pkgdir}/boot/barebox/images/"
  install -t "${pkgdir}/boot/barebox/images/" images/barebox-*.img
}
