#!/bin/sh
#
# configure: prepare wmclock to be built using imake and make
# created 1999-Mar-30 03:40 jmk

DefLanguage=english
Language=''
LangDir=''
Me=`basename $0`

GetLanguages() {
    ls -1d lang.* | awk -F . '{
      print "            " $2
    }'
}

PrintHelp() {
    langlist="`GetLanguages`"
    cat <<EOF

  Usage: ${0} [--lang <language>]

  Options:
    --lang <language>
        Configure wmclock to use day and month names for the specified
        language.  Defaults to 'english'.  Choices are:

${langlist}
EOF
}

Die() {
        echo "$*"
	echo "wmclock is NOT successfully configured!"
	exit 1
}

while [ $# -gt 0 ]; do
    case "$1" in
        --lang|--language)
            shift
	    Language="$1"
	    ;;
        --help)
	    PrintHelp
	    exit 1
            ;;
    esac
    shift
done

if [ -z "${Language}" ]; then
    Language="${DefLanguage}"
fi

LangDir="lang.${Language}"
if [ ! -d "${LangDir}" ]; then
    Die "${Me}: error: cannot find language directory '${LangDir}'"
fi

echo "Configuring for ${Language} day-of-week and month names ..."
rm -f month.xpm weekday.xpm
ln -s "./${LangDir}/month.xpm" .
ln -s "./${LangDir}/weekday.xpm" .

echo "Building Makefile from Imakefile ..."
echo "----------------------------------------------------------------"
xmkmf -a

echo "----------------------------------------------------------------"
echo "Finished configuring.  To build wmclock, type 'make'."
echo

exit 0