Recently Written · git

clic

MIRROR ONLY Gopher client with pretty colours in Common Lisp

git clone https://github.com/equwal/clic

Log | Files | Refs


3rdparties/software/cffi_0.21.0/doc/gendocs.sh (10832 bytes)

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.
7 #
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.
12 #
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.
17 #
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.
22 #
23 # Original author: Mohit Agarwal.
24 # Send bug reports and any other correspondence to bug-texinfo@gnu.org.
25 
26 #set -e
27 
28 prog="`basename \"$0\"`"
29 srcdir=`pwd`
30 
31 scripturl="https://github.com/cffi/cffi/blob/master/doc/gendocs.sh"
32 templateurl="http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs_template"
33 
34 : ${MAKEINFO="makeinfo"}
35 : ${TEXI2DVI="texi2dvi -t @finalout"}
36 : ${DVIPS="dvips"}
37 : ${DOCBOOK2TXT="docbook2txt"}
38 : ${DOCBOOK2HTML="docbook2html"}
39 : ${DOCBOOK2PDF="docbook2pdf"}
40 : ${DOCBOOK2PS="docbook2ps"}
41 : ${GENDOCS_TEMPLATE_DIR="."}
42 unset CDPATH
43 
44 rcs_revision='$Revision: 1.16 $'
45 rcs_version=`set - $rcs_revision; echo $2`
46 program=`echo $0 | sed -e 's!.*/!!'`
47 version="gendocs.sh $rcs_version
48 
49 Copyright (C) 2005 Free Software Foundation, Inc.
50 There is NO warranty.  You may redistribute this software
51 under the terms of the GNU General Public License.
52 For more information about these matters, see the files named COPYING."
53 
54 usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE
55 
56 Generate various output formats from PACKAGE.texinfo (or .texi or .txi) source.
57 See the GNU Maintainers document for a more extensive discussion:
58   http://www.gnu.org/prep/maintain_toc.html
59 
60 Options:
61   -o OUTDIR   write files into OUTDIR, instead of manual/.
62   --docbook   convert to DocBook too (xml, txt, html, pdf and ps).
63   --html ARG  pass indicated ARG to makeinfo for HTML targets.
64   --help      display this help and exit successfully.
65   --version   display version information and exit successfully.
66 
67 Simple example: $prog emacs \"GNU Emacs Manual\"
68 
69 Typical sequence:
70   cd YOURPACKAGESOURCE/doc
71   wget \"$scripturl\"
72   wget \"$templateurl\"
73   $prog YOURMANUAL \"GNU YOURMANUAL - 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 MANUAL-TITLE is included as part of the HTML <title> of the overall
80 manual/index.html file.  It should include the name of the package being
81 documented.  manual/index.html is created by substitution from the file
82 $GENDOCS_TEMPLATE_DIR/gendocs_template.  (Feel free to modify the
83 generic template for your own purposes.)
84 
85 If you have several manuals, you'll need to run this script several
86 times with different YOURMANUAL values, specifying a different output
87 directory with -o each time.  Then write (by hand) an overall index.html
88 with links to them all.
89 
90 You can set the environment variables MAKEINFO, TEXI2DVI, and DVIPS to
91 control the programs that get executed, and GENDOCS_TEMPLATE_DIR to
92 control where the gendocs_template file is looked for.
93 
94 Email bug reports or enhancement requests to bug-texinfo@gnu.org.
95 "
96 
97 calcsize()
98 {
99   size="`ls -ksl $1 | awk '{print $1}'`"
100   echo $size
101 }
102 
103 outdir=manual
104 html=
105 PACKAGE=
106 MANUAL_TITLE=
107 
108 while test $# -gt 0; do
109   case $1 in
110     --help) echo "$usage"; exit 0;;
111     --version) echo "$version"; exit 0;;
112     -o) shift; outdir=$1;;
113     --docbook) docbook=yes;;
114     --html) shift; html=$1;;
115     -*)
116       echo "$0: Unknown or ambiguous option \`$1'." >&2
117       echo "$0: Try \`--help' for more information." >&2
118       exit 1;;
119     *)
120       if test -z "$PACKAGE"; then
121         PACKAGE=$1
122       elif test -z "$MANUAL_TITLE"; then
123         MANUAL_TITLE=$1
124       else
125         echo "$0: extra non-option argument \`$1'." >&2
126         exit 1
127       fi;;
128   esac
129   shift
130 done
131 
132 if test -s $srcdir/$PACKAGE.texinfo; then
133   srcfile=$srcdir/$PACKAGE.texinfo
134 elif test -s $srcdir/$PACKAGE.texi; then
135   srcfile=$srcdir/$PACKAGE.texi
136 elif test -s $srcdir/$PACKAGE.txi; then
137   srcfile=$srcdir/$PACKAGE.txi
138 else
139   echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2
140   exit 1
141 fi
142 
143 if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then
144   echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2
145   echo "$0: it is available from $templateurl." >&2
146   exit 1
147 fi
148 
149 echo Generating output formats for $srcfile
150 
151 cmd="${MAKEINFO} -o $PACKAGE.info $srcfile"
152 echo "Generating info files... ($cmd)"
153 eval $cmd
154 install-info $PACKAGE.info dir
155 mkdir -p $outdir/
156 tar czf $outdir/$PACKAGE.info.tar.gz $PACKAGE.info*
157 info_tgz_size="`calcsize $outdir/$PACKAGE.info.tar.gz`"
158 # do not mv the info files, there's no point in having them available
159 # separately on the web.
160 
161 cmd="${TEXI2DVI} $srcfile"
162 echo "Generating dvi ... ($cmd)"
163 eval $cmd
164 
165 # now, before we compress dvi:
166 echo Generating postscript...
167 ${DVIPS} $PACKAGE -o
168 gzip -f -9 $PACKAGE.ps
169 ps_gz_size="`calcsize $PACKAGE.ps.gz`"
170 mv $PACKAGE.ps.gz $outdir/
171 
172 # compress/finish dvi:
173 gzip -f -9 $PACKAGE.dvi
174 dvi_gz_size="`calcsize $PACKAGE.dvi.gz`"
175 mv $PACKAGE.dvi.gz $outdir/
176 
177 cmd="${TEXI2DVI} --pdf $srcfile"
178 echo "Generating pdf ... ($cmd)"
179 eval $cmd
180 pdf_size="`calcsize $PACKAGE.pdf`"
181 mv $PACKAGE.pdf $outdir/
182 
183 cmd="${MAKEINFO} -o $PACKAGE.txt --no-split --no-headers $srcfile"
184 echo "Generating ASCII... ($cmd)"
185 eval $cmd
186 ascii_size="`calcsize $PACKAGE.txt`"
187 gzip -f -9 -c $PACKAGE.txt >$outdir/$PACKAGE.txt.gz
188 ascii_gz_size="`calcsize $outdir/$PACKAGE.txt.gz`"
189 mv $PACKAGE.txt $outdir/
190 
191 # Print a SED expression that will translate references to MANUAL to
192 # the proper page on gnu.org.  This is a horrible shell hack done
193 # because \| in sed regexps is a GNU extension.
194 monognuorg () {
195     case "$1" in
196 	libtool) echo "s!$1.html!http://www.gnu.org/software/$1/manual.html!" ;;
197 	*) echo "s!$1.html!http://www.gnu.org/software/$1/manual/html_mono/$1.html!" ;;
198     esac
199 }
200 polygnuorg () {
201     case "$1" in
202 	libtool) echo 's!\.\./'"$1/.*\.html!http://www.gnu.org/software/$1/manual.html!" ;;
203 	*) echo 's!\.\./'"$1!http://www.gnu.org/software/$1/manual/html_node!" ;;
204     esac
205 }
206 
207 cmd="${MAKEINFO} --no-split --html -o $PACKAGE.html $html $srcfile"
208 echo "Generating monolithic html... ($cmd)"
209 rm -rf $PACKAGE.html  # in case a directory is left over
210 eval $cmd
211 sbcl --no-sysinit --no-userinit --load colorize-lisp-examples.lisp $PACKAGE.html
212 #fix libc/libtool xrefs
213 sed -e `monognuorg libc` -e `monognuorg libtool` $PACKAGE.html >$outdir/$PACKAGE.html
214 rm $PACKAGE.html
215 html_mono_size="`calcsize $outdir/$PACKAGE.html`"
216 gzip -f -9 -c $outdir/$PACKAGE.html >$outdir/$PACKAGE.html.gz
217 html_mono_gz_size="`calcsize $outdir/$PACKAGE.html.gz`"
218 
219 cmd="${MAKEINFO} --html -o $PACKAGE.html $html $srcfile"
220 echo "Generating html by node... ($cmd)"
221 eval $cmd
222 split_html_dir=$PACKAGE.html
223 sbcl --no-userinit --no-sysinit --load colorize-lisp-examples.lisp "${split_html_dir}"/\*.html
224 (
225   cd ${split_html_dir} || exit 1
226   #fix libc xrefs
227   for broken_file in *.html; do
228       sed -e `polygnuorg libc` -e `polygnuorg libtool` "$broken_file" > "$broken_file".temp
229       mv -f "$broken_file".temp "$broken_file"
230   done
231   tar -czf ../$outdir/${PACKAGE}.html_node.tar.gz -- *.html
232 )
233 html_node_tgz_size="`calcsize $outdir/${PACKAGE}.html_node.tar.gz`"
234 rm -f $outdir/html_node/*.html
235 mkdir -p $outdir/html_node/
236 mv ${split_html_dir}/*.html $outdir/html_node/
237 rmdir ${split_html_dir}
238 
239 echo Making .tar.gz for sources...
240 srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null`
241 tar cvzfh $outdir/$PACKAGE.texi.tar.gz $srcfiles
242 texi_tgz_size="`calcsize $outdir/$PACKAGE.texi.tar.gz`"
243 
244 if test -n "$docbook"; then
245   cmd="${MAKEINFO} -o - --docbook $srcfile > ${srcdir}/$PACKAGE-db.xml"
246   echo "Generating docbook XML... $(cmd)"
247   eval $cmd
248   docbook_xml_size="`calcsize $PACKAGE-db.xml`"
249   gzip -f -9 -c $PACKAGE-db.xml >$outdir/$PACKAGE-db.xml.gz
250   docbook_xml_gz_size="`calcsize $outdir/$PACKAGE-db.xml.gz`"
251   mv $PACKAGE-db.xml $outdir/
252 
253   cmd="${DOCBOOK2HTML} -o $split_html_db_dir ${outdir}/$PACKAGE-db.xml"
254   echo "Generating docbook HTML... ($cmd)"
255   eval $cmd
256   split_html_db_dir=html_node_db
257   (
258     cd ${split_html_db_dir} || exit 1
259     tar -czf ../$outdir/${PACKAGE}.html_node_db.tar.gz -- *.html
260   )
261   html_node_db_tgz_size="`calcsize $outdir/${PACKAGE}.html_node_db.tar.gz`"
262   rm -f $outdir/html_node_db/*.html
263   mkdir -p $outdir/html_node_db
264   mv ${split_html_db_dir}/*.html $outdir/html_node_db/
265   rmdir ${split_html_db_dir}
266 
267   cmd="${DOCBOOK2TXT} ${outdir}/$PACKAGE-db.xml"
268   echo "Generating docbook ASCII... ($cmd)"
269   eval $cmd
270   docbook_ascii_size="`calcsize $PACKAGE-db.txt`"
271   mv $PACKAGE-db.txt $outdir/
272 
273   cmd="${DOCBOOK2PS} ${outdir}/$PACKAGE-db.xml"
274   echo "Generating docbook PS... $(cmd)"
275   eval $cmd
276   gzip -f -9 -c $PACKAGE-db.ps >$outdir/$PACKAGE-db.ps.gz
277   docbook_ps_gz_size="`calcsize $outdir/$PACKAGE-db.ps.gz`"
278   mv $PACKAGE-db.ps $outdir/
279 
280   cmd="${DOCBOOK2PDF} ${outdir}/$PACKAGE-db.xml"
281   echo "Generating docbook PDF... ($cmd)"
282   eval $cmd
283   docbook_pdf_size="`calcsize $PACKAGE-db.pdf`"
284   mv $PACKAGE-db.pdf $outdir/
285 fi
286 
287 echo Writing index file...
288 curdate="`date '+%B %d, %Y'`"
289 sed \
290    -e "s!%%TITLE%%!$MANUAL_TITLE!g" \
291    -e "s!%%DATE%%!$curdate!g" \
292    -e "s!%%PACKAGE%%!$PACKAGE!g" \
293    -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \
294    -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \
295    -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \
296    -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \
297    -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \
298    -e "s!%%PDF_SIZE%%!$pdf_size!g" \
299    -e "s!%%PS_GZ_SIZE%%!$ps_gz_size!g" \
300    -e "s!%%ASCII_SIZE%%!$ascii_size!g" \
301    -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \
302    -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \
303    -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \
304    -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \
305    -e "s!%%DOCBOOK_PS_GZ_SIZE%%!$docbook_ps_gz_size!g" \
306    -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \
307    -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \
308    -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \
309    -e "s,%%SCRIPTURL%%,$scripturl,g" \
310    -e "s!%%SCRIPTNAME%%!$prog!g" \
311 $GENDOCS_TEMPLATE_DIR/gendocs_template >$outdir/index.html
312 
313 echo "Done!  See $outdir/ subdirectory for new files."