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