c++: default template arg, partial ordering [PR105481]
[official-gcc.git] / maintainer-scripts / update_web_docs_git
blobd44ab27c1b7cd2fc12c6d383ef71c88c179c1258
1 #!/bin/sh
3 # Generate HTML documentation from GCC Texinfo docs.
5 # If you want to run this on a machine different from gcc.gnu.org, you
6 # may need to adjust GITROOT and WWWBASE below (or override them via the
7 # environment).
9 set -e
11 # Run this from /tmp.
12 GITROOT=${GITROOT:-"/git/gcc.git"}
13 export GITROOT
15 PATH=/usr/local/bin:$PATH
17 MANUALS="cpp
18 cppinternals
19 fastjar
20 gcc
21 gccgo
22 gccint
23 gcj
24 gdc
25 gfortran
26 gfc-internals
27 gm2
28 gnat_ugn
29 gnat-style
30 gnat_rm
31 libgomp
32 libitm
33 libquadmath
34 libiberty
35 porting"
37 BUGURL="http://gcc.gnu.org/bugs/"
38 CSS=/texinfo-manuals.css
40 WWWBASE=${WWWBASE:-"/www/gcc/htdocs"}
41 WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted
42 WWWPREPROCESS='/www/gcc/bin/preprocess -r'
44 # Process options -rrelease and -ddirectory
45 RELEASE=""
46 SUBDIR=""
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
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
65 -d*)
66 if [ -n "$SUBDIR" ]; then
67 echo "Multiple subdirectories specified" >&2
68 exit 1
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
81 echo "Unknown argument \"$1\"" >&2
82 exit 1
84 esac
85 shift
86 done
88 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
89 echo "Release specified without subdirectory" >&2
90 exit 1
93 if [ -z "$SUBDIR" ]; then
94 DOCSDIR=$WWWBASE/onlinedocs
95 else
96 DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR
99 if [ ! -d $WWWBASE ]; then
100 echo "WWW base directory \"$WWWBASE\" does not exist." >&2
101 exit 1
104 if [ ! -d $DOCSDIR ]; then
105 mkdir $DOCSDIR
106 chmod g+w $DOCSDIR
109 if [ -z "$RELEASE" ]; then
110 RELEASE=master
113 WORKDIR=/tmp/gcc-doc-update.$$
115 rm -rf $WORKDIR
116 mkdir $WORKDIR
117 cd $WORKDIR
118 if [ "$RELEASE" = "master" ]; then
119 git clone -q $GITROOT gcc
120 else
121 git clone -q -b releases/gcc-$RELEASE $GITROOT gcc
123 rm -rf gcc/.git
125 # Remove all unwanted files. This is needed to avoid packaging all the
126 # sources instead of only documentation sources.
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.
131 find gcc -type f \( -name '*.texi' \
132 -o -path gcc/gcc/doc/install.texi2html \
133 -o -path gcc/gcc/doc/include/texinfo.tex \
134 -o -path gcc/gcc/BASE-VER \
135 -o -path gcc/gcc/DEV-PHASE \
136 -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \
137 -o -path "gcc/gcc/jit/docs/*" \
138 -o -path "gcc/gcc/jit/jit-common.h" \
139 -o -path "gcc/gcc/jit/notes.txt" \
140 -o -print0 \) | xargs -0 rm -f
142 # Build a tarball of the sources.
143 tar cf docs-sources.tar gcc
145 # The directory to pass to -I; this is the one with texinfo.tex
146 # and fdl.texi.
147 includedir=gcc/gcc/doc/include
149 # Generate gcc-vers.texi.
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"
157 echo "@set srcdir $WORKDIR/gcc/gcc"
158 echo "@set VERSION_PACKAGE (GCC)"
159 echo "@set BUGURL @uref{$BUGURL}"
160 ) > $includedir/gcc-vers.texi
162 # Generate libquadmath-vers.texi.
163 echo "@set BUGURL @uref{$BUGURL}" \
164 > $includedir/libquadmath-vers.texi
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
170 includes="-I ${includedir} -I `dirname ${filename}`"
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
175 includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn"
177 makeinfo --html -c CONTENTS_OUTPUT_LOCATION=inline --css-ref $CSS $includes -o ${file} ${filename}
178 tar cf ${file}-html.tar ${file}/*.html
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
181 mkdir -p $DOCSDIR/$file
183 done
185 # The jit is a special-case, using Sphinx rather than texinfo.
186 # Specifically, the jit docs need Sphinx 3.0 or later.
188 # Use the Sphinx installed in a virtual environment so that
189 # we don't depend on a system package.
191 pushd gcc/gcc/jit/docs
192 make html SPHINXBUILD=/home/gccadmin/venv/bin/sphinx-build || true
193 popd
194 cp -a gcc/gcc/jit/docs/_build/html jit
195 mkdir -p $DOCSDIR/jit
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"
208 done
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
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
221 rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz
222 done
225 # And copy the resulting files to the web server
226 for file in */*.html *.ps *.pdf *.tar; do
227 if [ -f $DOCSDIR/$file ]; then
228 cat $DOCSDIR/$file |
229 sed -e '/^<meta name=generator/d' \
230 -e '/^%DVIPSSource:/d' > file1
232 cat $file |
233 sed -e '/^<meta name=generator/d' \
234 -e '/^%DVIPSSource:/d' > file2
235 if cmp -s file1 file2; then
237 else
238 cp $file $DOCSDIR/$file
239 cp $file.gz $DOCSDIR/$file.gz
241 done
243 # Again, the jit is a special case, with nested subdirectories
244 # below "jit", and with some non-HTML files (.png images from us,
245 # plus .css and .js supplied by sphinx, and source files, renamed
246 # from .rst to .txt).
247 find jit \
248 -name "*.html" -o -name "*.png" \
249 -o -name "*.css" -o -name "*.js" \
250 -o -name "*.txt" |
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
258 cd $DOCSDIR
260 # Finally, generate the installation documentation
261 if [ "$RELEASE" = "master" ]; then
262 SOURCEDIR=$WORKDIR/gcc/gcc/doc
263 DESTDIR=$WWWBASE_PREFORMATTED/install
264 export SOURCEDIR
265 export DESTDIR
266 $WORKDIR/gcc/gcc/doc/install.texi2html
268 # Preprocess the entire web site, not just the install docs!
269 echo "Invoking $WWWPREPROCESS"
270 $WWWPREPROCESS |grep -v '^ Warning: Keeping'
273 # Clean up behind us.
275 rm -rf $WORKDIR