Suppress -fstack-protector warning on hppa.
[official-gcc.git] / maintainer-scripts / update_web_docs_git
blobdee9b1d3b5ee5ce0b018849fb983cf4a45184e46
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 gnat_ugn
28 gnat-style
29 gnat_rm
30 libgomp
31 libitm
32 libquadmath
33 libiberty
34 porting"
36 CSS=/gcc.css
38 WWWBASE=${WWWBASE:-"/www/gcc/htdocs"}
39 WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted
40 WWWPREPROCESS='/www/gcc/bin/preprocess -r'
42 # Process options -rrelease and -ddirectory
43 RELEASE=""
44 SUBDIR=""
46 while [ $# -gt 0 ]; do
47 case $1 in
48 -r*)
49 if [ -n "$RELEASE" ]; then
50 echo "Multiple releases specified" >&2
51 exit 1
53 RELEASE="${1#-r}"
54 if [ -z "$RELEASE" ]; then
55 shift
56 RELEASE="$1"
57 if [ -z "$RELEASE" ]; then
58 echo "No release specified with -r" >&2
59 exit 1
63 -d*)
64 if [ -n "$SUBDIR" ]; then
65 echo "Multiple subdirectories specified" >&2
66 exit 1
68 SUBDIR="${1#-d}"
69 if [ -z "$SUBDIR" ]; then
70 shift
71 SUBDIR="$1"
72 if [ -z "$SUBDIR" ]; then
73 echo "No subdirectory specified with -d" >&2
74 exit 1
79 echo "Unknown argument \"$1\"" >&2
80 exit 1
82 esac
83 shift
84 done
86 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
87 echo "Release specified without subdirectory" >&2
88 exit 1
91 if [ -z "$SUBDIR" ]; then
92 DOCSDIR=$WWWBASE/onlinedocs
93 else
94 DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR
97 if [ ! -d $WWWBASE ]; then
98 echo "WWW base directory \"$WWWBASE\" does not exist." >&2
99 exit 1
102 if [ ! -d $DOCSDIR ]; then
103 mkdir $DOCSDIR
104 chmod g+w $DOCSDIR
107 if [ -z "$RELEASE" ]; then
108 RELEASE=master
111 WORKDIR=/tmp/gcc-doc-update.$$
113 rm -rf $WORKDIR
114 mkdir $WORKDIR
115 cd $WORKDIR
116 if [ "$RELEASE" = "master" ]; then
117 git clone -q $GITROOT gcc
118 else
119 git clone -q -b releases/gcc-$RELEASE $GITROOT gcc
121 rm -rf gcc/.git
123 # Remove all unwanted files. This is needed to avoid packaging all the
124 # sources instead of only documentation sources.
125 # Note that we have to preserve gcc/jit/docs since the jit docs are
126 # not .texi files (Makefile, .rst and .png), and the jit docs use
127 # include directives to pull in content from jit/jit-common.h and
128 # jit/notes.txt, so we have to preserve those also.
129 find gcc -type f \( -name '*.texi' \
130 -o -path gcc/gcc/doc/install.texi2html \
131 -o -path gcc/gcc/doc/include/texinfo.tex \
132 -o -path gcc/gcc/BASE-VER \
133 -o -path gcc/gcc/DEV-PHASE \
134 -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \
135 -o -path "gcc/gcc/jit/docs/*" \
136 -o -path "gcc/gcc/jit/jit-common.h" \
137 -o -path "gcc/gcc/jit/notes.txt" \
138 -o -print0 \) | xargs -0 rm -f
140 # Build a tarball of the sources.
141 tar cf docs-sources.tar gcc
143 # The directory to pass to -I; this is the one with texinfo.tex
144 # and fdl.texi.
145 includedir=gcc/gcc/doc/include
147 # Generate gcc-vers.texi.
149 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"
150 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then
151 echo "@set DEVELOPMENT"
152 else
153 echo "@clear DEVELOPMENT"
155 echo "@set srcdir $WORKDIR/gcc/gcc"
156 echo "@set VERSION_PACKAGE (GCC)"
157 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}"
158 ) > $includedir/gcc-vers.texi
160 # Generate libquadmath-vers.texi.
161 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" \
162 > $includedir/libquadmath-vers.texi
164 # Now convert the relevant files from texi to HTML, PDF and PostScript.
165 for file in $MANUALS; do
166 filename=`find . -name ${file}.texi`
167 if [ "${filename}" ]; then
168 includes="-I ${includedir} -I `dirname ${filename}`"
169 if [ "$file" = "gnat_ugn" ]; then
170 includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn"
172 makeinfo --html --css-ref $CSS $includes -o ${file} ${filename}
173 tar cf ${file}-html.tar ${file}/*.html
174 texi2dvi $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi
175 texi2pdf $includes -o ${file}.pdf ${filename} </dev/null
176 mkdir -p $DOCSDIR/$file
178 done
180 # The jit is a special-case, using Sphinx rather than texinfo.
181 # Specifically, the jit docs need Sphinx 3.0 or later.
183 # Use the Sphinx installed in a virtual environment so that
184 # we don't depend on a system package.
186 pushd gcc/gcc/jit/docs
187 make html SPHINXBUILD=/home/gccadmin/venv/bin/sphinx-build || true
188 popd
189 cp -a gcc/gcc/jit/docs/_build/html jit
190 mkdir -p $DOCSDIR/jit
192 # Work around makeinfo generated file names and references with
193 # "_002d" instead of "-".
194 find . -name '*.html' | while read f; do
195 # Do this for the contents of each file.
196 sed -i -e 's/_002d/-/g' "$f"
197 # And rename files if necessary.
198 ff=`echo $f | sed -e 's/_002d/-/g'`;
199 if [ "$f" != "$ff" ]; then
200 printf "Renaming %s to %s\n" "$f" "$ff"
201 mv "$f" "$ff"
203 done
205 # Then build a gzipped copy of each of the resulting .html, .ps and .tar files
206 for file in */*.html *.ps *.pdf *.tar; do
207 cat $file | gzip --best > $file.gz
208 done
210 # On the 15th of the month, wipe all the old files from the
211 # web server.
212 today=`date +%d`
213 if test $today = 15; then
214 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
215 for m in $MANUALS; do
216 rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz
217 done
220 # And copy the resulting files to the web server
221 for file in */*.html *.ps *.pdf *.tar; do
222 if [ -f $DOCSDIR/$file ]; then
223 cat $DOCSDIR/$file |
224 sed -e '/^<meta name=generator/d' \
225 -e '/^%DVIPSSource:/d' > file1
227 cat $file |
228 sed -e '/^<meta name=generator/d' \
229 -e '/^%DVIPSSource:/d' > file2
230 if cmp -s file1 file2; then
232 else
233 cp $file $DOCSDIR/$file
234 cp $file.gz $DOCSDIR/$file.gz
236 done
238 # Again, the jit is a special case, with nested subdirectories
239 # below "jit", and with some non-HTML files (.png images from us,
240 # plus .css and .js supplied by sphinx, and source files, renamed
241 # from .rst to .txt).
242 find jit \
243 -name "*.html" -o -name "*.png" \
244 -o -name "*.css" -o -name "*.js" \
245 -o -name "*.txt" |
246 while read file ; do
247 # Note that $file here will contain path fragments beginning
248 # with "jit/", e.g. "jit/cp/topics/functions.html"
249 mkdir -p $(dirname $DOCSDIR/$file)
250 cp $file $DOCSDIR/$file
251 done
253 cd $DOCSDIR
255 # Finally, generate the installation documentation
256 if [ "$RELEASE" = "master" ]; then
257 SOURCEDIR=$WORKDIR/gcc/gcc/doc
258 DESTDIR=$WWWBASE_PREFORMATTED/install
259 export SOURCEDIR
260 export DESTDIR
261 $WORKDIR/gcc/gcc/doc/install.texi2html
263 # Preprocess the entire web site, not just the install docs!
264 echo "Invoking $WWWPREPROCESS"
265 $WWWPREPROCESS |grep -v '^ Warning: Keeping'
268 # Clean up behind us.
270 rm -rf $WORKDIR