@@@start-active@@@
=========================================================================
# This is the template file to create all debiandoc2${format} files with
# execution of "mkconversions ${perldir} ${helperdir}".
#
# The lines just with @@@start-...-active@@@ are used to mark the start of
# ${format} specific section while the ones just with @@@end-...-active@@@
# are used to mark the start of it.  For example, this text here will not
# be included in any command since it lacks ${format} at all.  No nesting
# are allowed with this.
#
# There will be few automatic text substitutions performed:
#  EXpressions used                  => typical results
#  s:@@@perldir@@@:${perldir}:g;     => /usr/share/perl5/DebianDoc_SGML/Format/
#  s:@@@helperdir@@@:${helperdir}:g; => /usr/share/debiandoc-sgml
#  s:@@@format@@@:${format}:g;       => tail end of the command name
#  s:@@@ext@@@:${ext}:g;             => ${format} dependent file extension
#
# Some format calls other debiandoc2* script:
#  latexdvi, latexps, latexpdf ==(calls)==> latex
#  info, docbookxml            ==(calls)==> texinfo
#
# If you are confused, do "make diff" and see the difference from 
# installed version of debiandoc2* commands.
=========================================================================
@@@end-active@@@
@@@start-active@@@
=========================================================================
# This section is common start section.
=========================================================================
@@@end-active@@@
#!/bin/bash
## ----------------------------------------------------------------------

## ----------------------------------------------------------------------
## exit on erroneous subcommand
set -e

## ----------------------------------------------------------------------
## get script name
script=$(basename ${0})

## ----------------------------------------------------------------------
## print version and usage message
function usage_message
{
    cat >&2 <<'END'
debiandoc2@@@format@@@ version 1.1

Copyright (C) 1998-2004 Ardo van Rangelrooij
Copyright (C) 1996 Ian Jackson

This is free software; see the GNU General Public Licence
version 2 or later for copying conditions.  There is NO warranty.

usage: debiandoc2@@@format@@@ [options] <filename>.sgml
options: -h               print this help message
@@@start-html-active@@@
         -L               add <link> tags
@@@end-html-active@@@
@@@start-latex-texinfo-text-textov-latexdvi-latexps-latexpdf-active@@@
         -O               send output to stdout instead of <filename>.@@@ext@@@
@@@end-latex-texinfo-text-textov-latexdvi-latexps-latexpdf-active@@@
         -b <basename>    basename to be used
         -c               use content-negotiation
	 -d <declaration> SGML declaration to be used
         -e <extension>   extension to be used
         -k               keep intermediate files
         -l <locale>      locale to be used
@@@start-latexdvi-latexps-latexpdf-active@@@
         -s <script>      apply script on latex generated file
@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-info-docbookxml-active@@@
         -s <script>      apply script on texinfo generated file
@@@end-info-docbookxml-active@@@
@@@start-html-text-textov-active@@@
	 -m               put comments in output
@@@end-html-text-textov-active@@@
         -n <options>     nsgmls options to be passed on
@@@start-html-active@@@
         -t <topname>     topname to be used
         -1               generate one page
@@@end-html-active@@@
@@@start--latexps-active@@@
         -1               1 page per page (deprecated, default)
@@@end-latexps-active@@@
@@@start-latexdvi-latexps-latexpdf-active@@@
         -p <papersize>   paper size to be used
@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
         -v               be verbose
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
END
    exit 0;
}

## ----------------------------------------------------------------------
## print error message
function usage_error
{
    echo >&2 "${script}: ${@}";
    exit 2;
}

@@@start-info-docbookxml-active@@@
## ----------------------------------------------------------------------
## check for presence of makeinfo
if ! which makeinfo >/dev/null 2>&1
then
    echo >&2 "${script}: Texinfo documentation system not found"
    echo >&2 "${script}: please install the package 'texinfo'"
    exit 2
fi

@@@end-info-docbookxml-active@@@
@@@start-latexdvi-latexps-active@@@
## ----------------------------------------------------------------------
## check for presence of latex
if ! which latex >/dev/null 2>&1
then
    echo >&2 "${script}: LaTeX typesetting system not found"
    echo >&2 "${script}: please install the package 'tetex-bin'"
    exit 2
fi

