# determines PROJECT, if not forced by user
# default is generic
if [ -z "$PROJECT" ]; then
  PROJECT="generic"
else
  PROJECT=$PROJECT
fi

# determines TARGET_ARCH, if not forced by user (i386 / x86_64 / powerpc)
# default is i386
if [ -z "$ARCH" ]; then
  TARGET_ARCH="i386"
else
  TARGET_ARCH=$ARCH
fi

ROOT=`pwd`
PROJECT_DIR=$ROOT/projects

# read project options if available
 if [ -f $PROJECT_DIR/$PROJECT/options ]; then
   . $PROJECT_DIR/$PROJECT/options
 fi

# Target system library C (eglibc)
  TARGET_LIBC=eglibc

# Library strip
  LIBSTRIP=yes

# Need to point to your actual cc
# If you have ccache installed, take care that LOCAL_CC don't point to it
  LOCAL_CC=`which gcc`

# Need to point to your actual g++
# If you have ccache installed, take care that LOCAL_CXX don't point to it
  LOCAL_CXX=`which g++`

# Support C++ in toolchain
  TOOLCHAIN_CXX=yes

# verbose compilation mode (yes/no)
  VERBOSE=yes

# download new sources when url file is updated (yes/no/ask)
  AUTOUPDATE=yes

# Concurrency make level (-j option)
#  Try value 1 (default) to 4 on single CPU computer, or more on
#  multi-processor computer (like hyperthreading SMP CPU)
  CONCURRENCY_MAKE_LEVEL=1

get_graphicdrivers() {
  if [ "$GRAPHIC_DRIVERS" = all ]; then
    GRAPHIC_DRIVERS="i915 i965 r200 r300 r600 radeon nvidia"
  fi

  for drv in $GRAPHIC_DRIVERS; do
    [ $drv = i915 ] && MESA_DRIVERS="$MESA_DRIVERS,i915"
    [ $drv = i965 ] && MESA_DRIVERS="$MESA_DRIVERS,i965"
    [ $drv = r200 ] && MESA_DRIVERS="$MESA_DRIVERS,r200"
    [ $drv = r300 ] && MESA_DRIVERS="$MESA_DRIVERS,r300"
    [ $drv = r600 ] && MESA_DRIVERS="$MESA_DRIVERS,r600"
    [ $drv = radeon ] && MESA_DRIVERS="$MESA_DRIVERS,radeon"

    if [ $drv = i915 -o $drv = i965 ]; then
      XORG_DRIVERS="$XORG_DRIVERS intel"
      DRM_DRIVERS="$DRM_DRIVERS intel"
    fi

    if [ $drv = r200 -o $drv = r300 -o $drv = r600 -o $drv = radeon ]; then
      XORG_DRIVERS="$XORG_DRIVERS ati"
      DRM_DRIVERS="$DRM_DRIVERS radeon"
    fi

    if [ $drv = nvidia ]; then
      XORG_DRIVERS="$XORG_DRIVERS nvidia"
      XINERAMA_SUPPORT="yes"
    fi

  done
}

. config/path
