lib/Tools/document
changeset 48616 be8002ee43d8
parent 32390 468eff174a77
child 48637 547b075669ae
equal deleted inserted replaced
48615:d5c9917ff5b6 48616:be8002ee43d8
    83     fail "Bad output format '$OUTFORMAT'"
    83     fail "Bad output format '$OUTFORMAT'"
    84     ;;
    84     ;;
    85 esac
    85 esac
    86 
    86 
    87 
    87 
    88 # tagged region markup
    88 # document variants
       
    89 
       
    90 ROOT_NAME="root_$NAME"
       
    91 [ ! -f "$DIR/$ROOT_NAME.tex" ] && ROOT_NAME="root"
    89 
    92 
    90 function prep_tags ()
    93 function prep_tags ()
    91 {
    94 {
    92   (
    95   (
    93     for TAG in "${TAGS[@]}"
    96     for TAG in "${TAGS[@]}"
   115 
   118 
   116 function pre_latex ()
   119 function pre_latex ()
   117 {
   120 {
   118   local FMT="$1"
   121   local FMT="$1"
   119   [ -n "$CLEAN" ] && rm -f *.aux *.out *.ind *.idx *.ilg *.bbl *.blg *.log
   122   [ -n "$CLEAN" ] && rm -f *.aux *.out *.ind *.idx *.ilg *.bbl *.blg *.log
   120   "$ISABELLE_TOOL" latex -o sty && \
   123   "$ISABELLE_TOOL" latex -o sty "$ROOT_NAME.tex" && \
   121   "$ISABELLE_TOOL" latex -o "$FMT" && \
   124   "$ISABELLE_TOOL" latex -o "$FMT" "$ROOT_NAME.tex" && \
   122   { [ ! -f root.bib ] || "$ISABELLE_TOOL" latex -o bbl; } && \
   125   { [ ! -f root.bib -a ! -f "$ROOT_NAME.bib" ] || "$ISABELLE_TOOL" latex -o bbl "$ROOT_NAME.tex"; } && \
   123   { [ ! -f root.idx ] || "$ISABELLE_TOOL" latex -o idx; } && \
   126   { [ ! -f root.idx -a ! -f "$ROOT_NAME.idx" ] || "$ISABELLE_TOOL" latex -o idx "$ROOT_NAME.tex"; } && \
   124   "$ISABELLE_TOOL" latex -o "$FMT"
   127   "$ISABELLE_TOOL" latex -o "$FMT"
   125 }
   128 }
   126 
   129 
   127 (
   130 (
   128   cd "$DIR" || fail "Bad directory '$DIR'"
   131   cd "$DIR" || fail "Bad directory '$DIR'"
   134   if [ -f IsaMakefile ]; then
   137   if [ -f IsaMakefile ]; then
   135     "$ISABELLE_TOOL" make "$OUTFORMAT"
   138     "$ISABELLE_TOOL" make "$OUTFORMAT"
   136     RC="$?"
   139     RC="$?"
   137   elif [ "$OUTFORMAT" = pdf ]; then
   140   elif [ "$OUTFORMAT" = pdf ]; then
   138     pre_latex pdf && \
   141     pre_latex pdf && \
   139     "$ISABELLE_TOOL" latex -o pdf
   142     "$ISABELLE_TOOL" latex -o pdf "$ROOT_NAME.tex"
   140     RC="$?"
   143     RC="$?"
   141   else
   144   else
   142     pre_latex dvi && \
   145     pre_latex dvi && \
   143     "$ISABELLE_TOOL" latex -o "$OUTFORMAT"
   146     "$ISABELLE_TOOL" latex -o "$OUTFORMAT" "$ROOT_NAME.tex"
   144     RC="$?"
   147     RC="$?"
   145   fi
   148   fi
   146 
   149 
   147   if [ "$RC" -eq 0 -a -f "root.$OUTFORMAT" ]; then
   150   if [ "$RC" -eq 0 -a -f "$ROOT_NAME.$OUTFORMAT" ]; then
   148     cp -f "root.$OUTFORMAT" "../$NAME.$OUTFORMAT"
   151     cp -f "$ROOT_NAME.$OUTFORMAT" "../$NAME.$OUTFORMAT"
   149   fi
   152   fi
   150 
   153 
   151   exit "$RC"
   154   exit "$RC"
   152 )
   155 )
   153 RC="$?"
   156 RC="$?"