Blame build-aux/gendocs.sh

Packit aea12f
#!/bin/sh -e
Packit aea12f
# gendocs.sh -- generate a GNU manual in many formats.  This script is
Packit aea12f
#   mentioned in maintain.texi.  See the help message below for usage details.
Packit aea12f
Packit Service 991b93
scriptversion=2020-01-01.00
Packit aea12f
Packit Service 991b93
# Copyright 2003-2020 Free Software Foundation, Inc.
Packit aea12f
#
Packit aea12f
# This program is free software: you can redistribute it and/or modify
Packit aea12f
# it under the terms of the GNU General Public License as published by
Packit aea12f
# the Free Software Foundation; either version 3 of the License, or
Packit aea12f
# (at your option) any later version.
Packit aea12f
#
Packit aea12f
# This program is distributed in the hope that it will be useful,
Packit aea12f
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit aea12f
# GNU General Public License for more details.
Packit aea12f
#
Packit aea12f
# You should have received a copy of the GNU General Public License
Packit aea12f
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
Packit aea12f
#
Packit aea12f
# Original author: Mohit Agarwal.
Packit aea12f
# Send bug reports and any other correspondence to bug-gnulib@gnu.org.
Packit aea12f
#
Packit aea12f
# The latest version of this script, and the companion template, is
Packit aea12f
# available from the Gnulib repository:
Packit aea12f
#
Packit aea12f
# https://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/gendocs.sh
Packit aea12f
# https://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/gendocs_template
Packit aea12f
Packit aea12f
# TODO:
Packit aea12f
# - image importing was only implemented for HTML generated by
Packit aea12f
#   makeinfo.  But it should be simple enough to adjust.
Packit aea12f
# - images are not imported in the source tarball.  All the needed
Packit aea12f
#   formats (PDF, PNG, etc.) should be included.
Packit aea12f
Packit aea12f
prog=`basename "$0"`
Packit aea12f
srcdir=`pwd`
Packit aea12f
Packit aea12f
scripturl="https://git.savannah.gnu.org/cgit/gnulib.git/plain/build-aux/gendocs.sh"
Packit aea12f
templateurl="https://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/gendocs_template"
Packit aea12f
Packit aea12f
: ${SETLANG="env LANG= LC_MESSAGES= LC_ALL= LANGUAGE="}
Packit aea12f
: ${MAKEINFO="makeinfo"}
Packit aea12f
: ${TEXI2DVI="texi2dvi"}
Packit aea12f
: ${DOCBOOK2HTML="docbook2html"}
Packit aea12f
: ${DOCBOOK2PDF="docbook2pdf"}
Packit aea12f
: ${DOCBOOK2TXT="docbook2txt"}
Packit aea12f
: ${GENDOCS_TEMPLATE_DIR="."}
Packit aea12f
: ${PERL='perl'}
Packit aea12f
: ${TEXI2HTML="texi2html"}
Packit aea12f
unset CDPATH
Packit aea12f
unset use_texi2html
Packit aea12f
Packit aea12f
MANUAL_TITLE=
Packit aea12f
PACKAGE=
Packit aea12f
EMAIL=webmasters@gnu.org  # please override with --email
Packit aea12f
commonarg= # passed to all makeinfo/texi2html invcations.
Packit aea12f
dirargs=   # passed to all tools (-I dir).
Packit aea12f
dirs=      # -I directories.
Packit aea12f
htmlarg="--css-ref=/software/gnulib/manual.css -c TOP_NODE_UP_URL=/manual"
Packit aea12f
default_htmlarg=true
Packit aea12f
infoarg=--no-split
Packit aea12f
generate_ascii=true
Packit aea12f
generate_html=true
Packit aea12f
generate_info=true
Packit aea12f
generate_tex=true
Packit aea12f
outdir=manual
Packit aea12f
source_extra=
Packit aea12f
split=node
Packit aea12f
srcfile=
Packit aea12f
texarg="-t @finalout"
Packit aea12f
Packit aea12f
version="gendocs.sh $scriptversion
Packit aea12f
Packit Service 991b93
Copyright 2020 Free Software Foundation, Inc.
Packit aea12f
There is NO warranty.  You may redistribute this software
Packit aea12f
under the terms of the GNU General Public License.
Packit aea12f
For more information about these matters, see the files named COPYING."
Packit aea12f
Packit aea12f
usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE
Packit aea12f
Packit aea12f
Generate output in various formats from PACKAGE.texinfo (or .texi or
Packit aea12f
.txi) source.  See the GNU Maintainers document for a more extensive
Packit aea12f
discussion:
Packit aea12f
  https://www.gnu.org/prep/maintain_toc.html
