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