* doc/xml/manual/policy_data_structures.xml: Simplify and
[official-gcc.git] / maintainer-scripts / update_web_docs_svn
blobe5f76e6d8740593c0bdb77e5d0eeba8f99e96566
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 libitm
28 libquadmath
29 libiberty
30 porting"
32 CSS=/gcc.css
34 WWWBASE=/www/gcc/htdocs
35 WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted
36 WWWPREPROCESS='/www/gcc/bin/preprocess -r'
38 # Process options -rrelease and -ddirectory
39 RELEASE=""
40 SUBDIR=""
42 while [ $# -gt 0 ]; do
43 case $1 in
44 -r*)
45 if [ -n "$RELEASE" ]; then
46 echo "Multiple releases specified" >&2
47 exit 1
49 RELEASE="${1#-r}"
50 if [ -z "$RELEASE" ]; then
51 shift
52 RELEASE="$1"
53 if [ -z "$RELEASE" ]; then
54 echo "No release specified with -r" >&2
55 exit 1
59 -d*)
60 if [ -n "$SUBDIR" ]; then
61 echo "Multiple subdirectories specified" >&2
62 exit 1
64 SUBDIR="${1#-d}"
65 if [ -z "$SUBDIR" ]; then
66 shift
67 SUBDIR="$1"
68 if [ -z "$SUBDIR" ]; then
69 echo "No subdirectory specified with -d" >&2
70 exit 1
75 echo "Unknown argument \"$1\"" >&2
76 exit 1
78 esac
79 shift
80 done
82 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
83 echo "Release specified without subdirectory" >&2
84 exit 1
87 if [ -z "$SUBDIR" ]; then
88 DOCSDIR=$WWWBASE/onlinedocs
89 else
90 DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR
93 if [ ! -d $DOCSDIR ]; then
94 mkdir $DOCSDIR
95 chmod g+w $DOCSDIR
98 if [ -z "$RELEASE" ]; then
99 RELEASE=trunk
102 WORKDIR=/tmp/gcc-doc-update.$$
104 rm -rf $WORKDIR
105 mkdir $WORKDIR
106 cd $WORKDIR
107 if [ "$RELEASE" = "trunk" ]; then
108 svn -q export $SVNROOT/$RELEASE gcc
109 else
110 svn -q export $SVNROOT/tags/$RELEASE gcc
113 # Remove all unwanted files. This is needed to avoid packaging all the
114 # sources instead of only documentation sources.
115 # Note that we have to preserve gcc/jit/docs since the jit docs are
116 # not .texi files (Makefile, .rst and .png), and the jit docs use
117 # include directives to pull in content from jit/jit-common.h and
118 # jit/notes.txt, so we have to preserve those also.
119 find gcc -type f \( -name '*.texi' \
120 -o -path gcc/gcc/doc/install.texi2html \
121 -o -path gcc/gcc/doc/include/texinfo.tex \
122 -o -path gcc/gcc/BASE-VER \
123 -o -path gcc/gcc/DEV-PHASE \
124 -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \
125 -o -path "gcc/gcc/jit/docs/*" \
126 -o -path "gcc/gcc/jit/jit-common.h" \
127 -o -path "gcc/gcc/jit/notes.txt" \
128 -o -print0 \) | xargs -0 rm -f
130 # Build a tarball of the sources.
131 tar cf docs-sources.tar gcc
133 # The directory to pass to -I; this is the one with texinfo.tex
134 # and fdl.texi.
135 includedir=gcc/gcc/doc/include
137 # Generate gcc-vers.texi.
139 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"
140 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then
141 echo "@set DEVELOPMENT"
142 else
143 echo "@clear DEVELOPMENT"
145 echo "@set srcdir $WORKDIR/gcc/gcc"
146 echo "@set VERSION_PACKAGE (GCC)"
147 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}"
148 ) > $includedir/gcc-vers.texi
150 # Generate libquadmath-vers.texi.
151 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" \
152 > $includedir/libquadmath-vers.texi
154 # Now convert the relevant files from texi to HTML, PDF and PostScript.
155 for file in $MANUALS; do
156 filename=`find . -name ${file}.texi`
157 if [ "${filename}" ]; then
158 includes="-I ${includedir} -I `dirname ${filename}`"
159 if [ "$file" = "gnat_ugn" ]; then
160 includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn"
162 makeinfo --html --css-ref $CSS $includes -o ${file} ${filename}
163 tar cf ${file}-html.tar ${file}/*.html
164 texi2dvi $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi
165 texi2pdf $includes -o ${file}.pdf ${filename} </dev/null
166 mkdir -p $DOCSDIR/$file
168 done
170 # The jit is a special-case, using sphinx rather than texinfo.
171 # Specifically, the jit docs need sphinx 1.0 or later.
173 # The jit/docs Makefile uses the executable $(SPHINXBUILD),
174 # defaulting to "sphinx-build".
176 # sphinx is packaged in Fedora and EPEL 6 within "python-sphinx",
177 # and in openSUSE within "python-Sphinx".
179 # For EPEL6, python-sphinx is sphinx 0.6.6, which is missing various
180 # directives (e.g. ":c:macro:"), so we need the variant
181 # python-sphinx10 package. The latter installs its executable as
182 # /usr/bin/sphinx-1.0-build
183 # so we need to override SPHINXBUILD with this when invoking "make".
184 pushd gcc/gcc/jit/docs
185 make SPHINXBUILD=/usr/bin/sphinx-1.0-build html
186 popd
187 cp -a gcc/gcc/jit/docs/_build/html jit
188 mkdir -p $DOCSDIR/jit
190 # Work around makeinfo generated file names and references with
191 # "_002d" instead of "-".
192 find . -name '*.html' | while read f; do
193 # Do this for the contents of each file.
194 sed -i -e 's/_002d/-/g' "$f"
195 # And rename files if necessary.
196 ff=`echo $f | sed -e 's/_002d/-/g'`;
197 if [ "$f" != "$ff" ]; then
198 printf "Renaming %s to %s\n" "$f" "$ff"
199 mv "$f" "$ff"
201 done
203 # Then build a gzipped copy of each of the resulting .html, .ps and .tar files
204 for file in */*.html *.ps *.pdf *.tar; do
205 cat $file | gzip --best > $file.gz
206 done
208 # On the 15th of the month, wipe all the old files from the
209 # web server.
210 today=`date +%d`
211 if test $today = 15; then
212 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
213 for m in $MANUALS; do
214 rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz
215 done
218 # And copy the resulting files to the web server
219 for file in */*.html *.ps *.pdf *.tar; do
220 if [ -f $DOCSDIR/$file ]; then
221 cat $DOCSDIR/$file |
222 sed -e '/^<meta name=generator/d' \
223 -e '/^%DVIPSSource:/d' > file1
225 cat $file |
226 sed -e '/^<meta name=generator/d' \
227 -e '/^%DVIPSSource:/d' > file2
228 if cmp -s file1 file2; then
230 else
231 cp $file $DOCSDIR/$file
232 cp $file.gz $DOCSDIR/$file.gz
234 done
236 # Again, the jit is a special case, with nested subdirectories
237 # below "jit", and with some non-HTML files (.png images from us,
238 # plus .css and .js supplied by sphinx, and source files, renamed
239 # from .rst to .txt).
240 find jit \
241 -name "*.html" -o -name "*.png" \
242 -o -name "*.css" -o -name "*.js" \
243 -o -name "*.txt" |
244 while read file ; do
245 # Note that $file here will contain path fragments beginning
246 # with "jit/", e.g. "jit/cp/topics/functions.html"
247 mkdir -p $(dirname $DOCSDIR/$file)
248 cp $file $DOCSDIR/$file
249 done
251 cd $DOCSDIR
253 # Finally, generate the installation documentation
254 if [ "$RELEASE" = "trunk" ]; then
255 SOURCEDIR=$WORKDIR/gcc/gcc/doc
256 DESTDIR=$WWWBASE_PREFORMATTED/install
257 export SOURCEDIR
258 export DESTDIR
259 $WORKDIR/gcc/gcc/doc/install.texi2html
261 # Preprocess the entire web site, not just the install docs!
262 echo "Invoking $WWWPREPROCESS"
263 $WWWPREPROCESS |grep -v '^ Warning: Keeping'
266 # Clean up behind us.
268 rm -rf $WORKDIR