#! /bin/sh
#
# This script installs the GCC4TI documentation
# For this, a directory "doc" has to be created.
#
echo GCC4TI script: Installing GCC4TI documentation...

isos=`uname -a | grep "opensolaris"`
if [ "x$isos" = "x" ]; then
	#Assume GNU or BSD install
        install=install
else
        install=ginstall
fi

cd ..

${install} -d "$PREFIX_GCC4TI/doc" || exit 1
${install} -m 644 AUTHORS BUGS CHANGELOG COPYING DIRECTORIES HOWTO INSTALL README README.linux README.osX "$PREFIX_GCC4TI/doc" || exit 1

${install} -d "$PREFIX_GCC4TI/doc/a68k" || exit 1
cd sources/a68k; ${install} -m 644 Bugs.txt Doc.txt History.txt ToDo.txt "$PREFIX_GCC4TI/doc/a68k" || exit 1

${install} -d "$PREFIX_GCC4TI/doc/tigcc" || exit 1
cd ../tigcc; ${install} -m 644 AUTHORS COPYING ChangeLog README "$PREFIX_GCC4TI/doc/tigcc" || exit 1

${install} -d "$PREFIX_GCC4TI/doc/tprbuilder" || exit 1
cd ../tprbuilder; ${install} -m 644 AUTHORS COPYING ChangeLog README "$PREFIX_GCC4TI/doc/tprbuilder" || exit 1

rm -Rf "$PREFIX_GCC4TI/doc/parser"

${install} -d "$PREFIX_GCC4TI/doc/patcher" || exit 1
cd ../patcher; ${install} -m 644 AUTHORS COPYING ChangeLog README "$PREFIX_GCC4TI/doc/patcher" || exit 1

rm -Rf "$PREFIX_GCC4TI/doc/html"
cd ../../tigcclib/doc; cp -Rf html "$PREFIX_GCC4TI/doc"
rm -Rf "$PREFIX_GCC4TI/doc/tigcclib"
ln -sf "$PREFIX_GCC4TI/doc/html" "$PREFIX_GCC4TI/doc/tigcclib"
iswin1=`echo $GCC4TIHOST | grep -E -i "msys|mingw|cygwin"`
iswin2=`uname -a | grep -E -i "msys|mingw|cygwin"`
if [ "x$iswin1" = "x" -a "x$iswin2" = "x" ]; then
${install} ../../tigcclib/doc/converter/gcc4tidoc "$PREFIX_GCC4TI/bin" || exit 1
fi

echo GCC4TI script: Creating GCC4TI projects folder...
${install} -d "$PREFIX_GCC4TI/projects" || exit 1

echo Done.

exit 0
