#!/bin/sh

FEATURES="
GNOME gnome
GNOME2 gnome2
GTK gtk
GTK2 gtk2
SKINS skins
BASIC_SKINS basic-skins
FAMILIAR familiar
WXWINDOWS wxwindows
QT qt
KDE kde
OPIE opie
MACOSX macosx
QNX qnx
INTFWIN intfwin
NCURSES ncurses
XOSD xosd
DVDOLD dvd
DVDREAD dvdread
DVDPLAY dvdplay
DVBPSI dvbpsi
VCD vcd
V4L v4l
SAT satellite
X11 x11
XVIDEO xvideo
SDL sdl
FB fb
DIRECTX directx
WINGDI wingdi
FREETYPE freetype
QTE qte
MGA mga
SVGALIB svgalib
GGI ggi
GLIDE glide
AA aa
OSS oss
ESD esd
ARTS arts
ALSA alsa
WAVEOUT waveout
COREAUDIO coreaudio
OGG ogg
A52 a52
MAD mad
FFMPEG ffmpeg
FAAD faad
XVID xvid
DV dv
FLAC flac
LIBMPEG2 libmpeg2
VORBIS vorbis
TREMOR tremor
TARKIN tarkin
THEORA theora
SOUT sout
SLP slp
DEBUG debug
"
PATHS="
FFMPEG_TREE ffmpeg-tree
"
if [ ! -e .config ]
then
   ./menuconfig
fi

echo -n "./configure " > .cmd
source .config

check_features () {
while [ -n "$1" ]
do
   eval x="\$CONFIG_$1"
   if [ "$x" == "y" ]
   then
      echo -n "--enable-$2 " >> .cmd
   else
      echo -n "--disable-$2 " >> .cmd
   fi
   shift; shift
done
}

check_paths () {
while [ -n "$1" ]
do
   if [ -n $1 ]
   then
      eval x="\$CONFIG_$1"
      echo -n "--with-$2=$x" >> .cmd
   fi
   shift; shift
done
}

check_features $FEATURES
check_paths $PATHS

if [ ! -e configure ]
then
   ./bootstrap
fi

source .cmd
make
rm -f .cmd
