#!/bin/sh
#
# Copyright (C) 2004 Florian Briegel / MPIA <briegel@mpia.de>
#  
# copyright conditions offered by the company MPIA
#  
# file <reconf> version <#0.1.0#> of project <LGCS>

#!/bin/sh


#DELCONF_FILES=`ls config.*`
DELETE_FILES=" config.cache    acconfig.h    Makefile    Makefile.in    aclocal.m4    configure    ${DELCONF_FILES}"
for DF in ${DELETE_FILES}; 
do
  echo "deleting ${DF}"
  find . -name ${DF} -exec rm \{\} \;
done

#find . -type l -exec rm \{\} \;

:> acinclude.m4
M4_FILES=`ls config/m4/*.m4`
echo "- creating acinclude.m4 with:"
for M4 in $M4_FILES; 
do
 echo m4_include\([$M4]\) >> acinclude.m4;
 echo m4_include\([$M4]\)
done

echo "- aclocal."
aclocal 


if test `uname` = "Darwin"; then
    echo "- glibtoolize"
    glibtoolize --force
else
    echo "- libtoolize"
    if test "x`libtool --version | head -1 | cut -d" " -f4 | cut -d"." -f1`" = "x"; then
      libtoolize --force --install;
    else
      libtoolize --force;
    fi
fi

echo "- autoconf."
autoconf
echo "- autoheader."
autoheader
echo "- automake."
automake --add-missing

if test -n "$INSROOT"; then
  echo "Now its time for ./configure --prefix=$INSROOT"
elif test -n "$LNROOT"; then
  echo "Now its time for ./configure --prefix=$LNROOT"
  echo "Please change your enviroment from LNROOT to INSROOT\!"
else
  echo
  echo "Please add the following enviroment variables to .bashrc:"
  echo "  export INSROOT=your_install_path"
  echo "  export LD_LIBRARY_PATH=\$INSROOT/lib"
  echo "  export PATH=\$INSROOT/bin:\$PATH"
  echo "  export MANPATH=\$INSROOT/man:\$MANPATH"
  echo "  export USERNAME=\"John Doe\""
  echo "  export USEREMAIL=doe@the.end"
  echo "  export QT_PLUGIN_PATH=\$INSROOT/lib/plugins:\$QT_PLUGIN_PATH"
fi

#test -d `uname -m` || mkdir `uname -m`
#cd `uname -m`
#echo "- configure."
#../configure $* 
#exit