Packit aea12f
Packit aea12f
Options:
Packit aea12f
  --email ADR use ADR as contact in generated web pages; always give this.
Packit aea12f
Packit aea12f
  -s SRCFILE   read Texinfo from SRCFILE, instead of PACKAGE.{texinfo|texi|txi}
Packit aea12f
  -o OUTDIR    write files into OUTDIR, instead of manual/.
Packit aea12f
  -I DIR       append DIR to the Texinfo search path.
Packit aea12f
  --common ARG pass ARG in all invocations.
Packit aea12f
  --html ARG   pass ARG to makeinfo or texi2html for HTML targets,
Packit aea12f
                 instead of '$htmlarg'.
Packit aea12f
  --info ARG   pass ARG to makeinfo for Info, instead of --no-split.
Packit aea12f
  --no-ascii   skip generating the plain text output.
Packit aea12f
  --no-html    skip generating the html output.
Packit aea12f
  --no-info    skip generating the info output.
Packit aea12f
  --no-tex     skip generating the dvi and pdf output.
Packit aea12f
  --source ARG include ARG in tar archive of sources.
Packit aea12f
  --split HOW  make split HTML by node, section, chapter; default node.
Packit aea12f
  --tex ARG    pass ARG to texi2dvi for DVI and PDF, instead of -t @finalout.
Packit aea12f
Packit aea12f
  --texi2html  use texi2html to make HTML target, with all split versions.
Packit aea12f
  --docbook    convert through DocBook too (xml, txt, html, pdf).
Packit aea12f
Packit aea12f
  --help       display this help and exit successfully.
Packit aea12f
  --version    display version information and exit successfully.
Packit aea12f
Packit aea12f
Simple example: $prog --email bug-gnu-emacs@gnu.org emacs \"GNU Emacs Manual\"
Packit aea12f
Packit aea12f
Typical sequence:
Packit aea12f
  cd PACKAGESOURCE/doc
Packit aea12f
  wget \"$scripturl\"
Packit aea12f
  wget \"$templateurl\"
Packit aea12f
  $prog --email BUGLIST MANUAL \"GNU MANUAL - One-line description\"
Packit aea12f
Packit aea12f
Output will be in a new subdirectory \"manual\" (by default;
Packit aea12f
use -o OUTDIR to override).  Move all the new files into your web CVS
Packit aea12f
tree, as explained in the Web Pages node of maintain.texi.
Packit aea12f
Packit aea12f
Please use the --email ADDRESS option so your own bug-reporting
Packit aea12f
address will be used in the generated HTML pages.
Packit aea12f
Packit aea12f
MANUAL-TITLE is included as part of the HTML <title> of the overall
Packit aea12f
manual/index.html file.  It should include the name of the package being
Packit aea12f
documented.  manual/index.html is created by substitution from the file
Packit aea12f
$GENDOCS_TEMPLATE_DIR/gendocs_template.  (Feel free to modify the
Packit aea12f
generic template for your own purposes.)
Packit aea12f
Packit aea12f
If you have several manuals, you'll need to run this script several
Packit aea12f
times with different MANUAL values, specifying a different output
Packit aea12f
directory with -o each time.  Then write (by hand) an overall index.html
Packit aea12f
with links to them all.
Packit aea12f
Packit aea12f
If a manual's Texinfo sources are spread across several directories,
Packit aea12f
first copy or symlink all Texinfo sources into a single directory.
Packit aea12f
(Part of the script's work is to make a tar.gz of the sources.)
Packit aea12f
Packit aea12f
As implied above, by default monolithic Info files are generated.
Packit aea12f
If you want split Info, or other Info options, use --info to override.
Packit aea12f
Packit aea12f
You can set the environment variables MAKEINFO, TEXI2DVI, TEXI2HTML,
Packit aea12f
and PERL to control the programs that get executed, and
Packit aea12f
GENDOCS_TEMPLATE_DIR to control where the gendocs_template file is
Packit aea12f
looked for.  With --docbook, the environment variables DOCBOOK2HTML,
Packit aea12f
DOCBOOK2PDF, and DOCBOOK2TXT are also consulted.
Packit aea12f
Packit aea12f
By default, makeinfo and texi2dvi are run in the default (English)
Packit aea12f
locale, since that's the language of most Texinfo manuals.  If you
Packit aea12f
happen to have a non-English manual and non-English web site, see the
Packit aea12f
SETLANG setting in the source.
Packit aea12f
Packit aea12f
Email bug reports or enhancement requests to bug-gnulib@gnu.org.
Packit aea12f
"
Packit aea12f
Packit aea12f
while test $# -gt 0; do
Packit aea12f
  case $1 in
Packit aea12f
    -s)          shift; srcfile=$1;;
