moved old instructions for external packages to top-level in preparation for nuking...
[CommonLispStat.git] / external / cffi.darcs / _darcs / pristine / doc / gendocs.sh
blob14260201ca42f90889ef0b6a2243c8e027f84266
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 # $Id: gendocs.sh,v 1.16 2005/05/15 00:00:08 karl Exp $
5 #
6 # Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, you can either send email to this
20 # program's maintainer or write to: The Free Software Foundation,
21 # Inc.; 51 Franklin Street, Fifth Floor; Boston, MA 02110-1301, USA.
23 # Original author: Mohit Agarwal.
24 # Send bug reports and any other correspondence to bug-texinfo@gnu.org.
26 prog="`basename \"$0\"`"
27 srcdir=`pwd`
29 scripturl="http://common-lisp.net/project/cffi/darcs/cffi/doc/gendocs.sh"
30 templateurl="http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs_template"
32 : ${MAKEINFO="makeinfo"}
33 : ${TEXI2DVI="texi2dvi -t @finalout"}
34 : ${DVIPS="dvips"}
35 : ${DOCBOOK2TXT="docbook2txt"}
36 : ${DOCBOOK2HTML="docbook2html"}
37 : ${DOCBOOK2PDF="docbook2pdf"}
38 : ${DOCBOOK2PS="docbook2ps"}
39 : ${GENDOCS_TEMPLATE_DIR="."}
40 unset CDPATH
42 rcs_revision='$Revision: 1.16 $'
43 rcs_version=`set - $rcs_revision; echo $2`
44 program=`echo $0 | sed -e 's!.*/!!'`
45 version="gendocs.sh $rcs_version
47 Copyright (C) 2005 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."
52 usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE
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
58 Options:
59 -o OUTDIR write files into OUTDIR, instead of manual/.
60 --docbook convert to DocBook too (xml, txt, html, pdf and ps).
61 --html ARG pass indicated ARG to makeinfo for HTML targets.
62 --help display this help and exit successfully.
63 --version display version information and exit successfully.
65 Simple example: $prog emacs \"GNU Emacs Manual\"
67 Typical sequence:
68 cd YOURPACKAGESOURCE/doc
69 wget \"$scripturl\"
70 wget \"$templateurl\"
71 $prog YOURMANUAL \"GNU YOURMANUAL - One-line description\"
73 Output will be in a new subdirectory \"manual\" (by default, use -o OUTDIR
74 to override). Move all the new files into your web CVS tree, as
75 explained in the Web Pages node of maintain.texi.
77 MANUAL-TITLE is included as part of the HTML <title> of the overall
78 manual/index.html file. It should include the name of the package being
79 documented. manual/index.html is created by substitution from the file
80 $GENDOCS_TEMPLATE_DIR/gendocs_template. (Feel free to modify the
81 generic template for your own purposes.)
83 If you have several manuals, you'll need to run this script several
84 times with different YOURMANUAL values, specifying a different output
85 directory with -o each time. Then write (by hand) an overall index.html
86 with links to them all.
88 You can set the environment variables MAKEINFO, TEXI2DVI, and DVIPS to
89 control the programs that get executed, and GENDOCS_TEMPLATE_DIR to
90 control where the gendocs_template file is looked for.
92 Email bug reports or enhancement requests to bug-texinfo@gnu.org.
95 calcsize()
97 size="`ls -ksl $1 | awk '{print $1}'`"
98 echo $size
101 outdir=manual
102 html=
103 PACKAGE=
104 MANUAL_TITLE=
106 while test $# -gt 0; do
107 case $1 in
108 --help) echo "$usage"; exit 0;;
109 --version) echo "$version"; exit 0;;
110 -o) shift; outdir=$1;;
111 --docbook) docbook=yes;;
112 --html) shift; html=$1;;
114 echo "$0: Unknown or ambiguous option \`$1'." >&2
115 echo "$0: Try \`--help' for more information." >&2
116 exit 1;;
118 if test -z "$PACKAGE"; then
119 PACKAGE=$1
120 elif test -z "$MANUAL_TITLE"; then
121 MANUAL_TITLE=$1
122 else
123 echo "$0: extra non-option argument \`$1'." >&2
124 exit 1
125 fi;;
126 esac
127 shift
128 done
130 if test -s $srcdir/$PACKAGE.texinfo; then
131 srcfile=$srcdir/$PACKAGE.texinfo
132 elif test -s $srcdir/$PACKAGE.texi; then
133 srcfile=$srcdir/$PACKAGE.texi
134 elif test -s $srcdir/$PACKAGE.txi; then
135 srcfile=$srcdir/$PACKAGE.txi
136 else
137 echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2
138 exit 1
141 if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then
142 echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2
143 echo "$0: it is available from $templateurl." >&2
144 exit 1
147 echo Generating output formats for $srcfile
149 cmd="${MAKEINFO} -o $PACKAGE.info $srcfile"
150 echo "Generating info files... ($cmd)"
151 eval $cmd
152 mkdir -p $outdir/
153 tar czf $outdir/$PACKAGE.info.tar.gz $PACKAGE.info*
154 info_tgz_size="`calcsize $outdir/$PACKAGE.info.tar.gz`"
155 # do not mv the info files, there's no point in having them available
156 # separately on the web.
158 cmd="${TEXI2DVI} $srcfile"
159 echo "Generating dvi ... ($cmd)"
160 eval $cmd
162 # now, before we compress dvi:
163 echo Generating postscript...
164 ${DVIPS} $PACKAGE -o
165 gzip -f -9 $PACKAGE.ps
166 ps_gz_size="`calcsize $PACKAGE.ps.gz`"
167 mv $PACKAGE.ps.gz $outdir/
169 # compress/finish dvi:
170 gzip -f -9 $PACKAGE.dvi
171 dvi_gz_size="`calcsize $PACKAGE.dvi.gz`"
172 mv $PACKAGE.dvi.gz $outdir/
174 cmd="${TEXI2DVI} --pdf $srcfile"
175 echo "Generating pdf ... ($cmd)"
176 eval $cmd
177 pdf_size="`calcsize $PACKAGE.pdf`"
178 mv $PACKAGE.pdf $outdir/
180 cmd="${MAKEINFO} -o $PACKAGE.txt --no-split --no-headers $srcfile"
181 echo "Generating ASCII... ($cmd)"
182 eval $cmd
183 ascii_size="`calcsize $PACKAGE.txt`"
184 gzip -f -9 -c $PACKAGE.txt >$outdir/$PACKAGE.txt.gz
185 ascii_gz_size="`calcsize $outdir/$PACKAGE.txt.gz`"
186 mv $PACKAGE.txt $outdir/
188 # Print a SED expression that will translate references to MANUAL to
189 # the proper page on gnu.org. This is a horrible shell hack done
190 # because \| in sed regexps is a GNU extension.
191 monognuorg () {
192 case "$1" in
193 libtool) echo "s!$1.html!http://www.gnu.org/software/$1/manual.html!" ;;
194 *) echo "s!$1.html!http://www.gnu.org/software/$1/manual/html_mono/$1.html!" ;;
195 esac
197 polygnuorg () {
198 case "$1" in
199 libtool) echo 's!\.\./'"$1/.*\.html!http://www.gnu.org/software/$1/manual.html!" ;;
200 *) echo 's!\.\./'"$1!http://www.gnu.org/software/$1/manual/html_node!" ;;
201 esac
204 cmd="${MAKEINFO} --no-split --html -o $PACKAGE.html $html $srcfile"
205 echo "Generating monolithic html... ($cmd)"
206 rm -rf $PACKAGE.html # in case a directory is left over
207 eval $cmd
208 sbcl --load colorize-lisp-examples.lisp $PACKAGE.html
209 #fix libc/libtool xrefs
210 sed -e `monognuorg libc` -e `monognuorg libtool` $PACKAGE.html >$outdir/$PACKAGE.html
211 rm $PACKAGE.html
212 html_mono_size="`calcsize $outdir/$PACKAGE.html`"
213 gzip -f -9 -c $outdir/$PACKAGE.html >$outdir/$PACKAGE.html.gz
214 html_mono_gz_size="`calcsize $outdir/$PACKAGE.html.gz`"
216 cmd="${MAKEINFO} --html -o $PACKAGE.html $html $srcfile"
217 echo "Generating html by node... ($cmd)"
218 eval $cmd
219 split_html_dir=$PACKAGE.html
220 sbcl --load colorize-lisp-examples.lisp "${split_html_dir}/*.html"
222 cd ${split_html_dir} || exit 1
223 #fix libc xrefs
224 for broken_file in *.html; do
225 sed -e `polygnuorg libc` -e `polygnuorg libtool` "$broken_file" > "$broken_file".temp
226 mv -f "$broken_file".temp "$broken_file"
227 done
228 tar -czf ../$outdir/${PACKAGE}.html_node.tar.gz -- *.html
230 html_node_tgz_size="`calcsize $outdir/${PACKAGE}.html_node.tar.gz`"
231 rm -f $outdir/html_node/*.html
232 mkdir -p $outdir/html_node/
233 mv ${split_html_dir}/*.html $outdir/html_node/
234 rmdir ${split_html_dir}
236 echo Making .tar.gz for sources...
237 srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null`
238 tar cvzfh $outdir/$PACKAGE.texi.tar.gz $srcfiles
239 texi_tgz_size="`calcsize $outdir/$PACKAGE.texi.tar.gz`"
241 if test -n "$docbook"; then
242 cmd="${MAKEINFO} -o - --docbook $srcfile > ${srcdir}/$PACKAGE-db.xml"
243 echo "Generating docbook XML... $(cmd)"
244 eval $cmd
245 docbook_xml_size="`calcsize $PACKAGE-db.xml`"
246 gzip -f -9 -c $PACKAGE-db.xml >$outdir/$PACKAGE-db.xml.gz
247 docbook_xml_gz_size="`calcsize $outdir/$PACKAGE-db.xml.gz`"
248 mv $PACKAGE-db.xml $outdir/
250 cmd="${DOCBOOK2HTML} -o $split_html_db_dir ${outdir}/$PACKAGE-db.xml"
251 echo "Generating docbook HTML... ($cmd)"
252 eval $cmd
253 split_html_db_dir=html_node_db
255 cd ${split_html_db_dir} || exit 1
256 tar -czf ../$outdir/${PACKAGE}.html_node_db.tar.gz -- *.html
258 html_node_db_tgz_size="`calcsize $outdir/${PACKAGE}.html_node_db.tar.gz`"
259 rm -f $outdir/html_node_db/*.html
260 mkdir -p $outdir/html_node_db
261 mv ${split_html_db_dir}/*.html $outdir/html_node_db/
262 rmdir ${split_html_db_dir}
264 cmd="${DOCBOOK2TXT} ${outdir}/$PACKAGE-db.xml"
265 echo "Generating docbook ASCII... ($cmd)"
266 eval $cmd
267 docbook_ascii_size="`calcsize $PACKAGE-db.txt`"
268 mv $PACKAGE-db.txt $outdir/
270 cmd="${DOCBOOK2PS} ${outdir}/$PACKAGE-db.xml"
271 echo "Generating docbook PS... $(cmd)"
272 eval $cmd
273 gzip -f -9 -c $PACKAGE-db.ps >$outdir/$PACKAGE-db.ps.gz
274 docbook_ps_gz_size="`calcsize $outdir/$PACKAGE-db.ps.gz`"
275 mv $PACKAGE-db.ps $outdir/
277 cmd="${DOCBOOK2PDF} ${outdir}/$PACKAGE-db.xml"
278 echo "Generating docbook PDF... ($cmd)"
279 eval $cmd
280 docbook_pdf_size="`calcsize $PACKAGE-db.pdf`"
281 mv $PACKAGE-db.pdf $outdir/
284 echo Writing index file...
285 curdate="`date '+%B %d, %Y'`"
286 sed \
287 -e "s!%%TITLE%%!$MANUAL_TITLE!g" \
288 -e "s!%%DATE%%!$curdate!g" \
289 -e "s!%%PACKAGE%%!$PACKAGE!g" \
290 -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \
291 -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \
292 -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \
293 -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \
294 -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \
295 -e "s!%%PDF_SIZE%%!$pdf_size!g" \
296 -e "s!%%PS_GZ_SIZE%%!$ps_gz_size!g" \
297 -e "s!%%ASCII_SIZE%%!$ascii_size!g" \
298 -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \
299 -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \
300 -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \
301 -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \
302 -e "s!%%DOCBOOK_PS_GZ_SIZE%%!$docbook_ps_gz_size!g" \
303 -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \
304 -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \
305 -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \
306 -e "s,%%SCRIPTURL%%,$scripturl,g" \
307 -e "s!%%SCRIPTNAME%%!$prog!g" \
308 $GENDOCS_TEMPLATE_DIR/gendocs_template >$outdir/index.html
310 echo "Done! See $outdir/ subdirectory for new files."