]>
Commit | Line | Data |
---|---|---|
d21a98b8 | 1 | #!/bin/sh |
4dc7b0f0 DB |
2 | |
3 | # Generate HTML documentation from GCC Texinfo docs. | |
b54f986e GP |
4 | # |
5 | # If you want to run this on a machine different from gcc.gnu.org, you | |
33742a0a | 6 | # may need to adjust GITROOT and WWWBASE below (or override them via the |
b54f986e | 7 | # environment). |
4dc7b0f0 | 8 | |
f0ac2193 JM |
9 | set -e |
10 | ||
4dc7b0f0 | 11 | # Run this from /tmp. |
33742a0a JM |
12 | GITROOT=${GITROOT:-"/git/gcc.git"} |
13 | export GITROOT | |
4dc7b0f0 DB |
14 | |
15 | PATH=/usr/local/bin:$PATH | |
16 | ||
339731c9 GP |
17 | MANUALS="cpp |
18 | cppinternals | |
19 | fastjar | |
20 | gcc | |
e493bdc2 | 21 | gccgo |
339731c9 GP |
22 | gccint |
23 | gcj | |
d13c359a | 24 | gdc |
339731c9 GP |
25 | gfortran |
26 | gfc-internals | |
fa4d0ab5 | 27 | gm2 |
aaebbe1f | 28 | gnat_ugn |
339731c9 GP |
29 | gnat-style |
30 | gnat_rm | |
31 | libgomp | |
8027776f | 32 | libitm |
f21fe684 | 33 | libquadmath |
339731c9 GP |
34 | libiberty |
35 | porting" | |
36 | ||
0c061da9 | 37 | BUGURL="http://gcc.gnu.org/bugs/" |
27334ebe | 38 | CSS=/texinfo-manuals.css |
b8c0f3c1 | 39 | |
b54f986e | 40 | WWWBASE=${WWWBASE:-"/www/gcc/htdocs"} |
4dc7b0f0 DB |
41 | WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted |
42 | WWWPREPROCESS='/www/gcc/bin/preprocess -r' | |
43 | ||
44 | # Process options -rrelease and -ddirectory | |
45 | RELEASE="" | |
46 | SUBDIR="" | |
47 | ||
48 | while [ $# -gt 0 ]; do | |
49 | case $1 in | |
50 | -r*) | |
51 | if [ -n "$RELEASE" ]; then | |
52 | echo "Multiple releases specified" >&2 | |
53 | exit 1 | |
54 | fi | |
55 | RELEASE="${1#-r}" | |
56 | if [ -z "$RELEASE" ]; then | |
57 | shift | |
58 | RELEASE="$1" | |
59 | if [ -z "$RELEASE" ]; then | |
60 | echo "No release specified with -r" >&2 | |
61 | exit 1 | |
62 | fi | |
63 | fi | |
64 | ;; | |
65 | -d*) | |
66 | if [ -n "$SUBDIR" ]; then | |
67 | echo "Multiple subdirectories specified" >&2 | |
68 | exit 1 | |
69 | fi | |
70 | SUBDIR="${1#-d}" | |
71 | if [ -z "$SUBDIR" ]; then | |
72 | shift | |
73 | SUBDIR="$1" | |
74 | if [ -z "$SUBDIR" ]; then | |
75 | echo "No subdirectory specified with -d" >&2 | |
76 | exit 1 | |
77 | fi | |
78 | fi | |
79 | ;; | |
80 | *) | |
81 | echo "Unknown argument \"$1\"" >&2 | |
82 | exit 1 | |
83 | ;; | |
84 | esac | |
85 | shift | |
86 | done | |
87 | ||
88 | if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then | |
89 | echo "Release specified without subdirectory" >&2 | |
90 | exit 1 | |
91 | fi | |
92 | ||
93 | if [ -z "$SUBDIR" ]; then | |
94 | DOCSDIR=$WWWBASE/onlinedocs | |
95 | else | |
96 | DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR | |
97 | fi | |
98 | ||
b54f986e GP |
99 | if [ ! -d $WWWBASE ]; then |
100 | echo "WWW base directory \"$WWWBASE\" does not exist." >&2 | |
101 | exit 1 | |
102 | fi | |
103 | ||
4dc7b0f0 DB |
104 | if [ ! -d $DOCSDIR ]; then |
105 | mkdir $DOCSDIR | |
6a4b4d31 | 106 | chmod g+w $DOCSDIR |
4dc7b0f0 DB |
107 | fi |
108 | ||
109 | if [ -z "$RELEASE" ]; then | |
33742a0a | 110 | RELEASE=master |
4dc7b0f0 DB |
111 | fi |
112 | ||
113 | WORKDIR=/tmp/gcc-doc-update.$$ | |
114 | ||
f0ac2193 JM |
115 | rm -rf $WORKDIR |
116 | mkdir $WORKDIR | |
4dc7b0f0 | 117 | cd $WORKDIR |
33742a0a JM |
118 | if [ "$RELEASE" = "master" ]; then |
119 | git clone -q $GITROOT gcc | |
4dc7b0f0 | 120 | else |
33742a0a | 121 | git clone -q -b releases/gcc-$RELEASE $GITROOT gcc |
4dc7b0f0 | 122 | fi |
33742a0a | 123 | rm -rf gcc/.git |
4dc7b0f0 | 124 | |
8200e6f1 AC |
125 | # Remove all unwanted files. This is needed to avoid packaging all the |
126 | # sources instead of only documentation sources. | |
5a28932a DM |
127 | # Note that we have to preserve gcc/jit/docs since the jit docs are |
128 | # not .texi files (Makefile, .rst and .png), and the jit docs use | |
129 | # include directives to pull in content from jit/jit-common.h and | |
130 | # jit/notes.txt, so we have to preserve those also. | |
f0ac2193 JM |
131 | find gcc -type f \( -name '*.texi' \ |
132 | -o -path gcc/gcc/doc/install.texi2html \ | |
133 | -o -path gcc/gcc/doc/include/texinfo.tex \ | |
f0ac2193 JM |
134 | -o -path gcc/gcc/BASE-VER \ |
135 | -o -path gcc/gcc/DEV-PHASE \ | |
f66172c4 | 136 | -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \ |
5a28932a DM |
137 | -o -path "gcc/gcc/jit/docs/*" \ |
138 | -o -path "gcc/gcc/jit/jit-common.h" \ | |
139 | -o -path "gcc/gcc/jit/notes.txt" \ | |
f0ac2193 JM |
140 | -o -print0 \) | xargs -0 rm -f |
141 | ||
4dc7b0f0 DB |
142 | # Build a tarball of the sources. |
143 | tar cf docs-sources.tar gcc | |
144 | ||
145 | # The directory to pass to -I; this is the one with texinfo.tex | |
146 | # and fdl.texi. | |
147 | includedir=gcc/gcc/doc/include | |
148 | ||
4dc7b0f0 DB |
149 | # Generate gcc-vers.texi. |
150 | ( | |
151 | echo "@set version-GCC $(cat gcc/gcc/BASE-VER)" | |
152 | if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then | |
153 | echo "@set DEVELOPMENT" | |
154 | else | |
155 | echo "@clear DEVELOPMENT" | |
156 | fi | |
e99c1d84 | 157 | echo "@set srcdir $WORKDIR/gcc/gcc" |
2f41c1d6 | 158 | echo "@set VERSION_PACKAGE (GCC)" |
0c061da9 | 159 | echo "@set BUGURL @uref{$BUGURL}" |
4dc7b0f0 DB |
160 | ) > $includedir/gcc-vers.texi |
161 | ||
afa62639 | 162 | # Generate libquadmath-vers.texi. |
0c061da9 | 163 | echo "@set BUGURL @uref{$BUGURL}" \ |
afa62639 JM |
164 | > $includedir/libquadmath-vers.texi |
165 | ||
4dc7b0f0 DB |
166 | # Now convert the relevant files from texi to HTML, PDF and PostScript. |
167 | for file in $MANUALS; do | |
168 | filename=`find . -name ${file}.texi` | |
169 | if [ "${filename}" ]; then | |
4f8f9b8f | 170 | includes="-I ${includedir} -I `dirname ${filename}`" |
fa4d0ab5 GM |
171 | if [ "$file" = "gm2" ]; then |
172 | includes="$includes -I gcc/gcc/m2/target-independent" | |
173 | includes="$includes -I gcc/gcc/m2/target-independent/m2" | |
174 | elif [ "$file" = "gnat_ugn" ]; then | |
1d3d9afa | 175 | includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn" |
4f8f9b8f | 176 | fi |
b8c0f3c1 | 177 | makeinfo --html --css-ref $CSS $includes -o ${file} ${filename} |
4dc7b0f0 | 178 | tar cf ${file}-html.tar ${file}/*.html |
4f8f9b8f JM |
179 | texi2dvi $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi |
180 | texi2pdf $includes -o ${file}.pdf ${filename} </dev/null | |
4dc7b0f0 DB |
181 | mkdir -p $DOCSDIR/$file |
182 | fi | |
183 | done | |
184 | ||
c6894e1d ML |
185 | # The jit is a special-case, using Sphinx rather than texinfo. |
186 | # Specifically, the jit docs need Sphinx 3.0 or later. | |
a4be4e91 | 187 | # |
c6894e1d ML |
188 | # Use the Sphinx installed in a virtual environment so that |
189 | # we don't depend on a system package. | |
190 | ||
5a28932a | 191 | pushd gcc/gcc/jit/docs |
c6894e1d | 192 | make html SPHINXBUILD=/home/gccadmin/venv/bin/sphinx-build || true |
5a28932a DM |
193 | popd |
194 | cp -a gcc/gcc/jit/docs/_build/html jit | |
195 | mkdir -p $DOCSDIR/jit | |
196 | ||
52cacf72 GP |
197 | # Work around makeinfo generated file names and references with |
198 | # "_002d" instead of "-". | |
199 | find . -name '*.html' | while read f; do | |
200 | # Do this for the contents of each file. | |
201 | sed -i -e 's/_002d/-/g' "$f" | |
202 | # And rename files if necessary. | |
203 | ff=`echo $f | sed -e 's/_002d/-/g'`; | |
204 | if [ "$f" != "$ff" ]; then | |
205 | printf "Renaming %s to %s\n" "$f" "$ff" | |
206 | mv "$f" "$ff" | |
207 | fi | |
208 | done | |
209 | ||
4dc7b0f0 DB |
210 | # Then build a gzipped copy of each of the resulting .html, .ps and .tar files |
211 | for file in */*.html *.ps *.pdf *.tar; do | |
212 | cat $file | gzip --best > $file.gz | |
213 | done | |
214 | ||
215 | # On the 15th of the month, wipe all the old files from the | |
216 | # web server. | |
217 | today=`date +%d` | |
218 | if test $today = 15; then | |
219 | find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm | |
220 | for m in $MANUALS; do | |
f0ac2193 | 221 | rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz |
4dc7b0f0 DB |
222 | done |
223 | fi | |
224 | ||
2b9e95d0 | 225 | # And copy the resulting files to the web server |
4dc7b0f0 | 226 | for file in */*.html *.ps *.pdf *.tar; do |
f0ac2193 JM |
227 | if [ -f $DOCSDIR/$file ]; then |
228 | cat $DOCSDIR/$file | | |
229 | sed -e '/^<meta name=generator/d' \ | |
230 | -e '/^%DVIPSSource:/d' > file1 | |
231 | fi | |
4dc7b0f0 DB |
232 | cat $file | |
233 | sed -e '/^<meta name=generator/d' \ | |
234 | -e '/^%DVIPSSource:/d' > file2 | |
235 | if cmp -s file1 file2; then | |
236 | : | |
237 | else | |
238 | cp $file $DOCSDIR/$file | |
239 | cp $file.gz $DOCSDIR/$file.gz | |
240 | fi | |
241 | done | |
242 | ||
5a28932a DM |
243 | # Again, the jit is a special case, with nested subdirectories |
244 | # below "jit", and with some non-HTML files (.png images from us, | |
9baa38b7 DM |
245 | # plus .css and .js supplied by sphinx, and source files, renamed |
246 | # from .rst to .txt). | |
5a28932a DM |
247 | find jit \ |
248 | -name "*.html" -o -name "*.png" \ | |
9baa38b7 DM |
249 | -o -name "*.css" -o -name "*.js" \ |
250 | -o -name "*.txt" | | |
5a28932a DM |
251 | while read file ; do |
252 | # Note that $file here will contain path fragments beginning | |
253 | # with "jit/", e.g. "jit/cp/topics/functions.html" | |
254 | mkdir -p $(dirname $DOCSDIR/$file) | |
255 | cp $file $DOCSDIR/$file | |
256 | done | |
257 | ||
4dc7b0f0 DB |
258 | cd $DOCSDIR |
259 | ||
2b9e95d0 | 260 | # Finally, generate the installation documentation |
33742a0a | 261 | if [ "$RELEASE" = "master" ]; then |
4dc7b0f0 DB |
262 | SOURCEDIR=$WORKDIR/gcc/gcc/doc |
263 | DESTDIR=$WWWBASE_PREFORMATTED/install | |
264 | export SOURCEDIR | |
265 | export DESTDIR | |
266 | $WORKDIR/gcc/gcc/doc/install.texi2html | |
4dc7b0f0 | 267 | |
2b9e95d0 GP |
268 | # Preprocess the entire web site, not just the install docs! |
269 | echo "Invoking $WWWPREPROCESS" | |
270 | $WWWPREPROCESS |grep -v '^ Warning: Keeping' | |
271 | fi | |
339731c9 | 272 | |
4dc7b0f0 DB |
273 | # Clean up behind us. |
274 | ||
275 | rm -rf $WORKDIR |