Packit aea12f
    -o)          shift; outdir=$1;;
Packit aea12f
    -I)          shift; dirargs="$dirargs -I '$1'"; dirs="$dirs $1";;
Packit aea12f
    --common)    shift; commonarg=$1;;
Packit aea12f
    --docbook)   docbook=yes;;
Packit aea12f
    --email)     shift; EMAIL=$1;;
Packit aea12f
    --html)      shift; default_htmlarg=false; htmlarg=$1;;
Packit aea12f
    --info)      shift; infoarg=$1;;
Packit aea12f
    --no-ascii)  generate_ascii=false;;
Packit aea12f
    --no-html)   generate_ascii=false;;
Packit aea12f
    --no-info)   generate_info=false;;
Packit aea12f
    --no-tex)    generate_tex=false;;
Packit aea12f
    --source)    shift; source_extra=$1;;
Packit aea12f
    --split)     shift; split=$1;;
Packit aea12f
    --tex)       shift; texarg=$1;;
Packit aea12f
    --texi2html) use_texi2html=1;;
Packit aea12f
Packit aea12f
    --help)      echo "$usage"; exit 0;;
Packit aea12f
    --version)   echo "$version"; exit 0;;
Packit aea12f
    -*)
Packit aea12f
      echo "$0: Unknown option \`$1'." >&2
Packit aea12f
      echo "$0: Try \`--help' for more information." >&2
Packit aea12f
      exit 1;;
Packit aea12f
    *)
Packit aea12f
      if test -z "$PACKAGE"; then
Packit aea12f
        PACKAGE=$1
Packit aea12f
      elif test -z "$MANUAL_TITLE"; then
Packit aea12f
        MANUAL_TITLE=$1
Packit aea12f
      else
Packit aea12f
        echo "$0: extra non-option argument \`$1'." >&2
Packit aea12f
        exit 1
Packit aea12f
      fi;;
Packit aea12f
  esac
Packit aea12f
  shift
Packit aea12f
done
Packit aea12f
Packit aea12f
# makeinfo uses the dirargs, but texi2dvi doesn't.
Packit aea12f
commonarg=" $dirargs $commonarg"
Packit aea12f
Packit aea12f
# For most of the following, the base name is just $PACKAGE
Packit aea12f
base=$PACKAGE
Packit aea12f
Packit aea12f
if $default_htmlarg && test -n "$use_texi2html"; then
Packit aea12f
  # The legacy texi2html doesn't support TOP_NODE_UP_URL
Packit aea12f
  htmlarg="--css-ref=/software/gnulib/manual.css"
Packit aea12f
fi
Packit aea12f
Packit aea12f
if test -n "$srcfile"; then
Packit aea12f
  # but here, we use the basename of $srcfile
Packit aea12f
  base=`basename "$srcfile"`
Packit aea12f
  case $base in
Packit aea12f
    *.txi|*.texi|*.texinfo) base=`echo "$base"|sed 's/\.[texinfo]*$//'`;;
