#!/bin/bash
#
#
# To update all your fvwm AND fvwm-themes configurations
# you must run the following commands while online.
#
CVSFVWM=$HOME"/.fvwm/cvs/fvwm"
CVSTHEME=$HOME"/.fvwm/cvs/fvwm-themes"
FVWMPREFIX="--prefix=/usr"
CFGOPTIONS="--enable-xft"
# DO NOT EDIT BELOW THIS LINE! ####

echo "WARNING! You MUST be online when you run this script!"
echo "         or your software may not be up to date!"
echo
echo "README script by awol@otaku42.de"
# First you must change to the fvwm source directory
echo "First we change into the right directory..."

cd $CVSFVWM && echo $CVSFVWM

echo "Clean up old files."

make distclean && echo "make distclean"

echo
echo "Next we update the fvwm sources..."
echo
cvs update -A && echo "cvs update"

echo
echo "Now the fvwm-themes sources..."
echo

cd $CVSTHEME && echo $CVSTHEME

make distclean

echo "make distclean"
echo
echo "cvs update"
cvs update

echo
echo
echo "OK! You can go offline now if you want...."
echo
echo "Back to the fvwm source tree."

echo "cd to" $CVSFVWM
cd $CVSFVWM
echo
echo "Start ./configure"

utils/configure_dev.sh $FVWMPREFIX $CFGOPTIONS
echo
echo "Now we run make."
echo
make > $CVSFVWM/../build.log-awol 2>&1 

echo
echo "Compilation finished!"
echo
echo "make install is next, but!"
echo "You have to be root to install fvwm."
echo "After login as root this script will"
echo "perform ---> cd "$CVSFVWM" ; make install ; exit"
echo "Command:"
echo "su -c 'cd "$CVSFVWM" ; make install ; exit'"
echo
echo "Please enter the root password."
su -c "cd "$CVSFVWM" ; make install ; exit"


echo "Good!"
echo "Now we go back to fvwm-themes source tree."

echo "cd "$CVSTHEME
cd $CVSTHEME

echo "Repeat configure, make and install..."

./configure $FVWMPREFIX
make >> $CVSTHEME/../build.log-awol 2>&1 

echo
echo
echo
echo "You have to be root to install fvwm-themes."
echo "After this script logs in as root it will perform"
echo "---> cd "$CVSTHEME" ; make install ; exit"
echo
echo "Please enter the root password."

su -c "cd "$CVSTHEME" ; make install ; exit"


echo "If you're reading this, it must have worked!"
echo "Both fvwm and fvwm-themes are now hopefully completely installed."
echo "Restart fvwm and have a nice day! :-)"

