#!/bin/sh

echo "This program accepts one command line switch,which is the QTDIR to use."

export TMAKEPATH=./tools/template/linux-g++

if test "${1+set}" = set; then
	QTDIR=$1
fi;
		    
if [ "$QTDIR" = "" ]; then
	echo "QTDIR is not set. Cannot configure."
else

echo "**************************"
echo "Your QTDIR is $QTDIR"
echo "Please, ensure that it is pointing to the right directory"
echo "**************************"

(cd tools && \
echo "Executing: cd tools &&"  && \
tar -pzxf tmake.tar.gz && \
echo "Executing: tar -pzxf tmake.tar.gz"  && \
cd .. && \
echo "Executing: cd .."  && \
tools/tmake LA4.pro >Makefile && \
echo "Executing: tools/tmake LA4.pro >Makefile"  && \
rm -f tools/tmake && \
echo "Executing: rm -f tools/tmake"  && \
rm -rf tools/template && \
echo "Executing: rm -rf tools/template"  && \
echo "Success." && \
# i18n : no output, lrelease will say if they were any problems
# and i18n is not mandatory in order to compile the project
# TODO: path of lrelease ?
if test -f /usr/bin/lrelease; then \
		lrelease LA4.pro
fi && \
echo "You can go on now and type 'make'" && \
echo "" && \
echo "WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" && \
echo "LA4 now needs libxml and libxslt for code generation." && \
echo "" && \
echo "By default, code generation is enabled." && \
echo "If you want to compiles LA4 without it, see LA4.pro" && \
echo "for the lines to comment and uncomment before rerunning configure" && \
echo "" && \
echo "Development files for libxml and libxslt should be placed" && \
echo "in /usr/include/libxml2".) || \
echo "Ooops, something went wrong. You should perhaps consider the manual procedure."

export QTDIR
fi
