Blame build-aux/gendocs.sh

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