Home | History | Annotate | Line # | Download | only in extra
      1  1.1  christos #!/bin/sh -e
      2  1.1  christos # gendocs.sh -- generate a GNU manual in many formats.  This script is
      3  1.1  christos #   mentioned in maintain.texi.  See the help message below for usage details.
      4  1.1  christos 
      5  1.1  christos scriptversion=2022-01-01.00
      6  1.1  christos 
      7  1.1  christos # Copyright 2003-2022 Free Software Foundation, Inc.
      8  1.1  christos #
      9  1.1  christos # This program is free software: you can redistribute it and/or modify
     10  1.1  christos # it under the terms of the GNU General Public License as published by
     11  1.1  christos # the Free Software Foundation, either version 3 of the License, or
     12  1.1  christos # (at your option) any later version.
     13  1.1  christos #
     14  1.1  christos # This program is distributed in the hope that it will be useful,
     15  1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17  1.1  christos # GNU General Public License for more details.
     18  1.1  christos #
     19  1.1  christos # You should have received a copy of the GNU General Public License
     20  1.1  christos # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     21  1.1  christos #
     22  1.1  christos # Original author: Mohit Agarwal.
     23  1.1  christos # Send bug reports and any other correspondence to bug-gnulib (at] gnu.org.
     24  1.1  christos #
     25  1.1  christos # The latest version of this script, and the companion template, is
     26  1.1  christos # available from the Gnulib repository:
     27  1.1  christos #
     28  1.1  christos # https://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/gendocs.sh
     29  1.1  christos # https://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/gendocs_template
     30  1.1  christos 
     31  1.1  christos # TODO:
     32  1.1  christos # - image importing was only implemented for HTML generated by
     33  1.1  christos #   makeinfo.  But it should be simple enough to adjust.
     34  1.1  christos # - images are not imported in the source tarball.  All the needed
     35  1.1  christos #   formats (PDF, PNG, etc.) should be included.
     36  1.1  christos 
     37  1.1  christos prog=`basename "$0"`
     38  1.1  christos srcdir=`pwd`
     39  1.1  christos 
     40  1.1  christos scripturl="https://git.savannah.gnu.org/cgit/gnulib.git/plain/build-aux/gendocs.sh"
     41  1.1  christos templateurl="https://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/gendocs_template"
     42  1.1  christos 
     43  1.1  christos : ${SETLANG="env LANG= LC_MESSAGES= LC_ALL= LANGUAGE="}
     44  1.1  christos : ${MAKEINFO="makeinfo"}
     45  1.1  christos : ${TEXI2DVI="texi2dvi"}
     46  1.1  christos : ${DOCBOOK2HTML="docbook2html"}
     47  1.1  christos : ${DOCBOOK2PDF="docbook2pdf"}
     48  1.1  christos : ${DOCBOOK2TXT="docbook2txt"}
     49  1.1  christos : ${GENDOCS_TEMPLATE_DIR="."}
     50  1.1  christos : ${PERL='perl'}
     51  1.1  christos : ${TEXI2HTML="texi2html"}
     52  1.1  christos unset CDPATH
     53  1.1  christos unset use_texi2html
     54  1.1  christos 
     55  1.1  christos MANUAL_TITLE=
     56  1.1  christos PACKAGE=
     57  1.1  christos EMAIL=webmasters@gnu.org  # please override with --email
     58  1.1  christos commonarg= # passed to all makeinfo/texi2html invcations.
     59  1.1  christos dirargs=   # passed to all tools (-I dir).
     60  1.1  christos dirs=      # -I directories.
     61  1.1  christos htmlarg="--css-ref=https://www.gnu.org/software/gnulib/manual.css -c TOP_NODE_UP_URL=/manual"
     62  1.1  christos default_htmlarg=true
     63  1.1  christos infoarg=--no-split
     64  1.1  christos generate_ascii=true
     65  1.1  christos generate_html=true
     66  1.1  christos generate_info=true
     67  1.1  christos generate_tex=true
     68  1.1  christos outdir=manual
     69  1.1  christos source_extra=
     70  1.1  christos split=node
     71  1.1  christos srcfile=
     72  1.1  christos texarg="-t @finalout"
     73  1.1  christos 
     74  1.1  christos version="gendocs.sh $scriptversion
     75  1.1  christos 
     76  1.1  christos Copyright 2022 Free Software Foundation, Inc.
     77  1.1  christos There is NO warranty.  You may redistribute this software
     78  1.1  christos under the terms of the GNU General Public License.
     79  1.1  christos For more information about these matters, see the files named COPYING."
     80  1.1  christos 
     81  1.1  christos usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE
     82  1.1  christos 
     83  1.1  christos Generate output in various formats from PACKAGE.texinfo (or .texi or
     84  1.1  christos .txi) source.  See the GNU Maintainers document for a more extensive
     85  1.1  christos discussion:
     86  1.1  christos   https://www.gnu.org/prep/maintain_toc.html
     87  1.1  christos 
     88  1.1  christos Options:
     89  1.1  christos   --email ADR use ADR as contact in generated web pages; always give this.
     90  1.1  christos 
     91  1.1  christos   -s SRCFILE   read Texinfo from SRCFILE, instead of PACKAGE.{texinfo|texi|txi}
     92  1.1  christos   -o OUTDIR    write files into OUTDIR, instead of manual/.
     93  1.1  christos   -I DIR       append DIR to the Texinfo search path.
     94  1.1  christos   --common ARG pass ARG in all invocations.
     95  1.1  christos   --html ARG   pass ARG to makeinfo or texi2html for HTML targets,
     96  1.1  christos                  instead of '$htmlarg'.
     97  1.1  christos   --info ARG   pass ARG to makeinfo for Info, instead of --no-split.
     98  1.1  christos   --no-ascii   skip generating the plain text output.
     99  1.1  christos   --no-html    skip generating the html output.
    100  1.1  christos   --no-info    skip generating the info output.
    101  1.1  christos   --no-tex     skip generating the dvi and pdf output.
    102  1.1  christos   --source ARG include ARG in tar archive of sources.
    103  1.1  christos   --split HOW  make split HTML by node, section, chapter; default node.
    104  1.1  christos   --tex ARG    pass ARG to texi2dvi for DVI and PDF, instead of -t @finalout.
    105  1.1  christos 
    106  1.1  christos   --texi2html  use texi2html to make HTML target, with all split versions.
    107  1.1  christos   --docbook    convert through DocBook too (xml, txt, html, pdf).
    108  1.1  christos 
    109  1.1  christos   --help       display this help and exit successfully.
    110  1.1  christos   --version    display version information and exit successfully.
    111  1.1  christos 
    112  1.1  christos Simple example: $prog --email bug-gnu-emacs (at] gnu.org emacs \"GNU Emacs Manual\"
    113  1.1  christos 
    114  1.1  christos Typical sequence:
    115  1.1  christos   cd PACKAGESOURCE/doc
    116  1.1  christos   wget \"$scripturl\"
    117  1.1  christos   wget \"$templateurl\"
    118  1.1  christos   $prog --email BUGLIST MANUAL \"GNU MANUAL - One-line description\"
    119  1.1  christos 
    120  1.1  christos Output will be in a new subdirectory \"manual\" (by default;
    121  1.1  christos use -o OUTDIR to override).  Move all the new files into your web CVS
    122  1.1  christos tree, as explained in the Web Pages node of maintain.texi.
    123  1.1  christos 
    124  1.1  christos Please use the --email ADDRESS option so your own bug-reporting
    125  1.1  christos address will be used in the generated HTML pages.
    126  1.1  christos 
    127  1.1  christos MANUAL-TITLE is included as part of the HTML <title> of the overall
    128  1.1  christos manual/index.html file.  It should include the name of the package being
    129  1.1  christos documented.  manual/index.html is created by substitution from the file
    130  1.1  christos $GENDOCS_TEMPLATE_DIR/gendocs_template.  (Feel free to modify the
    131  1.1  christos generic template for your own purposes.)
    132  1.1  christos 
    133  1.1  christos If you have several manuals, you'll need to run this script several
    134  1.1  christos times with different MANUAL values, specifying a different output
    135  1.1  christos directory with -o each time.  Then write (by hand) an overall index.html
    136  1.1  christos with links to them all.
    137  1.1  christos 
    138  1.1  christos If a manual's Texinfo sources are spread across several directories,
    139  1.1  christos first copy or symlink all Texinfo sources into a single directory.
    140  1.1  christos (Part of the script's work is to make a tar.gz of the sources.)
    141  1.1  christos 
    142  1.1  christos As implied above, by default monolithic Info files are generated.
    143  1.1  christos If you want split Info, or other Info options, use --info to override.
    144  1.1  christos 
    145  1.1  christos You can set the environment variables MAKEINFO, TEXI2DVI, TEXI2HTML,
    146  1.1  christos and PERL to control the programs that get executed, and
    147  1.1  christos GENDOCS_TEMPLATE_DIR to control where the gendocs_template file is
    148  1.1  christos looked for.  With --docbook, the environment variables DOCBOOK2HTML,
    149  1.1  christos DOCBOOK2PDF, and DOCBOOK2TXT are also consulted.
    150  1.1  christos 
    151  1.1  christos By default, makeinfo and texi2dvi are run in the default (English)
    152  1.1  christos locale, since that's the language of most Texinfo manuals.  If you
    153  1.1  christos happen to have a non-English manual and non-English web site, see the
    154  1.1  christos SETLANG setting in the source.
    155  1.1  christos 
    156  1.1  christos Email bug reports or enhancement requests to bug-gnulib (at] gnu.org.
    157  1.1  christos "
    158  1.1  christos 
    159  1.1  christos while test $# -gt 0; do
    160  1.1  christos   case $1 in
    161  1.1  christos     -s)          shift; srcfile=$1;;
    162  1.1  christos     -o)          shift; outdir=$1;;
    163  1.1  christos     -I)          shift; dirargs="$dirargs -I '$1'"; dirs="$dirs $1";;
    164  1.1  christos     --common)    shift; commonarg=$1;;
    165  1.1  christos     --docbook)   docbook=yes;;
    166  1.1  christos     --email)     shift; EMAIL=$1;;
    167  1.1  christos     --html)      shift; default_htmlarg=false; htmlarg=$1;;
    168  1.1  christos     --info)      shift; infoarg=$1;;
    169  1.1  christos     --no-ascii)  generate_ascii=false;;
    170  1.1  christos     --no-html)   generate_ascii=false;;
    171  1.1  christos     --no-info)   generate_info=false;;
    172  1.1  christos     --no-tex)    generate_tex=false;;
    173  1.1  christos     --source)    shift; source_extra=$1;;
    174  1.1  christos     --split)     shift; split=$1;;
    175  1.1  christos     --tex)       shift; texarg=$1;;
    176  1.1  christos     --texi2html) use_texi2html=1;;
    177  1.1  christos 
    178  1.1  christos     --help)      echo "$usage"; exit 0;;
    179  1.1  christos     --version)   echo "$version"; exit 0;;
    180  1.1  christos     -*)
    181  1.1  christos       echo "$0: Unknown option \`$1'." >&2
    182  1.1  christos       echo "$0: Try \`--help' for more information." >&2
    183  1.1  christos       exit 1;;
    184  1.1  christos     *)
    185  1.1  christos       if test -z "$PACKAGE"; then
    186  1.1  christos         PACKAGE=$1
    187  1.1  christos       elif test -z "$MANUAL_TITLE"; then
    188  1.1  christos         MANUAL_TITLE=$1
    189  1.1  christos       else
    190  1.1  christos         echo "$0: extra non-option argument \`$1'." >&2
    191  1.1  christos         exit 1
    192  1.1  christos       fi;;
    193  1.1  christos   esac
    194  1.1  christos   shift
    195  1.1  christos done
    196  1.1  christos 
    197  1.1  christos # makeinfo uses the dirargs, but texi2dvi doesn't.
    198  1.1  christos commonarg=" $dirargs $commonarg"
    199  1.1  christos 
    200  1.1  christos # For most of the following, the base name is just $PACKAGE
    201  1.1  christos base=$PACKAGE
    202  1.1  christos 
    203  1.1  christos if $default_htmlarg && test -n "$use_texi2html"; then
    204  1.1  christos   # The legacy texi2html doesn't support TOP_NODE_UP_URL
    205  1.1  christos   htmlarg="--css-ref=https://www.gnu.org/software/gnulib/manual.css"
    206  1.1  christos fi
    207  1.1  christos 
    208  1.1  christos if test -n "$srcfile"; then
    209  1.1  christos   # but here, we use the basename of $srcfile
    210  1.1  christos   base=`basename "$srcfile"`
    211  1.1  christos   case $base in
    212  1.1  christos     *.txi|*.texi|*.texinfo) base=`echo "$base"|sed 's/\.[texinfo]*$//'`;;
    213  1.1  christos   esac
    214  1.1  christos   PACKAGE=$base
    215  1.1  christos elif test -s "$srcdir/$PACKAGE.texinfo"; then
    216  1.1  christos   srcfile=$srcdir/$PACKAGE.texinfo
    217  1.1  christos elif test -s "$srcdir/$PACKAGE.texi"; then
    218  1.1  christos   srcfile=$srcdir/$PACKAGE.texi
    219  1.1  christos elif test -s "$srcdir/$PACKAGE.txi"; then
    220  1.1  christos   srcfile=$srcdir/$PACKAGE.txi
    221  1.1  christos else
    222  1.1  christos   echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2
    223  1.1  christos   exit 1
    224  1.1  christos fi
    225  1.1  christos 
    226  1.1  christos if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then
    227  1.1  christos   echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2
    228  1.1  christos   echo "$0: it is available from $templateurl." >&2
    229  1.1  christos   exit 1
    230  1.1  christos fi
    231  1.1  christos 
    232  1.1  christos # Function to return size of $1 in something resembling kilobytes.
    233  1.1  christos calcsize()
    234  1.1  christos {
    235  1.1  christos   size=`ls -ksl $1 | awk '{print $1}'`
    236  1.1  christos   echo $size
    237  1.1  christos }
    238  1.1  christos 
    239  1.1  christos # copy_images OUTDIR HTML-FILE...
    240  1.1  christos # -------------------------------
    241  1.1  christos # Copy all the images needed by the HTML-FILEs into OUTDIR.
    242  1.1  christos # Look for them in . and the -I directories; this is simpler than what
    243  1.1  christos # makeinfo supports with -I, but hopefully it will suffice.
    244  1.1  christos copy_images()
    245  1.1  christos {
    246  1.1  christos   local odir
    247  1.1  christos   odir=$1
    248  1.1  christos   shift
    249  1.1  christos   $PERL -n -e "
    250  1.1  christos BEGIN {
    251  1.1  christos   \$me = '$prog';
    252  1.1  christos   \$odir = '$odir';
    253  1.1  christos   @dirs = qw(. $dirs);
    254  1.1  christos }
    255  1.1  christos " -e '
    256  1.1  christos /<img src="(.*?)"/g && ++$need{$1};
    257  1.1  christos 
    258  1.1  christos END {
    259  1.1  christos   #print "$me: @{[keys %need]}\n";  # for debugging, show images found.
    260  1.1  christos   FILE: for my $f (keys %need) {
    261  1.1  christos     for my $d (@dirs) {
    262  1.1  christos       if (-f "$d/$f") {
    263  1.1  christos         use File::Basename;
    264  1.1  christos         my $dest = dirname ("$odir/$f");
    265  1.1  christos         #
    266  1.1  christos         use File::Path;
    267  1.1  christos         -d $dest || mkpath ($dest)
    268  1.1  christos           || die "$me: cannot mkdir $dest: $!\n";
    269  1.1  christos         #
    270  1.1  christos         use File::Copy;
    271  1.1  christos         copy ("$d/$f", $dest)
    272  1.1  christos           || die "$me: cannot copy $d/$f to $dest: $!\n";
    273  1.1  christos         next FILE;
    274  1.1  christos       }
    275  1.1  christos     }
    276  1.1  christos     die "$me: $ARGV: cannot find image $f\n";
    277  1.1  christos   }
    278  1.1  christos }
    279  1.1  christos ' -- "$@" || exit 1
    280  1.1  christos }
    281  1.1  christos 
    282  1.1  christos case $outdir in
    283  1.1  christos   /*) abs_outdir=$outdir;;
    284  1.1  christos   *)  abs_outdir=$srcdir/$outdir;;
    285  1.1  christos esac
    286  1.1  christos 
    287  1.1  christos echo "Making output for $srcfile"
    288  1.1  christos echo " in `pwd`"
    289  1.1  christos mkdir -p "$outdir/"
    290  1.1  christos 
    291  1.1  christos # 
    293  1.1  christos if $generate_info; then
    294  1.1  christos   cmd="$SETLANG $MAKEINFO -o $PACKAGE.info $commonarg $infoarg \"$srcfile\""
    295  1.1  christos   echo "Generating info... ($cmd)"
    296  1.1  christos   rm -f $PACKAGE.info* # get rid of any strays
    297  1.1  christos   eval "$cmd"
    298  1.1  christos   tar czf "$outdir/$PACKAGE.info.tar.gz" $PACKAGE.info*
    299  1.1  christos   ls -l "$outdir/$PACKAGE.info.tar.gz"
    300  1.1  christos   info_tgz_size=`calcsize "$outdir/$PACKAGE.info.tar.gz"`
    301  1.1  christos   # do not mv the info files, there's no point in having them available
    302  1.1  christos   # separately on the web.
    303  1.1  christos fi  # end info
    304  1.1  christos 
    305  1.1  christos # 
    307  1.1  christos if $generate_tex; then
    308  1.1  christos   cmd="$SETLANG $TEXI2DVI $dirargs $texarg \"$srcfile\""
    309  1.1  christos   printf "\nGenerating dvi... ($cmd)\n"
    310  1.1  christos   eval "$cmd"
    311  1.1  christos   # compress/finish dvi:
    312  1.1  christos   gzip -f -9 $PACKAGE.dvi
    313  1.1  christos   dvi_gz_size=`calcsize $PACKAGE.dvi.gz`
    314  1.1  christos   mv $PACKAGE.dvi.gz "$outdir/"
    315  1.1  christos   ls -l "$outdir/$PACKAGE.dvi.gz"
    316  1.1  christos 
    317  1.1  christos   cmd="$SETLANG $TEXI2DVI --pdf $dirargs $texarg \"$srcfile\""
    318  1.1  christos   printf "\nGenerating pdf... ($cmd)\n"
    319  1.1  christos   eval "$cmd"
    320  1.1  christos   pdf_size=`calcsize $PACKAGE.pdf`
    321  1.1  christos   mv $PACKAGE.pdf "$outdir/"
    322  1.1  christos   ls -l "$outdir/$PACKAGE.pdf"
    323  1.1  christos fi # end tex (dvi + pdf)
    324  1.1  christos 
    325  1.1  christos # 
    327  1.1  christos if $generate_ascii; then
    328  1.1  christos   opt="-o $PACKAGE.txt --no-split --no-headers $commonarg"
    329  1.1  christos   cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
    330  1.1  christos   printf "\nGenerating ascii... ($cmd)\n"
    331  1.1  christos   eval "$cmd"
    332  1.1  christos   ascii_size=`calcsize $PACKAGE.txt`
    333  1.1  christos   gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz"
    334  1.1  christos   ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"`
    335  1.1  christos   mv $PACKAGE.txt "$outdir/"
    336  1.1  christos   ls -l "$outdir/$PACKAGE.txt" "$outdir/$PACKAGE.txt.gz"
    337  1.1  christos fi
    338  1.1  christos 
    339  1.1  christos # 
    341  1.1  christos 
    342  1.1  christos if $generate_html; then
    343  1.1  christos # Split HTML at level $1.  Used for texi2html.
    344  1.1  christos html_split()
    345  1.1  christos {
    346  1.1  christos   opt="--split=$1 --node-files $commonarg $htmlarg"
    347  1.1  christos   cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\""
    348  1.1  christos   printf "\nGenerating html by $1... ($cmd)\n"
    349  1.1  christos   eval "$cmd"
    350  1.1  christos   split_html_dir=$PACKAGE.html
    351  1.1  christos   (
    352  1.1  christos     cd ${split_html_dir} || exit 1
    353  1.1  christos     ln -sf ${PACKAGE}.html index.html
    354  1.1  christos     tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html
    355  1.1  christos   )
    356  1.1  christos   eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"`
    357  1.1  christos   rm -f "$outdir"/html_$1/*.html
    358  1.1  christos   mkdir -p "$outdir/html_$1/"
    359  1.1  christos   mv ${split_html_dir}/*.html "$outdir/html_$1/"
    360  1.1  christos   rmdir ${split_html_dir}
    361  1.1  christos }
    362  1.1  christos 
    363  1.1  christos if test -z "$use_texi2html"; then
    364  1.1  christos   opt="--no-split --html -o $PACKAGE.html $commonarg $htmlarg"
    365  1.1  christos   cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
    366  1.1  christos   printf "\nGenerating monolithic html... ($cmd)\n"
    367  1.1  christos   rm -rf $PACKAGE.html  # in case a directory is left over
    368  1.1  christos   eval "$cmd"
    369  1.1  christos   html_mono_size=`calcsize $PACKAGE.html`
    370  1.1  christos   gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
    371  1.1  christos   html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
    372  1.1  christos   copy_images "$outdir/" $PACKAGE.html
    373  1.1  christos   mv $PACKAGE.html "$outdir/"
    374  1.1  christos   ls -l "$outdir/$PACKAGE.html" "$outdir/$PACKAGE.html.gz"
    375  1.1  christos 
    376  1.1  christos   # Before Texinfo 5.0, makeinfo did not accept a --split=HOW option,
    377  1.1  christos   # it just always split by node.  So if we're splitting by node anyway,
    378  1.1  christos   # leave it out.
    379  1.1  christos   if test "x$split" = xnode; then
    380  1.1  christos     split_arg=
    381  1.1  christos   else
    382  1.1  christos     split_arg=--split=$split
    383  1.1  christos   fi
    384  1.1  christos   #
    385  1.1  christos   opt="--html -o $PACKAGE.html $split_arg $commonarg $htmlarg"
    386  1.1  christos   cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
    387  1.1  christos   printf "\nGenerating html by $split... ($cmd)\n"
    388  1.1  christos   eval "$cmd"
    389  1.1  christos   split_html_dir=$PACKAGE.html
    390  1.1  christos   copy_images $split_html_dir/ $split_html_dir/*.html
    391  1.1  christos   (
    392  1.1  christos     cd $split_html_dir || exit 1
    393  1.1  christos     tar -czf "$abs_outdir/$PACKAGE.html_$split.tar.gz" -- *
    394  1.1  christos   )
    395  1.1  christos   eval \
    396  1.1  christos     html_${split}_tgz_size=`calcsize "$outdir/$PACKAGE.html_$split.tar.gz"`
    397  1.1  christos   rm -rf "$outdir/html_$split/"
    398  1.1  christos   mv $split_html_dir "$outdir/html_$split/"
    399  1.1  christos   du -s "$outdir/html_$split/"
    400  1.1  christos   ls -l "$outdir/$PACKAGE.html_$split.tar.gz"
    401  1.1  christos 
    402  1.1  christos else # use texi2html:
    403  1.1  christos   opt="--output $PACKAGE.html $commonarg $htmlarg"
    404  1.1  christos   cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\""
    405  1.1  christos   printf "\nGenerating monolithic html with texi2html... ($cmd)\n"
    406  1.1  christos   rm -rf $PACKAGE.html  # in case a directory is left over
    407  1.1  christos   eval "$cmd"
    408  1.1  christos   html_mono_size=`calcsize $PACKAGE.html`
    409  1.1  christos   gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
    410  1.1  christos   html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
    411  1.1  christos   mv $PACKAGE.html "$outdir/"
    412  1.1  christos 
    413  1.1  christos   html_split node
    414  1.1  christos   html_split chapter
    415  1.1  christos   html_split section
    416  1.1  christos fi
    417  1.1  christos fi # end html
    418  1.1  christos 
    419  1.1  christos # 
    421  1.1  christos printf "\nMaking .tar.gz for sources...\n"
    422  1.1  christos d=`dirname $srcfile`
    423  1.1  christos (
    424  1.1  christos   cd "$d"
    425  1.1  christos   srcfiles=`ls -d *.texinfo *.texi *.txi *.eps $source_extra 2>/dev/null` || true
    426  1.1  christos   tar czfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles
    427  1.1  christos   ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"
    428  1.1  christos )
    429  1.1  christos texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"`
    430  1.1  christos 
    431  1.1  christos # 
    433  1.1  christos # Do everything again through docbook.
    434  1.1  christos if test -n "$docbook"; then
    435  1.1  christos   opt="-o - --docbook $commonarg"
    436  1.1  christos   cmd="$SETLANG $MAKEINFO $opt \"$srcfile\" >${srcdir}/$PACKAGE-db.xml"
    437  1.1  christos   printf "\nGenerating docbook XML... ($cmd)\n"
    438  1.1  christos   eval "$cmd"
    439  1.1  christos   docbook_xml_size=`calcsize $PACKAGE-db.xml`
    440  1.1  christos   gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz"
    441  1.1  christos   docbook_xml_gz_size=`calcsize "$outdir/$PACKAGE-db.xml.gz"`
    442  1.1  christos   mv $PACKAGE-db.xml "$outdir/"
    443  1.1  christos 
    444  1.1  christos   split_html_db_dir=html_node_db
    445  1.1  christos   opt="$commonarg -o $split_html_db_dir"
    446  1.1  christos   cmd="$DOCBOOK2HTML $opt \"${outdir}/$PACKAGE-db.xml\""
    447  1.1  christos   printf "\nGenerating docbook HTML... ($cmd)\n"
    448  1.1  christos   eval "$cmd"
    449  1.1  christos   (
    450  1.1  christos     cd ${split_html_db_dir} || exit 1
    451  1.1  christos     tar -czf "$abs_outdir/${PACKAGE}.html_node_db.tar.gz" -- *.html
    452  1.1  christos   )
    453  1.1  christos   html_node_db_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node_db.tar.gz"`
    454  1.1  christos   rm -f "$outdir"/html_node_db/*.html
    455  1.1  christos   mkdir -p "$outdir/html_node_db"
    456  1.1  christos   mv ${split_html_db_dir}/*.html "$outdir/html_node_db/"
    457  1.1  christos   rmdir ${split_html_db_dir}
    458  1.1  christos 
    459  1.1  christos   cmd="$DOCBOOK2TXT \"${outdir}/$PACKAGE-db.xml\""
    460  1.1  christos   printf "\nGenerating docbook ASCII... ($cmd)\n"
    461  1.1  christos   eval "$cmd"
    462  1.1  christos   docbook_ascii_size=`calcsize $PACKAGE-db.txt`
    463  1.1  christos   mv $PACKAGE-db.txt "$outdir/"
    464  1.1  christos 
    465  1.1  christos   cmd="$DOCBOOK2PDF \"${outdir}/$PACKAGE-db.xml\""
    466  1.1  christos   printf "\nGenerating docbook PDF... ($cmd)\n"
    467  1.1  christos   eval "$cmd"
    468  1.1  christos   docbook_pdf_size=`calcsize $PACKAGE-db.pdf`
    469  1.1  christos   mv $PACKAGE-db.pdf "$outdir/"
    470  1.1  christos fi
    471  1.1  christos 
    472  1.1  christos # 
    474  1.1  christos printf "\nMaking index.html for $PACKAGE...\n"
    475  1.1  christos if test -z "$use_texi2html"; then
    476  1.1  christos   CONDS="/%%IF  *HTML_SECTION%%/,/%%ENDIF  *HTML_SECTION%%/d;\
    477  1.1  christos          /%%IF  *HTML_CHAPTER%%/,/%%ENDIF  *HTML_CHAPTER%%/d"
    478  1.1  christos else
    479  1.1  christos   # should take account of --split here.
    480  1.1  christos   CONDS="/%%ENDIF.*%%/d;/%%IF  *HTML_SECTION%%/d;/%%IF  *HTML_CHAPTER%%/d"
    481  1.1  christos fi
    482  1.1  christos 
    483  1.1  christos curdate=`$SETLANG date '+%B %d, %Y'`
    484  1.1  christos sed \
    485  1.1  christos    -e "s!%%TITLE%%!$MANUAL_TITLE!g" \
    486  1.1  christos    -e "s!%%EMAIL%%!$EMAIL!g" \
    487  1.1  christos    -e "s!%%PACKAGE%%!$PACKAGE!g" \
    488  1.1  christos    -e "s!%%DATE%%!$curdate!g" \
    489  1.1  christos    -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \
    490  1.1  christos    -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \
    491  1.1  christos    -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \
    492  1.1  christos    -e "s!%%HTML_SECTION_TGZ_SIZE%%!$html_section_tgz_size!g" \
    493  1.1  christos    -e "s!%%HTML_CHAPTER_TGZ_SIZE%%!$html_chapter_tgz_size!g" \
    494  1.1  christos    -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \
    495  1.1  christos    -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \
    496  1.1  christos    -e "s!%%PDF_SIZE%%!$pdf_size!g" \
    497  1.1  christos    -e "s!%%ASCII_SIZE%%!$ascii_size!g" \
    498  1.1  christos    -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \
    499  1.1  christos    -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \
    500  1.1  christos    -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \
    501  1.1  christos    -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \
    502  1.1  christos    -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \
    503  1.1  christos    -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \
    504  1.1  christos    -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \
    505  1.1  christos    -e "s,%%SCRIPTURL%%,$scripturl,g" \
    506  1.1  christos    -e "s!%%SCRIPTNAME%%!$prog!g" \
    507  1.1  christos    -e "$CONDS" \
    508  1.1  christos $GENDOCS_TEMPLATE_DIR/gendocs_template >"$outdir/index.html"
    509  1.1  christos 
    510  1.1  christos echo "Done, see $outdir/ subdirectory for new files."
    511                
    512                # Local variables:
    513                # eval: (add-hook 'before-save-hook 'time-stamp)
    514                # time-stamp-start: "scriptversion="
    515                # time-stamp-format: "%:y-%02m-%02d.%02H"
    516                # time-stamp-end: "$"
    517                # End:
    518