# Maintainer (Arch):  Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor (Arch): Allan McRae <allan@archlinux.org>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: André Silva <emulatorman@hyperbola.info>

# parabola changes and rationale (based on core/linux-api-headers):
#  - changing upstream source url to linux-libre
#  - change arch from (any) to explicit list, since headers differ across arches

# toolchain build order: linux-api-headers->glibc->binutils->gcc->binutils->glibc

pkgname=linux-libre-api-headers
pkgver=5.8.13_gnu
_minor_ver=${pkgver%.*}
_upstream_ver=${pkgver//_/-}
_dep_ver=${pkgver%_*}
pkgrel=2
pkgdesc='Kernel headers sanitized for use in userspace'
arch=(x86_64 i686 armv7h)
url='https://www.gnu.org/software/libc'
license=(GPL2)
makedepends=(rsync)
provides=("linux-api-headers=${_dep_ver}")
source=(https://linux-libre.fsfla.org/pub/linux-libre/releases/${_minor_ver}-gnu/linux-libre-${_minor_ver}-gnu.tar.xz{,.sign}
        https://linux-libre.fsfla.org/pub/linux-libre/releases/${_upstream_ver}/patch-${_minor_ver}-gnu-${_upstream_ver}.xz{,.sign})
sha256sums=('8146325466ee53cf46f993ba3d17296272f48bc9f13dd29b89e68563fd805980'
            'SKIP'
            '495123509db6c27b89cac3a38ad69d938404eb13ccf34c54e6ec677946b2e4cd'
            'SKIP')
validpgpkeys=('474402C8C582DAFBE389C427BCB7CF877E7D47A7') # Alexandre Oliva

prepare() {
  cd linux-${_minor_ver}
  patch -p1 -i "$srcdir/patch-${_minor_ver}-gnu-${_upstream_ver}"
}

build() {
  cd linux-${_minor_ver}

  make mrproper
  make headers_check
}

package() {
  cd linux-${_minor_ver}
  make INSTALL_HDR_PATH="$pkgdir/usr" headers_install

  # use headers from libdrm
  rm -r "$pkgdir/usr/include/drm"
}