@@@end-latexdvi-latexps-active@@@
@@@start-latexpdf-active@@@
## ----------------------------------------------------------------------
## check for presence of pdflatex
if ! which pdflatex >/dev/null 2>&1
then
    echo >&2 "${script}: LaTeX typesetting system not found"
    echo >&2 "${script}: please install the package 'tetex-bin'"
    exit 2
fi

@@@end-latexpdf-active@@@
@@@start-latexdvi-latexps-latexpdf-active@@@
## ----------------------------------------------------------------------
## check for presence of used latex styles
if ! kpsewhich \
    fancyhdr.sty \
    footmisc.sty \
    helvet.sty \
    hyperref.sty \
    paralist.sty \
    palatino.sty \
    pifont.sty \
    times.sty \
    url.sty \
    vmargin.sty \
    wasysym.sty \
    >/dev/null 2>&1
then
    echo >&2 "${script}: one or more used LaTeX typesetting styles not found"
    echo >&2 "${script}: please install the package 'tetex-extra'"
    exit 2
fi

@@@end-latexdvi-latexps-latexpdf-active@@@
## ----------------------------------------------------------------------
## set default values
basename=''
@@@start-html-text-textov-active@@@
comment=''
@@@end-html-text-textov-active@@@
content=''
@@@start-latexdvi-latexps-latexpdf-active@@@
postprocessing='@@@helperdir@@@/fixlatex'
@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-info-docbookxml-active@@@
postprocessing=''
@@@end-info-docbookxml-active@@@
declaration=''
extension=''
keep=false
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
keepopt=''
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
@@@start-html-active@@@
links=''
@@@end-html-active@@@
locale=''
nsgmls=''
@@@start-latexps-active@@@
paperopt=''
@@@end-latexps-active@@@
stdout=false
@@@start-html-active@@@
topname=''
@@@end-html-active@@@
@@@start-html-active@@@
single=''
@@@end-html-active@@@
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
verbose=false
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@

## ----------------------------------------------------------------------
## get command line options
options=':'
options="${options}h"
@@@start-html-active@@@
options="${options}L"
@@@end-html-active@@@
@@@start-latex-texinfo-text-textov-latexdvi-latexps-latexpdf-active@@@
options="${options}O"
@@@end-latex-texinfo-text-textov-latexdvi-latexps-latexpdf-active@@@
options="${options}b:"
options="${options}c"
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
options="${options}s:"
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
options="${options}d:"
options="${options}e:"
options="${options}k"
options="${options}l:"
@@@start-html-text-textov-active@@@
options="${options}m"
@@@end-html-text-textov-active@@@
options="${options}n:"
@@@start-html-active@@@
options="${options}t:"
options="${options}1"
@@@end-html-active@@@
@@@start-latexps-active@@@
options="${options}1"
@@@end-latexps-active@@@
@@@start-latexdvi-latexps-latexpdf-active@@@
options="${options}p:"
@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
options="${options}v"
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
while getopts ${options} opt
do
    case ${opt}
    in
	h  ) usage_message
	     ;;
@@@start-html-active@@@
	L  ) links="-${opt}"
	     ;;
@@@end-html-active@@@
@@@start-latex-texinfo-text-textov-latexdvi-latexps-latexpdf-active@@@
	O  ) stdout=true
	     ;;
@@@end-latex-texinfo-text-textov-latexdvi-latexps-latexpdf-active@@@
	b  ) basename="-${opt} ${OPTARG}"
	     ;;
	c  ) content="-${opt}"
	     ;;
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
	s  ) postprocessing="${OPTARG}"
	     ;;
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
	d  ) declaration="-${opt} ${OPTARG}"
	     ;;
	e  ) extension="-${opt} ${OPTARG}"
	     ;;
	k  ) keep=true
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
	     keepopt="-${opt}"
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
	     ;;
	l  ) locale="-${opt} ${OPTARG}"
	     ;;
@@@start-html-text-textov-active@@@
	m  ) comment="-${opt}"
	     ;;
@@@end-html-text-textov-active@@@
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
	n  ) nsgmls="-${opt} ${OPTARG} ${nsgmls}"
	     ;;
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
@@@start-html-texinfo-latex-text-textov-active@@@
	n  ) nsgmls="${nsgmls} ${OPTARG}"
	     ;;