Packit aea12f
  esac
Packit aea12f
  PACKAGE=$base
Packit aea12f
elif test -s "$srcdir/$PACKAGE.texinfo"; then
Packit aea12f
  srcfile=$srcdir/$PACKAGE.texinfo
Packit aea12f
elif test -s "$srcdir/$PACKAGE.texi"; then
Packit aea12f
  srcfile=$srcdir/$PACKAGE.texi
Packit aea12f
elif test -s "$srcdir/$PACKAGE.txi"; then
Packit aea12f
  srcfile=$srcdir/$PACKAGE.txi
Packit aea12f
else
Packit aea12f
  echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2
Packit aea12f
  exit 1
Packit aea12f
fi
Packit aea12f
Packit aea12f
if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then
Packit aea12f
  echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2
Packit aea12f
  echo "$0: it is available from $templateurl." >&2
Packit aea12f
  exit 1
Packit aea12f
fi
Packit aea12f
Packit aea12f
# Function to return size of $1 in something resembling kilobytes.
Packit aea12f
calcsize()
Packit aea12f
{
Packit aea12f
  size=`ls -ksl $1 | awk '{print $1}'`
Packit aea12f
  echo $size
Packit aea12f
}
Packit aea12f
Packit aea12f
# copy_images OUTDIR HTML-FILE...
Packit aea12f
# -------------------------------
Packit aea12f
# Copy all the images needed by the HTML-FILEs into OUTDIR.
Packit aea12f
# Look for them in . and the -I directories; this is simpler than what
Packit aea12f
# makeinfo supports with -I, but hopefully it will suffice.
Packit aea12f
copy_images()
Packit aea12f
{
Packit aea12f
  local odir
Packit aea12f
  odir=$1
Packit aea12f
  shift
Packit aea12f
  $PERL -n -e "
Packit aea12f
BEGIN {
Packit aea12f
  \$me = '$prog';
Packit aea12f
  \$odir = '$odir';
Packit aea12f
  @dirs = qw(. $dirs);
Packit aea12f
}
Packit aea12f
" -e '
Packit aea12f
/
Packit aea12f
Packit aea12f
END {
Packit aea12f
  #print "$me: @{[keys %need]}\n";  # for debugging, show images found.
Packit aea12f
  FILE: for my $f (keys %need) {
Packit aea12f
    for my $d (@dirs) {
Packit aea12f
      if (-f "$d/$f") {
Packit aea12f
        use File::Basename;
Packit aea12f
        my $dest = dirname ("$odir/$f");
Packit aea12f
        #
Packit aea12f
        use File::Path;
Packit aea12f
        -d $dest || mkpath ($dest)
Packit aea12f
          || die "$me: cannot mkdir $dest: $!\n";
Packit aea12f
        #
Packit aea12f
        use File::Copy;
Packit aea12f
        copy ("$d/$f", $dest)
Packit aea12f
          || die "$me: cannot copy $d/$f to $dest: $!\n";
Packit aea12f
        next FILE;
Packit aea12f
      }
Packit aea12f
    }
Packit aea12f
    die "$me: $ARGV: cannot find image $f\n";
Packit aea12f
  }
Packit aea12f
}
Packit aea12f
' -- "$@" || exit 1
Packit aea12f
}
Packit aea12f
Packit aea12f
case $outdir in
Packit aea12f
  /*) abs_outdir=$outdir;;
Packit aea12f
  *)  abs_outdir=$srcdir/$outdir;;
Packit aea12f
esac
Packit aea12f
Packit aea12f
echo "Making output for $srcfile"
Packit aea12f
echo " in `pwd`"
Packit aea12f
mkdir -p "$outdir/"
Packit aea12f
Packit aea12f
# 
Packit aea12f
if $generate_info; then
Packit aea12f
  cmd="$SETLANG $MAKEINFO -o $PACKAGE.info $commonarg $infoarg \"$srcfile\""
Packit aea12f
  echo "Generating info... ($cmd)"
Packit aea12f
  rm -f $PACKAGE.info* # get rid of any strays
Packit aea12f
  eval "$cmd"
Packit aea12f
  tar czf "$outdir/$PACKAGE.info.tar.gz" $PACKAGE.info*
Packit aea12f
  ls -l "$outdir/$PACKAGE.info.tar.gz"
Packit aea12f
  info_tgz_size=`calcsize "$outdir/$PACKAGE.info.tar.gz"`
Packit aea12f
  # do not mv the info files, there's no point in having them available
Packit aea12f
  # separately on the web.
Packit aea12f
fi  # end info
Packit aea12f
Packit aea12f
# 
Packit aea12f
if $generate_tex; then
Packit aea12f
  cmd="$SETLANG $TEXI2DVI $dirargs $texarg \"$srcfile\""
Packit aea12f
  printf "\nGenerating dvi... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  # compress/finish dvi:
Packit aea12f
  gzip -f -9 $PACKAGE.dvi
Packit aea12f
  dvi_gz_size=`calcsize $PACKAGE.dvi.gz`
Packit aea12f
  mv $PACKAGE.dvi.gz "$outdir/"
Packit aea12f
  ls -l "$outdir/$PACKAGE.dvi.gz"
Packit aea12f
Packit aea12f
  cmd="$SETLANG $TEXI2DVI --pdf $dirargs $texarg \"$srcfile\""
Packit aea12f
  printf "\nGenerating pdf... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  pdf_size=`calcsize $PACKAGE.pdf`
Packit aea12f
  mv $PACKAGE.pdf "$outdir/"
Packit aea12f
  ls -l "$outdir/$PACKAGE.pdf"
Packit aea12f
fi # end tex (dvi + pdf)
Packit aea12f
Packit aea12f
# 
Packit aea12f
if $generate_ascii; then
Packit aea12f
  opt="-o $PACKAGE.txt --no-split --no-headers $commonarg"
Packit aea12f
  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
Packit aea12f
  printf "\nGenerating ascii... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  ascii_size=`calcsize $PACKAGE.txt`
Packit aea12f
  gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz"
Packit aea12f
  ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"`
Packit aea12f
  mv $PACKAGE.txt "$outdir/"
Packit aea12f
  ls -l "$outdir/$PACKAGE.txt" "$outdir/$PACKAGE.txt.gz"
Packit aea12f
fi
Packit aea12f
Packit aea12f
# 
Packit aea12f
Packit aea12f
if $generate_html; then
Packit aea12f
# Split HTML at level $1.  Used for texi2html.
Packit aea12f
html_split()
Packit aea12f
{
Packit aea12f
  opt="--split=$1 --node-files $commonarg $htmlarg"
Packit aea12f
  cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\""
Packit aea12f
  printf "\nGenerating html by $1... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  split_html_dir=$PACKAGE.html
Packit aea12f
  (
Packit aea12f
    cd ${split_html_dir} || exit 1
Packit aea12f
    ln -sf ${PACKAGE}.html index.html
Packit aea12f
    tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html
Packit aea12f
  )
Packit aea12f
  eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"`
Packit aea12f
  rm -f "$outdir"/html_$1/*.html
Packit aea12f
  mkdir -p "$outdir/html_$1/"
Packit aea12f
  mv ${split_html_dir}/*.html "$outdir/html_$1/"
Packit aea12f
  rmdir ${split_html_dir}
Packit aea12f
}
Packit aea12f
Packit aea12f
if test -z "$use_texi2html"; then
Packit aea12f
  opt="--no-split --html -o $PACKAGE.html $commonarg $htmlarg"
Packit aea12f
  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
Packit aea12f
  printf "\nGenerating monolithic html... ($cmd)\n"
Packit aea12f
  rm -rf $PACKAGE.html  # in case a directory is left over
Packit aea12f
  eval "$cmd"
Packit aea12f
  html_mono_size=`calcsize $PACKAGE.html`
Packit aea12f
  gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
Packit aea12f
  html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
Packit aea12f
  copy_images "$outdir/" $PACKAGE.html
Packit aea12f
  mv $PACKAGE.html "$outdir/"
Packit aea12f
  ls -l "$outdir/$PACKAGE.html" "$outdir/$PACKAGE.html.gz"
Packit aea12f
Packit aea12f
  # Before Texinfo 5.0, makeinfo did not accept a --split=HOW option,
Packit aea12f
  # it just always split by node.  So if we're splitting by node anyway,
Packit aea12f
  # leave it out.
Packit aea12f
  if test "x$split" = xnode; then
Packit aea12f
    split_arg=
Packit aea12f
  else
Packit aea12f
    split_arg=--split=$split
Packit aea12f
  fi
Packit aea12f
  #
Packit aea12f
  opt="--html -o $PACKAGE.html $split_arg $commonarg $htmlarg"
Packit aea12f
  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
Packit aea12f
  printf "\nGenerating html by $split... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  split_html_dir=$PACKAGE.html
Packit aea12f
  copy_images $split_html_dir/ $split_html_dir/*.html
Packit aea12f
  (
Packit aea12f
    cd $split_html_dir || exit 1
Packit aea12f
    tar -czf "$abs_outdir/$PACKAGE.html_$split.tar.gz" -- *
Packit aea12f
  )
Packit aea12f
  eval \
Packit aea12f
    html_${split}_tgz_size=`calcsize "$outdir/$PACKAGE.html_$split.tar.gz"`
Packit aea12f
  rm -rf "$outdir/html_$split/"
Packit aea12f
  mv $split_html_dir "$outdir/html_$split/"
Packit aea12f
  du -s "$outdir/html_$split/"
Packit aea12f
  ls -l "$outdir/$PACKAGE.html_$split.tar.gz"
Packit aea12f
Packit aea12f
else # use texi2html:
Packit aea12f
  opt="--output $PACKAGE.html $commonarg $htmlarg"
Packit aea12f
  cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\""
Packit aea12f
  printf "\nGenerating monolithic html with texi2html... ($cmd)\n"
Packit aea12f
  rm -rf $PACKAGE.html  # in case a directory is left over
Packit aea12f
  eval "$cmd"
Packit aea12f
  html_mono_size=`calcsize $PACKAGE.html`
Packit aea12f
  gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
Packit aea12f
  html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
Packit aea12f
  mv $PACKAGE.html "$outdir/"
Packit aea12f
Packit aea12f
  html_split node
Packit aea12f
  html_split chapter
Packit aea12f
  html_split section
Packit aea12f
fi
Packit aea12f
fi # end html
Packit aea12f
Packit aea12f
# 
Packit aea12f
printf "\nMaking .tar.gz for sources...\n"
Packit aea12f
d=`dirname $srcfile`
Packit aea12f
(
Packit aea12f
  cd "$d"
Packit aea12f
  srcfiles=`ls -d *.texinfo *.texi *.txi *.eps $source_extra 2>/dev/null` || true
Packit aea12f
  tar czfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles
Packit aea12f
  ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"
Packit aea12f
)
Packit aea12f
texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"`
Packit aea12f
Packit aea12f
# 
Packit aea12f
# Do everything again through docbook.
Packit aea12f
if test -n "$docbook"; then
Packit aea12f
  opt="-o - --docbook $commonarg"
Packit aea12f
  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\" >${srcdir}/$PACKAGE-db.xml"
Packit aea12f
  printf "\nGenerating docbook XML... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  docbook_xml_size=`calcsize $PACKAGE-db.xml`
Packit aea12f
  gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz"
Packit aea12f
  docbook_xml_gz_size=`calcsize "$outdir/$PACKAGE-db.xml.gz"`
Packit aea12f
  mv $PACKAGE-db.xml "$outdir/"
Packit aea12f
Packit aea12f
  split_html_db_dir=html_node_db
Packit aea12f
  opt="$commonarg -o $split_html_db_dir"
Packit aea12f
  cmd="$DOCBOOK2HTML $opt \"${outdir}/$PACKAGE-db.xml\""
Packit aea12f
  printf "\nGenerating docbook HTML... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  (
Packit aea12f
    cd ${split_html_db_dir} || exit 1
Packit aea12f
    tar -czf "$abs_outdir/${PACKAGE}.html_node_db.tar.gz" -- *.html
Packit aea12f
  )
Packit aea12f
  html_node_db_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node_db.tar.gz"`
Packit aea12f
  rm -f "$outdir"/html_node_db/*.html
Packit aea12f
  mkdir -p "$outdir/html_node_db"
Packit aea12f
  mv ${split_html_db_dir}/*.html "$outdir/html_node_db/"
Packit aea12f
  rmdir ${split_html_db_dir}
Packit aea12f
Packit aea12f
  cmd="$DOCBOOK2TXT \"${outdir}/$PACKAGE-db.xml\""
Packit aea12f
  printf "\nGenerating docbook ASCII... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  docbook_ascii_size=`calcsize $PACKAGE-db.txt`
Packit aea12f
  mv $PACKAGE-db.txt "$outdir/"
Packit aea12f
Packit aea12f
  cmd="$DOCBOOK2PDF \"${outdir}/$PACKAGE-db.xml\""
Packit aea12f
  printf "\nGenerating docbook PDF... ($cmd)\n"
Packit aea12f
  eval "$cmd"
Packit aea12f
  docbook_pdf_size=`calcsize $PACKAGE-db.pdf`
Packit aea12f
  mv $PACKAGE-db.pdf "$outdir/"
Packit aea12f
fi
Packit aea12f
Packit aea12f
# 
Packit aea12f
printf "\nMaking index.html for $PACKAGE...\n"
Packit aea12f
if test -z "$use_texi2html"; then
Packit aea12f
  CONDS="/%%IF  *HTML_SECTION%%/,/%%ENDIF  *HTML_SECTION%%/d;\
Packit aea12f
         /%%IF  *HTML_CHAPTER%%/,/%%ENDIF  *HTML_CHAPTER%%/d"
Packit aea12f
else
Packit aea12f
  # should take account of --split here.
Packit aea12f
  CONDS="/%%ENDIF.*%%/d;/%%IF  *HTML_SECTION%%/d;/%%IF  *HTML_CHAPTER%%/d"
Packit aea12f
fi
Packit aea12f
Packit aea12f
curdate=`$SETLANG date '+%B %d, %Y'`
Packit aea12f
sed \
Packit aea12f
   -e "s!%%TITLE%%!$MANUAL_TITLE!g" \
Packit aea12f
   -e "s!%%EMAIL%%!$EMAIL!g" \
Packit aea12f
   -e "s!%%PACKAGE%%!$PACKAGE!g" \
Packit aea12f
   -e "s!%%DATE%%!$curdate!g" \
Packit aea12f
   -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \
Packit aea12f
   -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \
Packit aea12f
   -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \
Packit aea12f
   -e "s!%%HTML_SECTION_TGZ_SIZE%%!$html_section_tgz_size!g" \
Packit aea12f
   -e "s!%%HTML_CHAPTER_TGZ_SIZE%%!$html_chapter_tgz_size!g" \
Packit aea12f
   -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \
Packit aea12f
   -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \
Packit aea12f
   -e "s!%%PDF_SIZE%%!$pdf_size!g" \
Packit aea12f
   -e "s!%%ASCII_SIZE%%!$ascii_size!g" \
Packit aea12f
   -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \
Packit aea12f
   -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \
Packit aea12f
   -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \
Packit aea12f
   -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \
Packit aea12f
   -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \
Packit aea12f
   -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \
Packit aea12f
   -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \
Packit aea12f
   -e "s,%%SCRIPTURL%%,$scripturl,g" \
Packit aea12f
   -e "s!%%SCRIPTNAME%%!$prog!g" \
Packit aea12f
   -e "$CONDS" \
Packit aea12f
$GENDOCS_TEMPLATE_DIR/gendocs_template >"$outdir/index.html"
Packit aea12f
Packit aea12f
echo "Done, see $outdir/ subdirectory for new files."
Packit aea12f
Packit aea12f
# Local variables:
Packit aea12f
# eval: (add-hook 'before-save-hook 'time-stamp)
Packit aea12f
# time-stamp-start: "scriptversion="
Packit aea12f
# time-stamp-format: "%:y-%02m-%02d.%02H"
Packit aea12f
# time-stamp-end: "$"
Packit aea12f
# End: