~vcs-imports-ii/xboard/master

1460 by Arun Persaud
added some documentation about what's need to be done for a release and a bash-release script
1
#!/bin/sh
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=2009-04-08.09
6
7
# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009
8
# Free Software Foundation, Inc.
9
#
10
# This program is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 3 of the License,
13
# or (at your option) any later version.
14
#
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License
21
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
#
23
# Original author: Mohit Agarwal.
24
# Send bug reports and any other correspondence to bug-texinfo@gnu.org.
25
26
prog=`basename "$0"`
27
srcdir=`pwd`
28
29
scripturl="http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/texinfo/texinfo/util/gendocs.sh"
30
templateurl="http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/texinfo/texinfo/util/gendocs_template"
31
32
: ${SETLANG="env LANG= LC_MESSAGES= LC_ALL= LANGUAGE="}
33
: ${MAKEINFO="makeinfo"}
34
: ${TEXI2DVI="texi2dvi -t @finalout"}
35
: ${DVIPS="dvips"}
36
: ${DOCBOOK2HTML="docbook2html"}
37
: ${DOCBOOK2PDF="docbook2pdf"}
38
: ${DOCBOOK2PS="docbook2ps"}
39
: ${DOCBOOK2TXT="docbook2txt"}
40
: ${GENDOCS_TEMPLATE_DIR="."}
41
: ${TEXI2HTML="texi2html"}
42
unset CDPATH
43
unset use_texi2html
44
45
version="gendocs.sh $scriptversion
46
47
Copyright 2009 Free Software Foundation, Inc.
48
There is NO warranty.  You may redistribute this software
49
under the terms of the GNU General Public License.
50
For more information about these matters, see the files named COPYING."
51
52
usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE
53
54
Generate various output formats from PACKAGE.texinfo (or .texi or .txi) source.
55
See the GNU Maintainers document for a more extensive discussion:
56
  http://www.gnu.org/prep/maintain_toc.html
57
58
Options:
59
  -o OUTDIR   write files into OUTDIR, instead of manual/.
60
  --email ADR use ADR as contact in generated web pages.
61
  --docbook   convert to DocBook too (xml, txt, html, pdf and ps).
62
  --html ARG  pass indicated ARG to makeinfo or texi2html for HTML targets.
63
  --texi2html use texi2html to generate HTML targets.
64
  --help      display this help and exit successfully.
65
  --version   display version information and exit successfully.
66
67
Simple example: $prog --email bug-gnu-emacs@gnu.org emacs \"GNU Emacs Manual\"
68
69
Typical sequence:
70
  cd PACKAGESOURCE/doc
71
  wget \"$scripturl\"
72
  wget \"$templateurl\"
73
  $prog --email BUGLIST MANUAL \"GNU MANUAL - One-line description\"
74
75
Output will be in a new subdirectory \"manual\" (by default, use -o OUTDIR
76
to override).  Move all the new files into your web CVS tree, as
77
explained in the Web Pages node of maintain.texi.
78
79
Please use the --email ADDRESS option to specify your bug-reporting
80
address in the generated HTML pages.
81
82
MANUAL-TITLE is included as part of the HTML <title> of the overall
83
manual/index.html file.  It should include the name of the package being
84
documented.  manual/index.html is created by substitution from the file
85
$GENDOCS_TEMPLATE_DIR/gendocs_template.  (Feel free to modify the
86
generic template for your own purposes.)
87
88
If you have several manuals, you'll need to run this script several
89
times with different MANUAL values, specifying a different output
90
directory with -o each time.  Then write (by hand) an overall index.html
91
with links to them all.
92
93
If a manual's Texinfo sources are spread across several directories,
94
first copy or symlink all Texinfo sources into a single directory.
95
(Part of the script's work is to make a tar.gz of the sources.)
96
97
You can set the environment variables MAKEINFO, TEXI2DVI, and DVIPS to
98
control the programs that get executed, and GENDOCS_TEMPLATE_DIR to
99
control where the gendocs_template file is looked for.  (With --docbook,
100
the environment variables DOCBOOK2HTML, DOCBOOK2PDF, DOCBOOK2PS, and
101
DOCBOOK2TXT are also respected.)
102
103
By default, makeinfo is run in the default (English) locale, since
104
that's the language of most Texinfo manuals.  If you happen to have a
105
non-English manual and non-English web site, see the SETLANG setting
106
in the source.
107
108
Email bug reports or enhancement requests to bug-texinfo@gnu.org.
109
"
110
111
calcsize()
112
{
113
  size=`ls -ksl $1 | awk '{print $1}'`
114
  echo $size
115
}
116
117
MANUAL_TITLE=
118
PACKAGE=
119
EMAIL=webmasters@gnu.org  # please override with --email
120
htmlarg=
121
outdir=manual
122
123
while test $# -gt 0; do
124
  case $1 in
125
    --email) shift; EMAIL=$1;;