@@@end-html-texinfo-latex-text-textov-active@@@
@@@start-html-active@@@
	t  ) topname="-${opt} ${OPTARG}"
	     ;;
	1  ) single="-${opt}"
	     ;;
@@@end-html-active@@@
@@@start-latexdvi-latexpdf-active@@@
	p  ) PAPERSIZE=${OPTARG}
	     export PAPERSIZE
	     ;;
@@@end-latexdvi-latexpdf-active@@@
@@@start-latexps-active@@@
	p  ) PAPERSIZE=${OPTARG}
	     export PAPERSIZE
	     paperopt="-t ${PAPERSIZE}"
	     ;;
	1  ) echo >&2 "${script}: the -1 option is deprecated and may be removed in the future. It is activated by default now."
	     ;;
@@@end-latexps-active@@@
@@@start-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
	v  ) verbose=true
	     ;;
@@@end-info-docbookxml-latexdvi-latexps-latexpdf-active@@@
	\? ) usage_error "unknown option \`${OPTARG}'"
	     ;;
    esac
done
shift $((${OPTIND} - 1))

## ----------------------------------------------------------------------
## check remaining command line options
if [ ${#} -ne 1 ]
then
    usage_error "need exactly one input filename"
fi

@@@start-active@@@
# Next section for basename needs review and merge with other portion
# For now I just copy old ones for each format
@@@end-active@@@
@@@start-html-active@@@
## ----------------------------------------------------------------------
## get input file name
case "${1}"
in
    -   ) nsgmlsi="-"
	  if ${keep}
	  then
	      usage_error "-k not possible with input from stdin"
	  fi
	  if ! ${stdout}
	  then
	      usage_error "stdin not allowed with debiandoc2html"
	  fi
	  ;;
    -?* ) nsgmlsi="./${1}"
	  ;;
    *   ) nsgmlsi="${1}"
	  ;;
esac

## ----------------------------------------------------------------------
## get basename
if [ -n "${basename}" ]
then
    bsn="$(echo ${basename} | cut -d' ' -f2- | cut -d'/' -f-1)"
else
    if [ "${nsgmlsi}" != "-" ]
    then
	bsn="$(basename ${1} .sgml)"
	basename="-b ${bsn}"
    fi
fi
case "${bsn}"
in
    -* ) bsn="./${bsn}" 
	 ;;
esac

## ----------------------------------------------------------------------
## get content-negotiation
cnt=''
if [ -n "${content}" ]
then
    if [ -n "${locale}" ]
    then
	cnt="$(echo ${locale} | cut -d' ' -f2-)"
    else
	cnt='en'
    fi
    cnt=".${cnt}"
fi

## ----------------------------------------------------------------------
## get extension
if [ -n "${extension}" ]
then
    ext="$(echo ${extension} | cut -d' ' -f2-)"
else
    ext='@@@ext@@@'
    extension="-e ${ext}"
fi
ext=".${ext}"

@@@end-html-active@@@
@@@start-info-active@@@
## ----------------------------------------------------------------------
## get basename
if [ -n "${basename}" ]
then
    bsn="$(echo ${basename} | cut -d' ' -f2- | cut -d'/' -f-1)"
else
    bsn="$(basename ${1} .sgml)"
fi
case "${bsn}"
in
    -* ) bsn="./${bsn}"
	 ;;
esac

## ----------------------------------------------------------------------
## get content-negotiation
cnt=''
if [ -n "${content}" ]
then
    if [ -n "${locale}" ]
    then
	cnt="$(echo ${locale} | cut -d' ' -f2-)"
    else
	cnt='en'
    fi
    cnt=".${cnt}"
fi

## ----------------------------------------------------------------------
## get extension
if [ -n "${extension}" ]
then
    ext="$(echo ${extension} | cut -d' ' -f2-)"
else
    ext='@@@ext@@@'
fi
ext=".${ext}"

@@@end-info-active@@@
@@@start-latex-docbookxml-texinfo-text-textov-active@@@
## ----------------------------------------------------------------------
## get input file name
case "${1}"
in
    -   ) nsgmlsi="-"
	  if ${keep}
	  then
	      usage_error "-k not possible with input from stdin"
	  fi
	  stdout=true
	  ;;
    -?* ) nsgmlsi="./${1}"
	  ;;
    *   ) nsgmlsi="${1}"
	  ;;
esac

