#!/bin/sh

. config/options

$SCRIPTS/build toolchain
$SCRIPTS/build libpthread-stubs
$SCRIPTS/build udev

get_graphicdrivers

DRM_CONFIG="--disable-libkms --disable-intel --disable-radeon"

for drv in $DRM_DRIVERS; do
  [ $drv = intel ] && \
    DRM_CONFIG=`echo $DRM_CONFIG | sed -e 's/disable-libkms/enable-libkms/'` \
    DRM_CONFIG=`echo $DRM_CONFIG | sed -e 's/disable-intel/enable-intel/'`

  [ $drv = radeon ] && \
    DRM_CONFIG=`echo $DRM_CONFIG | sed -e 's/disable-libkms/enable-libkms/'` \
    DRM_CONFIG=`echo $DRM_CONFIG | sed -e 's/disable-radeon/enable-radeon/'`
done

export LIBUDEV_CFLAGS="-I`ls -d $ROOT/$BUILD/udev*`"
export LIBUDEV_LIBS="-I`ls -d $ROOT/$BUILD/udev*`"

cd $PKG_BUILD
./configure --host=$TARGET_NAME \
            --build=$HOST_NAME \
            --prefix=/usr \
            --sysconfdir=/etc \
            --disable-static \
            --enable-shared \
            --enable-udev \
            --enable-largefile \
            --with-kernel-source=$(kernel_path) \
            $DRM_CONFIG \

make

$MAKEINSTALL