126
    --help) echo "$usage"; exit 0;;
127
    --version) echo "$version"; exit 0;;
128
    -o) shift; outdir=$1;;
129
    --docbook) docbook=yes;;
130
    --html) shift; htmlarg=$1;;
131
    --texi2html) use_texi2html=1;;
132
    -*)
133
      echo "$0: Unknown option \`$1'." >&2
134
      echo "$0: Try \`--help' for more information." >&2
135
      exit 1;;
136
    *)
137
      if test -z "$PACKAGE"; then
138
        PACKAGE=$1
139
      elif test -z "$MANUAL_TITLE"; then
140
        MANUAL_TITLE=$1
141
      else
142
        echo "$0: extra non-option argument \`$1'." >&2
143
        exit 1
144
      fi;;
145
  esac
146
  shift
147
done
148
149
if test -s "$srcdir/$PACKAGE.texinfo"; then
150
  srcfile=$srcdir/$PACKAGE.texinfo
151
elif test -s "$srcdir/$PACKAGE.texi"; then
152
  srcfile=$srcdir/$PACKAGE.texi
153
elif test -s "$srcdir/$PACKAGE.txi"; then
154
  srcfile=$srcdir/$PACKAGE.txi
155
else
156
  echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2
157
  exit 1
158
fi
159
160
if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then
161
  echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2
162
  echo "$0: it is available from $templateurl." >&2
163
  exit 1
