#!/bin/sh

LS=/bin/ls

rm -f config.h
rm -f dirs.h

echo "/* auto-generated config.h for AScd. */" >  config.h
echo "/* do not edit. Run ./configure!       */" >> config.h
echo "" >> config.h

echo "/* internal defines, do not change! */" >> config.h
echo "#define PACKAGE \"ascd\"" >> config.h
cat version.h >> config.h
echo "" >> config.h
echo "/* user choices */" >> config.h
echo "#define DEFAULT_COLOR \"#2FAFAF\"" >> config.h
echo "#define DEFAULT_BGCOLOR \"#000000\"" >> config.h

clear

#################################################################

echo
echo "==================================================================="
echo "Please select a default CD device. This can be overriden at run"
echo "time with the -d option. Default is /dev/cdrom. You can also type"
echo "'NO' if you don't want to specify a default device (in case you're"
echo "using Volume Manager for example."
echo
printf "Default device or NO (or return to accept the default): "
read CDD

case $CDD in
   "")	echo "#define DEFAULTDEVICE \"/dev/cdrom\"" >> config.h
	echo "Ok, the default device will be /dev/cdrom"
	;;
   NO)	echo "#define DEFAULTDEVICE \"/dev/cdrom\"" >> config.h
	echo "#define NO_D_DEVICE" >> config.h
	echo "Ok, no device option enabled."
	;;
   *)	echo "#define DEFAULTDEVICE \"$CDD\"" >> config.h
	echo "Ok, the default device will be $CDD"
	;;
esac

#################################################################

echo
echo "==================================================================="
echo "Where shall I install ascd program? Press return to accept the"
echo "default value (/usr/local/bin)."
echo
printf "Bin directory? "
read BINDIR

case $BINDIR in 
    "") echo "#define CBINDIR /usr/local/bin" > dirs.h
        echo "Ascd will be installed in /usr/local/bin."
	;;
    *)	echo "#define CBINDIR $BINDIR" >> dirs.h
        echo "Ascd will be installed in $BINDIR."
	;;
esac

#################################################################

echo
echo "==================================================================="
echo "Where shall I install the man page? Press return to accept the"
echo "default value (/usr/local/man/man1)."
echo
printf "Man directory? "
read MANDIR

case $MANDIR in 
    "") echo "#define CMANDIR /usr/local/man/man1" >> dirs.h
        echo "Man page will be installed in /usr/local/man/man1."
	;;
    *)	echo "#define CMANDIR $MANDIR" >> dirs.h
        echo "Man page will be installed in $MANDIR."
	;;
esac

#################################################################

echo
echo "==================================================================="
echo "Where shall I install the visual themes pixmaps? Press return to"
echo "accept default value (/usr/local/share/AScd)."
echo
printf "Themes pixmaps directory? "
read THDIR

case $THDIR in 
    "") echo "#define THDIR \"/usr/local/share/AScd\"" >> config.h
        echo "#define CTHDIR /usr/local/share/AScd" >> dirs.h
        echo "Pixmaps will be installed in /usr/local/share/AScd."
	;;
    *)	echo "#define  \"$THDIR\"" >> config.h
        echo "#define CTHDIR $THDIR" >> dirs.h
        echo "Pixmaps will be installed in $THDIR."
	;;
esac


#################################################################

echo
echo "==================================================================="
echo "If you're using WindowMaker window manager, AScd can be compiled"
echo "with a configuration window using WINGs toolkit. Please note that"
echo "it's work in progress and you may have to change a few things in"
echo "ascd/Imakefile."
echo
echo "1) compile with WINGs support"
echo "2) no WINGs support (DEFAULT)"
echo
printf "Type 1 or 2: "
read WINGS

case $WINGS in 
    1)  echo "#define WMK" >> config.h
    	echo "Compiling with WINGs support."
	;;
    *)	echo "No WINGs support."
	;;
esac

#################################################################

echo "==================================================================="
echo "Configuration is done. Running xmkmf to generate the Makefiles."
echo

xmkmf -a

echo
echo "-------------------------------------------------------------------"
echo "You are now ready to compile AScd. type:"
echo
echo "make                ... to compile the software"
echo "make install        ... to install it"
echo "make install.man    ... to install the man page"
echo "-------------------------------------------------------------------"
echo