## ----------------------------------------------------------------------
## get basename
if [ -n "${basename}" ]
then
    bsn="$(echo ${basename} | cut -d' ' -f2- | cut -d'/' -f-1)"
else
    if [ "${nsgmlsi}" != "-" ]
    then
	bsn="$(basename ${1} .sgml)"
	basename="-b ${bsn}"
    fi
fi
case "${bsn}"
in
    -* ) bsn="./${bsn}" 
	 ;;
esac

## ----------------------------------------------------------------------
## get content-negotiation
cnt=''
if [ -n "${content}" ]
then
    if [ -n "${locale}" ]
    then
	cnt="$(echo ${locale} | cut -d' ' -f2-)"
    else
	cnt='en'
    fi
    cnt=".${cnt}"
fi

## ----------------------------------------------------------------------
## get extension
if [ -n "${extension}" ]
then
    ext="$(echo ${extension} | cut -d' ' -f2-)"
else
    ext='@@@ext@@@'
    extension="-e ${ext}"
fi
ext=".${ext}"

@@@end-latex-texinfo-docbookxml-text-textov-active@@@
@@@start-latexdvi-latexps-latexpdf-active@@@
## ----------------------------------------------------------------------
## get basename
if [ -n "${basename}" ]
then
    bsn="$(echo ${basename} | cut -d' ' -f2- | cut -d'/' -f-1)"
else
    bsn="$(basename ${1} .sgml)"
fi
case "${bsn}"
in
    -* ) bsn="./${bsn}"
	 ;;
esac

## ----------------------------------------------------------------------
## get content-negotiation
cnt=''
if [ -n "${content}" ]
then
    if [ -n "${locale}" ]
    then
	cnt="$(echo ${locale} | cut -d' ' -f2-)"
    else
	cnt='en'
    fi
    cnt=".${cnt}"
fi

## ----------------------------------------------------------------------
## get extension
if [ -n "${extension}" ]
then
    ext="$(echo ${extension} | cut -d' ' -f2-)"
else
    ext='@@@ext@@@'
fi
ext=".${ext}"

@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-html-text-textov-latex-texinfo-active@@@
## ----------------------------------------------------------------------
## get declaration
if [ -n "${declaration}" ]
then
    declaration="$(echo ${declaration} | cut -d' ' -f2-)"
    if [ "$(basename ${declaration})" = "${declaration}" ]
    then
	declaration="declaration/${declaration}"
    fi
fi

@@@end-html-text-textov-latex-texinfo-active@@@
@@@start-html-text-textov-latex-texinfo-active@@@
## ----------------------------------------------------------------------
## construct temporary file names
tf1="${bsn}.sasp"
tf2="${bsn}.sasp-@@@format@@@"

@@@end-html-text-textov-latex-texinfo-active@@@
## ----------------------------------------------------------------------
## what needs to be passed on to the backend
passing_on=''
passing_on="${passing_on} ${basename}"
@@@start-info-latexdvi-latexps-latexpdf-active@@@
passing_on="${passing_on} ${declaration}"
passing_on="${passing_on} ${keepopt}"
passing_on="${passing_on} ${locale}"
passing_on="${passing_on} ${nsgmls}"
@@@end-info-latexdvi-latexps-latexpdf-active@@@
@@@start-html-text-textov-active@@@
passing_on="${passing_on} ${comment}"
@@@end-html-text-textov-active@@@
@@@start-html-text-textov-latex-texinfo-active@@@
passing_on="${passing_on} ${content}"
passing_on="${passing_on} ${extension}"
@@@end-html-text-textov-latex-texinfo-active@@@
@@@start-html-active@@@
passing_on="${passing_on} ${links}"
@@@end-html-active@@@
@@@start-html-text-textov-latex-texinfo-active@@@
passing_on="${passing_on} ${locale}"
@@@end-html-text-textov-latex-texinfo-active@@@
@@@start-html-active@@@
passing_on="${passing_on} ${topname}"
passing_on="${passing_on} ${single}"
@@@end-html-active@@@

