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
12 GITROOT
=${GITROOT:-"/git/gcc.git"}
15 PATH
=/usr
/local
/bin
:$PATH
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
46 while [ $# -gt 0 ]; do
49 if [ -n "$RELEASE" ]; then
50 echo "Multiple releases specified" >&2
54 if [ -z "$RELEASE" ]; then
57 if [ -z "$RELEASE" ]; then
58 echo "No release specified with -r" >&2
64 if [ -n "$SUBDIR" ]; then
65 echo "Multiple subdirectories specified" >&2
69 if [ -z "$SUBDIR" ]; then
72 if [ -z "$SUBDIR" ]; then
73 echo "No subdirectory specified with -d" >&2
79 echo "Unknown argument \"$1\"" >&2
86 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
87 echo "Release specified without subdirectory" >&2
91 if [ -z "$SUBDIR" ]; then
92 DOCSDIR
=$WWWBASE/onlinedocs
94 DOCSDIR
=$WWWBASE/onlinedocs
/$SUBDIR
97 if [ ! -d $WWWBASE ]; then
98 echo "WWW base directory \"$WWWBASE\" does not exist." >&2
102 if [ ! -d $DOCSDIR ]; then
107 if [ -z "$RELEASE" ]; then
111 WORKDIR
=/tmp
/gcc-doc-update.$$
116 if [ "$RELEASE" = "master" ]; then
117 git clone
-q $GITROOT gcc
119 git clone
-q -b releases
/gcc-
$RELEASE $GITROOT gcc
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
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"
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
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
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"
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
210 # On the 15th of the month, wipe all the old files from the
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
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
224 sed -e '/^<meta name=generator/d' \
225 -e '/^%DVIPSSource:/d' > file1
228 sed -e '/^<meta name=generator/d' \
229 -e '/^%DVIPSSource:/d' > file2
230 if cmp -s file1 file2
; then
233 cp $file $DOCSDIR/$file
234 cp $file.gz
$DOCSDIR/$file.gz
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).
243 -name "*.html" -o -name "*.png" \
244 -o -name "*.css" -o -name "*.js" \
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
255 # Finally, generate the installation documentation
256 if [ "$RELEASE" = "master" ]; then
257 SOURCEDIR
=$WORKDIR/gcc
/gcc
/doc
258 DESTDIR
=$WWWBASE_PREFORMATTED/install
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.