#!/bin/sh
#
# Pathetic configure script for mythmusic
#

# default parameters
opengl="no"
fftw_lib="no"
sdl="no"

for opt do
  case "$opt" in
  --enable-opengl) opengl="yes"
  ;;
  --enable-fftw) fftw_lib="yes"
  ;;
  --enable-sdl) sdl="yes"
  ;;
  --enable-all) sdl="yes"; opengl="yes"; fftw_lib="yes";
  ;;
  esac
done

if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
cat << EOF

Usage: configure [options]
Options: [defaults in brackets after descriptions]

Standard options:
  --help                   print this message
  --enable-fftw            enable fftw visualizers [default=no]
  --enable-opengl          enable OpenGL visualizers [default=no]
  --enable-sdl             use SDL for the synaesthesia output [default=no]
  --enable-all             Enable all of the above.
EOF
exit 1
fi

echo "Creating config.h, config.pro"

echo ""
echo "Configuration settings: "
echo " "

echo "/*" >  ./mythmusic/config.h
echo "    Automatically generated by configure - do not modify" >> ./mythmusic/config.h
echo "*/" >> ./mythmusic/config.h

echo "#" > ./mythmusic/config.pro
echo "#    Automatically generated by configure - modify only under penalty of death" >> ./mythmusic/config.pro
echo "#" >> ./mythmusic/config.pro

if test "$opengl" = "yes" ; then
  echo "        OpenGL support will be included"
  echo "#define OPENGL_SUPPORT 1" >> ./mythmusic/config.h
  echo "CONFIG += opengl" >> ./mythmusic/config.pro
fi

if test "$opengl" = "no" ; then
  echo "        OpenGL support will not be included"
fi

if test "$fftw_lib" = "yes" ; then
  echo "        FFTW   support will be included"
  echo "#define FFTW_SUPPORT 1" >> ./mythmusic/config.h
  echo "LIBS += -lrfftw -lfftw" >> ./mythmusic/config.pro
fi

if test "$fftw_lib" = "no" ; then
  echo "        FFTW   support will not be included"
fi

if test "$sdl" = "yes" ; then
  echo "        SDL    support will be included"
  echo "#define SDL_SUPPORT 1" >> ./mythmusic/config.h
  echo "LIBS += `sdl-config --libs`" >> ./mythmusic/config.pro
  echo "QMAKE_CXXFLAGS_RELEASE += `sdl-config --cflags`" >> ./mythmusic/config.pro
  echo "QMAKE_CXXFLAGS_DEBUG += `sdl-config --cflags`" >> ./mythmusic/config.pro
fi

if test "$sdl" = "no" ; then
  echo "        SDL    support will not be included"
fi
echo ""

