#!/bin/sh

. config/options

$SCRIPTS/unpack linux

[ $TARGET_ARCH = i386 -o $TARGET_ARCH = x86_64 ] && TARGET_ARCH=x86
[ $TARGET_ARCH = powerpc -o $TARGET_ARCH = powerpc64 ] && TARGET_ARCH=powerpc

cd $(kernel_path)
make ARCH=$TARGET_ARCH headers_check
make ARCH=$TARGET_ARCH INSTALL_HDR_PATH=headers headers_install

mkdir -p headers/.install/usr/usr/include
cp -PR headers/include/* headers/.install/usr/usr/include

if [ "$TARGET_PLATFORM" = omap3 -o "$TARGET_PLATFORM" = omap4 ]; then
  mkdir -p headers/.install/usr/usr/include/asm/arch-omap
  cp -P include/linux/omapfb.h headers/.install/usr/usr/include/asm/arch-omap
  sed -i "s%__user%%g" headers/.install/usr/usr/include/asm/arch-omap/omapfb.h
fi

# boxee requires this deprecated header, let's make it happy
# if arch is i386 or x86_64, with the previous test, TARGET_ARCH is now x86
if [ "$TARGET_ARCH" = x86 ]; then
  cp -P drivers/staging/smbfs/smbno.h headers/.install/usr/usr/include/linux
fi

exit 0