@@@start-active@@@
=========================================================================
# This section is for html, text, textov, latex, and texinfo.
=========================================================================
@@@end-active@@@
@@@start-html-text-textov-latex-texinfo-active@@@
## ----------------------------------------------------------------------
## do the actual work
nsgmls -oline ${nsgmls} ${declaration} ${nsgmlsi} >${tf1}
@@@helperdir@@@/saspconvert <${tf1} >${tf2}
@@@end-html-text-textov-latex-texinfo-active@@@
@@@start-latex-texinfo-text-textov-active@@@
if ! ${stdout}
then
    exec >${bsn}${cnt}${ext}
fi
@@@end-latex-texinfo-text-textov-active@@@
@@@start-html-text-textov-latex-texinfo-active@@@
sgmlspl @@@perldir@@@/Driver.pm -f @@@format@@@ ${passing_on} <${tf2}

## ----------------------------------------------------------------------
## remove temporary files
if ! ${keep}
then
    rm -f ${tf1} ${tf2}
fi

@@@end-html-text-textov-latex-texinfo-active@@@
@@@start-active@@@
=========================================================================
# This second section is for latexdvi, latexps, and latexpdf.
=========================================================================
@@@end-active@@@
@@@start-latexdvi-latexps-latexpdf-active@@@
## ----------------------------------------------------------------------
## do the actual work
if [ -e ${bsn}.tex ]
then
    echo >&2 "${script}: WARNING: overwriting ${bsn}.tex"
fi
if ! debiandoc2latex ${passing_on} ${1}
then
    echo >&2 "${script}: ERROR: ${bsn}.tex could not be generated properly"
    exit 1
fi
if [ -n "${postprocessing}" ]
then
    mv ${bsn}.tex ${bsn}.tex-in
    "${postprocessing}" ${locale} ${bsn}.tex-in ${bsn}.tex
fi
@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-latexdvi-latexps-active@@@
if [ -e ${bsn}.dvi ] && ( [ -n "${content}" ] || [ -n "${extension}" ] )
then
    echo >&2 "${script}: WARNING: overwriting ${bsn}.dvi"
fi
@@@end-latexdvi-latexps-active@@@
@@@start-latexpdf-active@@@
if [ -e ${bsn}.pdf ] && ( [ -n "${content}" ] || [ -n "${extension}" ] )
then
    echo >&2 "${script}: WARNING: overwriting ${bsn}.pdf"
fi
@@@end-latexpdf-active@@@
@@@start-latexdvi-latexps-latexpdf-active@@@
touch prior.aux pprior.aux
MAX_LEVEL=9
LEVEL=1
while [ ${LEVEL} -lt ${MAX_LEVEL} ]
do
    if ! ( ${verbose} || exec >/dev/null;
@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-latexdvi-latexps-active@@@
	   latex -interaction=nonstopmode ${bsn}.tex )
    then
        echo >&2 "${script}: ERROR: ${bsn}.dvi could not be generated properly"
@@@end-latexdvi-latexps-active@@@
@@@start-latexpdf-active@@@
	   pdflatex -interaction=nonstopmode ${bsn}.tex )
    then
        echo >&2 "${script}: ERROR: ${bsn}.pdf could not be generated properly"
@@@end-latexpdf-active@@@
@@@start-latexdvi-latexps-latexpdf-active@@@
        if ! ${verbose}
        then
	    echo >&2 "${script}: rerun with the -v option to found out why"
	    echo >&2 "${script}: or check the log file ${bsn}.log"
        fi
	rm -f prior.aux pprior.aux
        exit 1
    fi
    if    ( ! cmp ${bsn}.aux prior.aux >/dev/null 2>&1 ) \
       && ( ! cmp ${bsn}.aux pprior.aux >/dev/null 2>&1 )
    then
        cp -pf prior.aux pprior.aux
	cp -pf ${bsn}.aux prior.aux
	let LEVEL=LEVEL+1
    else
        let LEVEL=MAX_LEVEL+1
    fi
done
rm -f prior.aux pprior.aux
if [ ${LEVEL} -eq ${MAX_LEVEL} ]
then
    echo >&2 "${script}: ERROR: reached maximum rebuilding level (= ${MAX_LEVEL})"
    if ! ${verbose}
    then
	echo >&2 "${script}: rerun with the -v option to found out why"
	echo >&2 "${script}: or check the log file ${bsn}.log"
    fi
    exit 1
fi
@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-latexps-active@@@
if ! ( ${verbose} || exec >/dev/null 2>&1;
       dvips ${paperopt} -o ${bsn}.@@@ext@@@ ${bsn} )