164
fi
165
166
case $outdir in
167
  /*) dotdot_outdir="$outdir";;
168
  *) dotdot_outdir="../$outdir";;
169
esac
170
171
echo Generating output formats for $srcfile
172
173
cmd="$SETLANG $MAKEINFO -o $PACKAGE.info \"$srcfile\""
174
echo "Generating info files... ($cmd)"
175
eval "$cmd"
176
mkdir -p $outdir/
177
tar czf $outdir/$PACKAGE.info.tar.gz $PACKAGE.info*
178
info_tgz_size=`calcsize $outdir/$PACKAGE.info.tar.gz`
179
# do not mv the info files, there's no point in having them available
180
# separately on the web.
181
182
cmd="${TEXI2DVI} \"$srcfile\""
183
echo "Generating dvi ... ($cmd)"
184
eval "$cmd"
185
186
# now, before we compress dvi:
187
echo Generating postscript...
188
${DVIPS} $PACKAGE -o
189
gzip -f -9 $PACKAGE.ps
190
ps_gz_size=`calcsize $PACKAGE.ps.gz`
191
mv $PACKAGE.ps.gz $outdir/
192
193
# compress/finish dvi:
194
gzip -f -9 $PACKAGE.dvi
195
dvi_gz_size=`calcsize $PACKAGE.dvi.gz`
196
mv $PACKAGE.dvi.gz $outdir/
197
198
cmd="${TEXI2DVI} --pdf \"$srcfile\""
199
echo "Generating pdf ... ($cmd)"
200
eval "$cmd"
201
pdf_size=`calcsize $PACKAGE.pdf`
202
mv $PACKAGE.pdf $outdir/
203
204
cmd="$SETLANG $MAKEINFO -o $PACKAGE.txt --no-split --no-headers \"$srcfile\""
205
echo "Generating ASCII... ($cmd)"
206
eval "$cmd"
207
ascii_size=`calcsize $PACKAGE.txt`
208
gzip -f -9 -c $PACKAGE.txt >$outdir/$PACKAGE.txt.gz
209
ascii_gz_size=`calcsize $outdir/$PACKAGE.txt.gz`
210
mv $PACKAGE.txt $outdir/
211
212
html_split()
213
{
214
  opt="--split=$1 $htmlarg --node-files"
215
  cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\""
216
  echo "Generating html by $1... ($cmd)"
217
  eval "$cmd"
218
  split_html_dir=$PACKAGE.html
219
  (
220
    cd ${split_html_dir} || exit 1
221
    ln -sf ${PACKAGE}.html index.html
222
    tar -czf $dotdot_outdir/${PACKAGE}.html_$1.tar.gz -- *.html
223
  )
224
  eval html_$1_tgz_size=`calcsize $outdir/${PACKAGE}.html_$1.tar.gz`
225
  rm -f $outdir/html_$1/*.html
226
  mkdir -p $outdir/html_$1/
227
  mv ${split_html_dir}/*.html $outdir/html_$1/
228
  rmdir ${split_html_dir}
229
}
230
231
if test -z "$use_texi2html"; then
232
  opt="--no-split --html -o $PACKAGE.html $htmlarg"
233
  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
234
  echo "Generating monolithic html... ($cmd)"
235
  rm -rf $PACKAGE.html  # in case a directory is left over
236
  eval "$cmd"
237
  html_mono_size=`calcsize $PACKAGE.html`
238
  gzip -f -9 -c $PACKAGE.html >$outdir/$PACKAGE.html.gz
239
  html_mono_gz_size=`calcsize $outdir/$PACKAGE.html.gz`
240
  mv $PACKAGE.html $outdir/
241
242
  cmd="$SETLANG $MAKEINFO --html -o $PACKAGE.html $htmlarg \"$srcfile\""
243
  echo "Generating html by node... ($cmd)"
244
  eval "$cmd"
245
  split_html_dir=$PACKAGE.html
246
  (
247
   cd ${split_html_dir} || exit 1
248
   tar -czf $dotdot_outdir/${PACKAGE}.html_node.tar.gz -- *.html
249
  )
250
  html_node_tgz_size=`calcsize $outdir/${PACKAGE}.html_node.tar.gz`
251
  rm -f $outdir/html_node/*.html
252
  mkdir -p $outdir/html_node/
253
  mv ${split_html_dir}/*.html $outdir/html_node/
254
  rmdir ${split_html_dir}
255
else
256
  cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $htmlarg \"$srcfile\""
257
  echo "Generating monolithic html... ($cmd)"
258
  rm -rf $PACKAGE.html  # in case a directory is left over
259
  eval "$cmd"
260
  html_mono_size=`calcsize $PACKAGE.html`
261
  gzip -f -9 -c $PACKAGE.html >$outdir/$PACKAGE.html.gz
262
  html_mono_gz_size=`calcsize $outdir/$PACKAGE.html.gz`
263
  mv $PACKAGE.html $outdir/
264
265
  html_split node
266
  html_split chapter
267
  html_split section
268
fi
269
270
echo Making .tar.gz for sources...
271
srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null`
272
tar cvzfh $outdir/$PACKAGE.texi.tar.gz $srcfiles
273
texi_tgz_size=`calcsize $outdir/$PACKAGE.texi.tar.gz`
274
275
if test -n "$docbook"; then
276
  cmd="$SETLANG $MAKEINFO -o - --docbook \"$srcfile\" > ${srcdir}/$PACKAGE-db.xml"
277
  echo "Generating docbook XML... $(cmd)"
278
  eval "$cmd"
279
  docbook_xml_size=`calcsize $PACKAGE-db.xml`
280
  gzip -f -9 -c $PACKAGE-db.xml >$outdir/$PACKAGE-db.xml.gz
281
  docbook_xml_gz_size=`calcsize $outdir/$PACKAGE-db.xml.gz`
282
  mv $PACKAGE-db.xml $outdir/
283
284
  cmd="${DOCBOOK2HTML} -o $split_html_db_dir ${outdir}/$PACKAGE-db.xml"
285
  echo "Generating docbook HTML... ($cmd)"
286
  eval "$cmd"
287
  split_html_db_dir=html_node_db
288
  (
289
    cd ${split_html_db_dir} || exit 1
290
    tar -czf $dotdot_outdir/${PACKAGE}.html_node_db.tar.gz -- *.html
291
  )
292
  html_node_db_tgz_size=`calcsize $outdir/${PACKAGE}.html_node_db.tar.gz`
293
  rm -f $outdir/html_node_db/*.html
294
  mkdir -p $outdir/html_node_db
295
  mv ${split_html_db_dir}/*.html $outdir/html_node_db/
296
  rmdir ${split_html_db_dir}
297
298
  cmd="${DOCBOOK2TXT} ${outdir}/$PACKAGE-db.xml"
299
  echo "Generating docbook ASCII... ($cmd)"
300
  eval "$cmd"
301
  docbook_ascii_size=`calcsize $PACKAGE-db.txt`
302
  mv $PACKAGE-db.txt $outdir/
303
304
  cmd="${DOCBOOK2PS} ${outdir}/$PACKAGE-db.xml"
305
  echo "Generating docbook PS... $(cmd)"
306
  eval "$cmd"
307
  gzip -f -9 -c $PACKAGE-db.ps >$outdir/$PACKAGE-db.ps.gz
308
  docbook_ps_gz_size=`calcsize $outdir/$PACKAGE-db.ps.gz`
309
  mv $PACKAGE-db.ps $outdir/
310
311
  cmd="${DOCBOOK2PDF} ${outdir}/$PACKAGE-db.xml"
312
  echo "Generating docbook PDF... ($cmd)"
313
  eval "$cmd"
314
  docbook_pdf_size=`calcsize $PACKAGE-db.pdf`
315
  mv $PACKAGE-db.pdf $outdir/
316
fi
317
318
echo "Writing index file..."
319
if test -z "$use_texi2html"; then
320
   CONDS="/%%IF  *HTML_SECTION%%/,/%%ENDIF  *HTML_SECTION%%/d;\
321
          /%%IF  *HTML_CHAPTER%%/,/%%ENDIF  *HTML_CHAPTER%%/d"
322
else
323
   CONDS="/%%ENDIF.*%%/d;/%%IF  *HTML_SECTION%%/d;/%%IF  *HTML_CHAPTER%%/d"
324
fi
325
curdate=`$SETLANG date '+%B %d, %Y'`
326
sed \
327
   -e "s!%%TITLE%%!$MANUAL_TITLE!g" \
328
   -e "s!%%EMAIL%%!$EMAIL!g" \
329
   -e "s!%%PACKAGE%%!$PACKAGE!g" \
330
   -e "s!%%DATE%%!$curdate!g" \
331
   -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \
332
   -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \
333
   -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \
334
   -e "s!%%HTML_SECTION_TGZ_SIZE%%!$html_section_tgz_size!g" \
335
   -e "s!%%HTML_CHAPTER_TGZ_SIZE%%!$html_chapter_tgz_size!g" \
336
   -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \
337
   -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \
338
   -e "s!%%PDF_SIZE%%!$pdf_size!g" \
339
   -e "s!%%PS_GZ_SIZE%%!$ps_gz_size!g" \
340
   -e "s!%%ASCII_SIZE%%!$ascii_size!g" \
341
   -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \
342
   -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \
343
   -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \
344
   -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \
345
   -e "s!%%DOCBOOK_PS_GZ_SIZE%%!$docbook_ps_gz_size!g" \
346
   -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \
347
   -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \
348
   -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \
349
   -e "s,%%SCRIPTURL%%,$scripturl,g" \
350
   -e "s!%%SCRIPTNAME%%!$prog!g" \
351
   -e "$CONDS" \
352
$GENDOCS_TEMPLATE_DIR/gendocs_template >$outdir/index.html
353
354
echo "Done, see $outdir/ subdirectory for new files."
355
356
# Local variables:
357
# eval: (add-hook 'write-file-hooks 'time-stamp)
358
# time-stamp-start: "scriptversion="
359
# time-stamp-format: "%:y-%02m-%02d.%02H"
360
# time-stamp-end: "$"
361
# End: