#!/bin/sh
## ----------------------------------------------------------------------
## bin/mkconversion : 
## ----------------------------------------------------------------------

## Make "debiandoc2${format}" commands from "template"

## Each selective section of "template" are marked with list of formats:
## @@@start-html-text-latex-active@@@
## ...
## @@@end-html-text-latex-active@@@

## No nesting of these pair are allowed.

## ----------------------------------------------------------------------
set -e

## ----------------------------------------------------------------------
perldir=${1}
helperdir=${2}

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

## List of "$format" and "$ext" value combination
exec << ENDOFDATA
text            txt
wiki            wiki
textov          tov
html            html
info            info
texinfo         texinfo
latex           tex
latexdvi        dvi
latexps         ps
latexpdf        pdf
dbk	        dbk
ENDOFDATA

## "$format" dvi, ps, pdf will be generated by the symlink

## ----------------------------------------------------------------------
while read format ext
do
    if [ "${format}" = "" ]; then continue; fi

    sed -e "
	s:@@@perldir@@@:${perldir}:g;
	s:@@@helperdir@@@:${helperdir}:g;
	s:@@@format@@@:${format}:g;
	s:@@@ext@@@:${ext}:g;
	s:^@@@start.*-${format}-.*active@@@:@@@lineelide@@@:g;
	s:^@@@end.*-${format}-.*active@@@:@@@lineelide@@@:g;
	s:^@@@start.*active@@@:@@@startelide@@@:g;
	s:^@@@end.*active@@@:@@@endelide@@@:g;
	/@@@lineelide@@@/d;
	/@@@startelide@@@/,/@@@endelide@@@/d;
    " <template >debiandoc2${format}

done

