#!/bin/sh

## This file is copyright (c) 2009-2015 Bruce Ravel and
## licensed under The Creative Commons Attribution-ShareAlike License.

## use the Template Toolkit to configure itself for building the
## Athena document.  This runs tpage on the templates in the bin/ and
## etc/ directories to generate the actual scripts and cfg files
## needed to build the various forms of the doc

id=`pwd`

if [ ! $1 ]; then echo "Configuring the Artemis User's Guide build system for your machine"; fi

if [ ! $1 ]; then echo "  configuring bin directory"; fi
files="build tex" # texbw pod mobile"
for b in $files; do
    rm -f bin/$b
    tpage --define installdir="$id" bin/$b.tt > bin/$b
    chmod +x bin/$b
done

if [ ! $1 ]; then echo "  configuring etc directory"; fi
files="ttree ttree_tex" # ttree_texbw ttree_pod ttree_mobile"
for b in $files; do
    rm -f etc/$b
    tpage --define installdir="$id" etc/$b.tt > etc/$b.cfg
done

if [ ! $1 ]; then echo "  copying map and version templates"; fi
cp etc/map     ../lib/config/map.artemis
cp etc/version ../lib/config/version.artemis
cp etc/map     ../latex/config/map.artemis
cp etc/version ../latex/config/version.artemis
#cp etc/map etc/version templates/latex/config/
#cp etc/map etc/version templates/pod/config/
#cp etc/map etc/version templates/mobile/config/

if [ ! $1 ]; then echo "  linking to perl modules from DPG"; fi
ln -sf ../dpg/Template
