* lib/scanasm.exp (hidden-scan-for): Add XCOFF support.
[official-gcc.git] / maintainer-scripts / update_web_docs_svn
blob0107851dcdd60e172b5310632fcdc76839b3d561
1 #!/bin/sh
3 # Generate HTML documentation from GCC Texinfo docs.
4 # This version is for GCC 3.1 and later versions.
6 set -e
8 # Run this from /tmp.
9 SVNROOT=${SVNROOT:-"file:///svn/gcc"}
10 export SVNROOT
12 PATH=/usr/local/bin:$PATH
14 MANUALS="cpp
15 cppinternals
16 fastjar
17 gcc
18 gccgo
19 gccint
20 gcj
21 gfortran
22 gfc-internals
23 gnat_ugn
24 gnat-style
25 gnat_rm
26 libgomp
27 libquadmath
28 libiberty
29 porting"
31 CSS=/gcc.css
33 WWWBASE=/www/gcc/htdocs
34 WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted
35 WWWPREPROCESS='/www/gcc/bin/preprocess -r'
37 # Process options -rrelease and -ddirectory
38 RELEASE=""
39 SUBDIR=""
41 while [ $# -gt 0 ]; do
42 case $1 in
43 -r*)
44 if [ -n "$RELEASE" ]; then
45 echo "Multiple releases specified" >&2
46 exit 1
48 RELEASE="${1#-r}"
49 if [ -z "$RELEASE" ]; then
50 shift
51 RELEASE="$1"
52 if [ -z "$RELEASE" ]; then
53 echo "No release specified with -r" >&2
54 exit 1
58 -d*)
59 if [ -n "$SUBDIR" ]; then
60 echo "Multiple subdirectories specified" >&2
61 exit 1
63 SUBDIR="${1#-d}"
64 if [ -z "$SUBDIR" ]; then
65 shift
66 SUBDIR="$1"
67 if [ -z "$SUBDIR" ]; then
68 echo "No subdirectory specified with -d" >&2
69 exit 1
74 echo "Unknown argument \"$1\"" >&2
75 exit 1
77 esac
78 shift
79 done
81 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
82 echo "Release specified without subdirectory" >&2
83 exit 1
86 if [ -z "$SUBDIR" ]; then
87 DOCSDIR=$WWWBASE/onlinedocs
88 else
89 DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR
92 if [ ! -d $DOCSDIR ]; then
93 mkdir $DOCSDIR
94 chmod g+w $DOCSDIR
97 if [ -z "$RELEASE" ]; then
98 RELEASE=trunk
101 WORKDIR=/tmp/gcc-doc-update.$$
103 rm -rf $WORKDIR
104 mkdir $WORKDIR
105 cd $WORKDIR
106 if [ "$RELEASE" = "trunk" ]; then
107 svn -q export $SVNROOT/$RELEASE gcc
108 else
109 svn -q export $SVNROOT/tags/$RELEASE gcc
112 # Remove all unwanted files. This is needed to avoid packaging all the
113 # sources instead of only documentation sources.
114 # Note that we have to preserve gcc/jit/docs since the jit docs are
115 # not .texi files (Makefile, .rst and .png), and the jit docs use
116 # include directives to pull in content from jit/jit-common.h and
117 # jit/notes.txt, so we have to preserve those also.
118 find gcc -type f \( -name '*.texi' \
119 -o -path gcc/gcc/doc/install.texi2html \
120 -o -path gcc/gcc/doc/include/texinfo.tex \
121 -o -path gcc/gcc/BASE-VER \
122 -o -path gcc/gcc/DEV-PHASE \
123 -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \
124 -o -path "gcc/gcc/jit/docs/*" \
125 -o -path "gcc/gcc/jit/jit-common.h" \
126 -o -path "gcc/gcc/jit/notes.txt" \
127 -o -print0 \) | xargs -0 rm -f
129 # Build a tarball of the sources.
130 tar cf docs-sources.tar gcc
132 # The directory to pass to -I; this is the one with texinfo.tex
133 # and fdl.texi.
134 includedir=gcc/gcc/doc/include
136 # Generate gcc-vers.texi.
138 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"
139 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then
140 echo "@set DEVELOPMENT"
141 else
142 echo "@clear DEVELOPMENT"
144 echo "@set srcdir $WORKDIR/gcc/gcc"
145 echo "@set VERSION_PACKAGE (GCC)"
146 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}"
147 ) > $includedir/gcc-vers.texi
149 # Generate libquadmath-vers.texi.
150 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" \
151 > $includedir/libquadmath-vers.texi
153 # Now convert the relevant files from texi to HTML, PDF and PostScript.
154 for file in $MANUALS; do
155 filename=`find . -name ${file}.texi`
156 if [ "${filename}" ]; then
157 includes="-I ${includedir} -I `dirname ${filename}`"
158 if [ "$file" = "gnat_ugn" ]; then
159 includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn"
161 makeinfo --html --css-ref $CSS $includes -o ${file} ${filename}
162 tar cf ${file}-html.tar ${file}/*.html
163 texi2dvi $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi
164 texi2pdf $includes -o ${file}.pdf ${filename} </dev/null
165 mkdir -p $DOCSDIR/$file
167 done
169 # The jit is a special-case, using sphinx rather than texinfo.
170 # Specifically, the jit docs need sphinx 1.0 or later.
172 # The jit/docs Makefile uses the executable $(SPHINXBUILD),
173 # defaulting to "sphinx-build".
175 # sphinx is packaged in Fedora and EPEL 6 within "python-sphinx",
176 # and in openSUSE within "python-Sphinx".
178 # For EPEL6, python-sphinx is sphinx 0.6.6, which is missing various
179 # directives (e.g. ":c:macro:"), so we need the variant
180 # python-sphinx10 package. The latter installs its executable as
181 # /usr/bin/sphinx-1.0-build
182 # so we need to override SPHINXBUILD with this when invoking "make".
183 pushd gcc/gcc/jit/docs
184 make SPHINXBUILD=/usr/bin/sphinx-1.0-build html
185 popd
186 cp -a gcc/gcc/jit/docs/_build/html jit
187 mkdir -p $DOCSDIR/jit
189 # Work around makeinfo generated file names and references with
190 # "_002d" instead of "-".
191 find . -name '*.html' | while read f; do
192 # Do this for the contents of each file.
193 sed -i -e 's/_002d/-/g' "$f"
194 # And rename files if necessary.
195 ff=`echo $f | sed -e 's/_002d/-/g'`;
196 if [ "$f" != "$ff" ]; then
197 printf "Renaming %s to %s\n" "$f" "$ff"
198 mv "$f" "$ff"
200 done
202 # Then build a gzipped copy of each of the resulting .html, .ps and .tar files
203 for file in */*.html *.ps *.pdf *.tar; do
204 cat $file | gzip --best > $file.gz
205 done
207 # On the 15th of the month, wipe all the old files from the
208 # web server.
209 today=`date +%d`
210 if test $today = 15; then
211 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
212 for m in $MANUALS; do
213 rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz
214 done
217 # And copy the resulting files to the web server
218 for file in */*.html *.ps *.pdf *.tar; do
219 if [ -f $DOCSDIR/$file ]; then
220 cat $DOCSDIR/$file |
221 sed -e '/^<meta name=generator/d' \
222 -e '/^%DVIPSSource:/d' > file1
224 cat $file |
225 sed -e '/^<meta name=generator/d' \
226 -e '/^%DVIPSSource:/d' > file2
227 if cmp -s file1 file2; then
229 else
230 cp $file $DOCSDIR/$file
231 cp $file.gz $DOCSDIR/$file.gz
233 done
235 # Again, the jit is a special case, with nested subdirectories
236 # below "jit", and with some non-HTML files (.png images from us,
237 # plus .css and .js supplied by sphinx, and source files, renamed
238 # from .rst to .txt).
239 find jit \
240 -name "*.html" -o -name "*.png" \
241 -o -name "*.css" -o -name "*.js" \
242 -o -name "*.txt" |
243 while read file ; do
244 # Note that $file here will contain path fragments beginning
245 # with "jit/", e.g. "jit/cp/topics/functions.html"
246 mkdir -p $(dirname $DOCSDIR/$file)
247 cp $file $DOCSDIR/$file
248 done
250 cd $DOCSDIR
252 # Finally, generate the installation documentation
253 if [ "$RELEASE" = "trunk" ]; then
254 SOURCEDIR=$WORKDIR/gcc/gcc/doc
255 DESTDIR=$WWWBASE_PREFORMATTED/install
256 export SOURCEDIR
257 export DESTDIR
258 $WORKDIR/gcc/gcc/doc/install.texi2html
260 # Preprocess the entire web site, not just the install docs!
261 echo "Invoking $WWWPREPROCESS"
262 $WWWPREPROCESS |grep -v '^ Warning: Keeping'
265 # Clean up behind us.
267 rm -rf $WORKDIR