#!/bin/bash
#
# This script will copy any files in this directory to the documentation
# directory, excluding this script.
#
# If the documentation directory does not exist this script will make the
# documentation directory and will copy the documentation to it.
#

docDir="$1"

# Check usage.
if [ -z "$docDir" ]; then
    echo "Incorrect usage of doc/SyncDoc script.  Will continue anyway."
    exit 0
fi

if [ ! -d "$docDir" ]; then
    if [ -e "$docDir" ]; then
	echo "$docDir is not a directory.  Please fix this."
	exit 0
    fi
    
    # Make the documentation directory.
    mkdir -p "$docDir" || {
	echo "Could not create directory: $docDir"
	echo "Documentation not installed."
	exit 0
    }
fi

# Copy documentation.
cd doc
for docFile in *; do
    # Don't copy this script.
    if [ "$docFile" == "SyncDoc" ]; then
	continue
    fi

    cp "$docFile" "$docDir/$docFile"
done
cd ..

echo "Documentation has been installed to: $docDir"

exit 0