then
    echo -n >&2 "${script}: ERROR: "
    if ${stdout}
    then
	echo -n >&2 "output"
    else
	echo -n >&2 "${bsn}${cnt}${ext}"
    fi
    echo >&2 " could not be generated properly"
    if ! ${verbose}
    then
	echo >&2 "${script}: rerun with the -v option to found out why"
    fi
    exit 1
fi
@@@end-latexps-active@@@
@@@start-latexpdf-active@@@
if ! ( ${verbose} || exec >/dev/null; thumbpdf ${bsn}.pdf )
then
    echo >&2 "${script}: ERROR: thumbnail images could not be generated properly"
    if ! ${verbose}
    then
	echo >&2 "${script}: rerun with the -v option to found out why"
	echo >&2 "${script}: or check the log file ${bsn}.log"
    fi
fi
@@@end-latexpdf-active@@@
@@@start-latexdvi-latexps-latexpdf-active@@@
if ${stdout}
then
    cat ${bsn}.@@@ext@@@
    if ! ${keep}
    then
	rm -f ${bsn}.@@@ext@@@
    fi
else
    if [ -n "${content}" ] || [ -n "${extension}" ]
    then
	mv -f ${bsn}.@@@ext@@@ ${bsn}${cnt}${ext}
    fi
fi

@@@end-latexdvi-latexps-latexpdf-active@@@
@@@start-latexps-active@@@
## ----------------------------------------------------------------------
## remove temporary files
if ! ${keep}
then
    rm -f ${bsn}.dvi ${bsn}.tex ${bsn}.aux ${bsn}.log ${bsn}.toc ${bsn}.tex-in
fi

@@@end-latexps-active@@@
@@@start-latexpdf-active@@@
## ----------------------------------------------------------------------
## remove temporary files
if ! ${keep}
then
    rm -f ${bsn}.tex ${bsn}.aux ${bsn}.log ${bsn}.out ${bsn}.toc ${bsn}.tex-in
fi

@@@end-latexpdf-active@@@
@@@start-latexdvi-active@@@
## ----------------------------------------------------------------------
## remove temporary files
if ! ${keep}
then
    rm -f ${bsn}.tex ${bsn}.aux ${bsn}.log ${bsn}.toc ${bsn}.tex-in
fi

@@@end-latexdvi-active@@@
@@@start-active@@@
=========================================================================
# This third section is for info, and docbookxml.
=========================================================================
@@@end-active@@@
@@@start-info-docbookxml-active@@@
## ----------------------------------------------------------------------
## do the actual work
if [ -e ${bsn}.texinfo ]
then
    echo >&2 "${script}: WARNING: overwriting ${bsn}.texinfo"
fi
if ! debiandoc2texinfo ${passing_on} ${1}
then
    echo >&2 "${script}: ERROR: ${bsn}.texinfo could not be generated properly"
    exit 1
fi
if [ -n "${postprocessing}" ]
then
    mv ${bsn}.texinfo ${bsn}.texinfo-in
    "${postprocessing}" ${locale} ${bsn}.texinfo-in ${bsn}.texinfo
fi
if ! ( ${verbose} || exec >/dev/null 2>&1;
@@@end-info-docbookxml-active@@@
@@@start-info-active@@@
       makeinfo --no-validate -v -o ${bsn}${cnt}${ext} ${bsn}.texinfo )
@@@end-info-active@@@
@@@start-docbookxml-active@@@
       makeinfo --no-validate --docbook -v -o ${bsn}${cnt}${ext} ${bsn}.texinfo )
@@@end-docbookxml-active@@@
@@@start-info-docbookxml-active@@@
then
    echo >&2 "${script}: ERROR: ${bsn}${cnt}${ext} could not be generated properly"
    if ! ${verbose}
    then
	echo >&2 "${script}: rerun with the -v option to found out why"
    fi
    exit 1
fi

## ----------------------------------------------------------------------
## remove temporary files
if ! ${keep}
then
    rm -f ${bsn}.texinfo-in ${bsn}.texinfo
fi

@@@end-info-docbookxml-active@@@
@@@start-active@@@
=========================================================================
# This section is common end section.
=========================================================================
@@@end-active@@@
## ----------------------------------------------------------------------
exit 0

## ----------------------------------------------------------------------
