#!/bin/sh
clear
echo Welcome to the new world of asclock!
echo
echo Specify the versions you want to build. Note that you can always
echo "build them explicitly by issuing 'make asclock' (gtk) or 'make asclock_applet'"
echo "(gnome) in the shell."
echo "asclock         : the gtk standalone version"
echo "asclock_applet  : the applet version (always docks to the gnome panel)"
echo "all             : both versions"
printf "I want to build [default=='asclock']:"
read build
case $build in
  asclock_applet)  build="asclock_applet";;
  all)             build="all";;
  *)     	   build="asclock";;
esac

echo You selected \'make $build\'
echo
echo you can build one of the following themes into asclock as a default theme,
echo "without specifying it with -t <theme-name>"
echo
cd themes
for i in *
do
  echo $i
done

printf "choose a theme from above: "
read line

for i in *
do
  if test $i = $line
  then cd ..
    echo
    echo you selected \'$line\'
    echo
    echo proceed by saying 'make' and then 'make install' if appropriate
    echo
    rm -f default_theme
    ln -s themes/$line default_theme
    if test -f ./default_theme/beats.xpm
    then echo beats.xpm found
    else echo "char *beats_xpm[] = { NULL };" >>./default_theme/beats.xpm
    fi
    if test -f ./default_theme/date.xpm 
    then echo date.xpm found
    else echo "char *date_xpm[] = { NULL };" >>./default_theme/date.xpm
    fi
    if test -f ./default_theme/led.xpm 
    then echo led.xpm found
    else echo "char *led_xpm[] = { NULL };" >>./default_theme/led.xpm
    fi
    if test -f ./default_theme/month.xpm 
    then echo month.xpm found
    else echo "char *month_xpm[] = { NULL };" >>./default_theme/month.xpm
    fi
    if test -f ./default_theme/weekday.xpm 
    then echo weekday.xpm found
    else echo "char *weekday_xpm[] = { NULL };" >>./default_theme/weekday.xpm
    fi
    if test -f ./default_theme/minute.xpm 
    then echo minute.xpm found
    else echo "char *minute_xpm[] = { NULL };" >>./default_theme/minute.xpm
    fi
    if test -f ./default_theme/hour.xpm 
    then echo hour.xpm found
    else echo "char *hour_xpm[] = { NULL };" >>./default_theme/hour.xpm
    fi
    if test -f ./default_theme/second.xpm 
    then echo second.xpm found
    else echo "char *second_xpm[] = { NULL };" >>./default_theme/second.xpm
    fi

    echo Do you want to build \'$build\' now [default==\'yes\']?
    read bla
    case $bla in
      [Nn]|[Nn][Oo])  echo no make no clock...;
		 exit 0;
		 ;;
	*)	 touch config.c asclock.c;
		 make $build;;
    esac
    exit 0
  fi
done

echo try again. The theme $line does not exist..
exit -1

