#!/bin/tcsh

setenv KDEDIR /opt/kde3
setenv QTDIR  /usr/lib/qt3

if(${?LD_LIBRARY_PATH} == 1 ) then
  setenv LD_LIBRARY_PATH $QTDIR/lib:$KDEDIR/lib:$LD_LIBRARY_PATH
else
  setenv LD_LIBRARY_PATH $QTDIR/lib:$KDEDIR/lib
endif

if(${?LIBRARY_PATH} == 1) then
  setenv LIBRARY_PATH $QTDIR/lib:$KDEDIR/lib:$LIBRARY_PATH
else
  setenv LIBRARY_PATH $QTDIR/lib:$KDEDIR/lib
endif
setenv CXXFLAGS "-g3 -O0"

echo "***** Updating sources *****"

cvs up | tee cvs.log

set doconfigure=0
set domake=0

if ({ grep -q -s "^U.*Makefile.am" cvs.log } == 1) then
  echo "===> found added makefile.am"
  set domake=1
  set doconfigure=1
endif

if ({ grep -q -s "^P.*Makefile.am" cvs.log } == 1) then
  echo "===> found modified makefile.am"
  set doconfigure=1
endif

if ($domake == 1) then
  echo "***** Running make -f makefile.cvs *****"
  make -f makefile.cvs
endif

if ($doconfigure == 1) then
  echo "***** Running configure *****"
 ./configure --enable-debug --prefix=/local/kde3 --with-kdelibsdoxy-dir=/opt/kde3/share/doc/HTML/en/kdelibs-apidocs
endif

echo "***** make *****"

make -k

