if [ "x$DTDROOT" != "x/usr/share/susedoc" ]; then
    export XML_CATALOG_FILES="$DTDROOT/etc/catalog.xml"
else
    unset XML_CATALOG_FILES
fi
unset FOPOPTIONS
unset COMMENTS
unset REMARKS
unset PROFOS
unset PROFARCH
unset ENVFILES
unset PROFVENDOR
unset PROFCONDITION
unset STYLENOV
unset STYLEFO
unset STYLEH
unset ROOTID
unset PDFNAME
unset FOP
unset LAYOUT
unset HTMLROOT
unset PRODUCTNAME
unset PRODUCTNAMEREG
unset DISTVER
unset TITLE
unset DRAFT

export BOOK="${BASH_ARGV[2]#*ENV-}"
echo "Setting BOOK variable to ${BOOK}"

if test -z "$XMLFORMAT_CONF"; then
    export XMLFORMAT_CONF=$DTDROOT/etc/docbook-xmlformat.conf
fi

if test -f "$(/usr/bin/which svn)"; then
    if DOC_RELEASE=$(svn pg doc:release ${BASH_SOURCE[1]}>&/dev/null); then
	export DOC_RELEASE
    else
	echo "No docmanager available, continuing ..."
    fi
else
    echo "local copy"
fi

NOVBIN=$(cd $DTDROOT;pwd)
echo $PATH | grep $NOVBIN &> /dev/null || PATH=$PATH:$NOVBIN/bin
export PATH

# find out if a common directory exists in this doc repository.
COMMON=$(cd ../../common 2> /dev/null || true; pwd)
if test "z$COMMON" != "$(pwd)"; then
  export COMMON
else
  unset COMMON
fi

# use exiftool and optipng if available
EXIFTOOL=$(type -p exiftool || echo /bin/true)
export EXIFTOOL

OPTIPNG=$(type -p optipng || echo /bin/true)
export OPTIPNG

DB2EPUB=$(type -p /usr/share/xml/docbook/stylesheet/nwalsh/current/epub/bin/dbtoepub || echo /bin/true)
export DB2EPUB

numprocs=`egrep -c ^cpu[0-9]+ /proc/stat || :`
if [ "$numprocs" = "0" ]; then
  numprocs=1
fi

# get the name of the prefered fop processor
if  test -z "$FOP"; then
  FOP=$(type -p xep fop | head -n1)
  export FOP=${FOP##*/}
  echo "Found FO processor: $FOP"
fi
if test "z$FOP" = "zxep"; then
  export FOP=/usr/bin/suse-xep
  echo "Using $FOP for PDF creation."
fi
if test "z$FOP" = "zfop"; then
  export FOP=/usr/bin/suse-fop
  echo "Using $FOP for PDF creation."
fi
if test -z "$FOP"; then
  echo "No fop processor found. You will not be able to create PDF documents."
fi

aspellsgmlskip="--add-sgml-skip=quote \
                --add-sgml-skip=filename \
                --add-sgml-skip=option \
                --add-sgml-skip=literal \
                --add-sgml-skip=systemitem \
                --add-sgml-skip=screen \
		--add-sgml-skip=remark \
		--add-sgml-skip=author \
		--add-sgml-skip=firstname \
		--add-sgml-skip=surname \
                --add-sgml-skip=command \
                --add-sgml-skip=guimenu \
                --add-sgml-skip=keycap \
                --add-sgml-skip=xref \
                --add-sgml-skip=ulink \
                --add-sgml-skip=option \
                --add-sgml-skip=varname \
                --add-sgml-skip=envar \
                --add-sgml-skip=email"

alias make="make -j$numprocs"
alias spell='/usr/bin/aspell --mode=sgml $aspellsgmlskip --encoding=utf-8 --lang=en_US --extra-dicts="$DTDROOT/aspell/suse_aspell.rws" -c'

aspelllist ()
{
	/usr/bin/aspell --mode=sgml $aspellsgmlskip --encoding=utf-8 --lang=en_US \
	--extra-dicts="$DTDROOT/aspell/suse_aspell.rws" list < $1 | sort | uniq 
}

if [ -f $DTDROOT/etc/dmaliases ]; then
    source $DTDROOT/etc/dmaliases
fi
