Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / maintainer-scripts / update_web_docs_svn
blobc0a034fea3853c6f7bee039f3842cd10e151bc39
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_ug_unx
24 gnat_ug_vms
25 gnat_ug_vxw
26 gnat_ug_wnt
27 gnat_ugn_unw
28 gnat-style
29 gnat_rm
30 libgomp
31 libiberty
32 porting"
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
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 (a) to build the Ada
113 # generator programs with the installed library, not the new one and
114 # (b) to avoid packaging all the sources instead of only documentation
115 # sources.
116 find gcc -type f \( -name '*.texi' \
117 -o -path gcc/gcc/doc/install.texi2html \
118 -o -path gcc/gcc/doc/include/texinfo.tex \
119 -o -path gcc/gcc/ada/xgnatugn.adb \
120 -o -path gcc/gcc/ada/ug_words \
121 -o -path gcc/gcc/BASE-VER \
122 -o -path gcc/gcc/DEV-PHASE \
123 -o -print0 \) | xargs -0 rm -f
125 # Build a tarball of the sources.
126 tar cf docs-sources.tar gcc
128 # The directory to pass to -I; this is the one with texinfo.tex
129 # and fdl.texi.
130 includedir=gcc/gcc/doc/include
132 # Generate gnat_ugn_unw
134 if [ -f gcc/gcc/ada/xgnatugn.adb ]; then
135 gnatmake -q gcc/gcc/ada/xgnatugn
136 ./xgnatugn unw gcc/gcc/ada/gnat_ugn.texi \
137 gcc/gcc/ada/ug_words gnat_ugn_unw.texi
140 # Generate gcc-vers.texi.
142 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"
143 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then
144 echo "@set DEVELOPMENT"
145 else
146 echo "@clear DEVELOPMENT"
148 echo "@set srcdir $WORKDIR/gcc/gcc"
149 echo "@set VERSION_PACKAGE (GCC)"
150 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}"
151 ) > $includedir/gcc-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_unw" ]; then
159 includes="$includes -I gcc/gcc/ada"
161 makeinfo --html $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 # Then build a gzipped copy of each of the resulting .html, .ps and .tar files
170 for file in */*.html *.ps *.pdf *.tar; do
171 cat $file | gzip --best > $file.gz
172 done
174 # On the 15th of the month, wipe all the old files from the
175 # web server.
176 today=`date +%d`
177 if test $today = 15; then
178 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
179 for m in $MANUALS; do
180 rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz
181 done
184 # And copy the resulting files to the web server
185 for file in */*.html *.ps *.pdf *.tar; do
186 if [ -f $DOCSDIR/$file ]; then
187 cat $DOCSDIR/$file |
188 sed -e '/^<meta name=generator/d' \
189 -e '/^%DVIPSSource:/d' > file1
191 cat $file |
192 sed -e '/^<meta name=generator/d' \
193 -e '/^%DVIPSSource:/d' > file2
194 if cmp -s file1 file2; then
196 else
197 cp $file $DOCSDIR/$file
198 cp $file.gz $DOCSDIR/$file.gz
200 done
202 cd $DOCSDIR
204 # Finally, generate the installation documentation
205 if [ "$RELEASE" = "trunk" ]; then
206 SOURCEDIR=$WORKDIR/gcc/gcc/doc
207 DESTDIR=$WWWBASE_PREFORMATTED/install
208 export SOURCEDIR
209 export DESTDIR
210 $WORKDIR/gcc/gcc/doc/install.texi2html
212 # Preprocess the entire web site, not just the install docs!
213 echo "Invoking $WWWPREPROCESS"
214 $WWWPREPROCESS |grep -v '^ Warning: Keeping'
217 # Clean up behind us.
219 rm -rf $WORKDIR