#!/bin/sh

. config/options

$SCRIPTS/build module-init-tools
$SCRIPTS/install linux system

VER=`ls $BUILD/linux*/modules/lib/modules`

mkdir -p $INSTALL/usr/lib
cp -PR $PKG_BUILD/libdrm/.libs/libdrm.so* $INSTALL/usr/lib
#cp -PR $PKG_BUILD/libdrm/intel/.libs/libdrm_intel.so* $INSTALL/usr/lib

#mkdir -p $INSTALL/lib/modules/$VER

mkdir -p "`ls -d $INSTALL/lib/modules/*`/kernel/drivers/gpu/drm"
cp -r $PKG_BUILD/linux-core/drm.ko $INSTALL/lib/modules/*/kernel/drivers/gpu/drm

mkdir -p "`ls -d $INSTALL/lib/modules/*`/kernel/drivers/gpu/drm/openchrome"
cp -r $PKG_BUILD/linux-core/openchrome/*.ko $INSTALL/lib/modules/*/kernel/drivers/gpu/drm/openchrome

for MOD in `find $INSTALL/lib/modules/ -name *.ko`; do
  $STRIP --strip-debug $MOD
done

$BUILD/module-init-tool*/build/depmod -b $INSTALL -v $VER > /dev/null
for i in `ls $INSTALL/lib/modules/*/modules.* | grep -v modules.dep | grep -v modules.alias | grep -v modules.symbols`; do
  rm -f $i
done
