kind: manual

sources:
- kind: git
  url: upstream:linux
  track: v4.11
  ref: a351e9b9fc24e982ec2f0e76379a49826036da1

depends:
- filename: gnu-toolchain/stage2.bst
  type: build
- gnu-toolchain/fhs-dirs.bst

variables:
  kernel-arch: unsupported
  (?):
    - arch in ["armv5", "armv7b", "armv7l", "armv7lhf"]:
        kernel-arch: arm
    - arch in ["armv8b", "armv8l"]:
        kernel-arch: arm64
    - arch in ["ppc64", "ppc64le"]:
        kernel-arch: powerpc
    - arch == "x86_32":
        kernel-arch: i386
    - arch == "x86_64":
        kernel-arch: x86_64

environment:
  PATH: /usr/bin:/bin:/usr/sbin:/sbin:/tools/bin:/tools/sbin

config:
  install-commands:
  - |
    if [ '%{kernel-arch}' == 'unsupported' ]; then
        echo "Error: unsupported architecture: %{arch}" >&2
        exit 1
    fi
    ARCH=%{kernel-arch} make INSTALL_HDR_PATH=dest headers_install
  - install -d "%{install-root}%{includedir}"
  - cp -r dest/include/* "%{install-root}%{includedir}"
