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
17 makeinfo_git
=/home
/gccadmin
/texinfo
/install-git
/bin
/
18 if [ -x "${makeinfo_git}"/makeinfo
]; then
19 : "${MAKEINFO:=${makeinfo_git}/makeinfo}"
20 : "${TEXI2DVI:=${makeinfo_git}/texi2dvi}"
21 : "${TEXI2PDF:=${makeinfo_git}/texi2pdf}"
23 : "${MAKEINFO:=makeinfo}"
24 : "${TEXI2DVI:=texi2dvi}"
25 : "${TEXI2PDF:=texi2pdf}"
48 BUGURL
="http://gcc.gnu.org/bugs/"
49 CSS
=/texinfo-manuals.css
51 WWWBASE
=${WWWBASE:-"/www/gcc/htdocs"}
52 WWWBASE_PREFORMATTED
=/www
/gcc
/htdocs-preformatted
53 WWWPREPROCESS
='/www/gcc/bin/preprocess -r'
55 # Process options -rrelease and -ddirectory
59 while [ $# -gt 0 ]; do
62 if [ -n "$RELEASE" ]; then
63 echo "Multiple releases specified" >&2
67 if [ -z "$RELEASE" ]; then
70 if [ -z "$RELEASE" ]; then
71 echo "No release specified with -r" >&2
77 if [ -n "$SUBDIR" ]; then
78 echo "Multiple subdirectories specified" >&2
82 if [ -z "$SUBDIR" ]; then
85 if [ -z "$SUBDIR" ]; then
86 echo "No subdirectory specified with -d" >&2
92 echo "Unknown argument \"$1\"" >&2
99 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
100 echo "Release specified without subdirectory" >&2
104 if [ -z "$SUBDIR" ]; then
105 DOCSDIR
=$WWWBASE/onlinedocs
107 DOCSDIR
=$WWWBASE/onlinedocs
/$SUBDIR
110 if [ ! -d $WWWBASE ]; then
111 echo "WWW base directory \"$WWWBASE\" does not exist." >&2
115 if [ ! -d $DOCSDIR ]; then
120 if [ -z "$RELEASE" ]; then
124 WORKDIR
=/tmp
/gcc-doc-update.$$
129 if [ "$RELEASE" = "master" ]; then
130 git clone
-q $GITROOT gcc
132 git clone
-q -b releases
/gcc-
$RELEASE $GITROOT gcc
136 # Remove all unwanted files. This is needed to avoid packaging all the
137 # sources instead of only documentation sources.
138 # Note that we have to preserve gcc/jit/docs since the jit docs are
139 # not .texi files (Makefile, .rst and .png), and the jit docs use
140 # include directives to pull in content from jit/jit-common.h and
141 # jit/notes.txt, so we have to preserve those also.
142 find gcc
-type f \
( -name '*.texi' \
143 -o -path gcc
/gcc
/doc
/install.texi2html \
144 -o -path gcc
/gcc
/doc
/include
/texinfo.tex \
145 -o -path gcc
/gcc
/BASE-VER \
146 -o -path gcc
/gcc
/DEV-PHASE \
147 -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \
148 -o -path "gcc/gcc/jit/docs/*" \
149 -o -path "gcc/gcc/jit/jit-common.h" \
150 -o -path "gcc/gcc/jit/notes.txt" \
151 -o -print0 \
) |
xargs -0 rm -f
153 # Build a tarball of the sources.
154 tar cf docs-sources.
tar gcc
156 # The directory to pass to -I; this is the one with texinfo.tex
158 includedir
=gcc
/gcc
/doc
/include
160 # Generate gcc-vers.texi.
162 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"
163 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then
164 echo "@set DEVELOPMENT"
166 echo "@clear DEVELOPMENT"
168 echo "@set srcdir $WORKDIR/gcc/gcc"
169 echo "@set VERSION_PACKAGE (GCC)"
170 echo "@set BUGURL @uref{$BUGURL}"
171 ) > $includedir/gcc-vers.texi
173 # Generate libquadmath-vers.texi.
174 echo "@set BUGURL @uref{$BUGURL}" \
175 > $includedir/libquadmath-vers.texi
177 # Now convert the relevant files from texi to HTML, PDF and PostScript.
178 for file in $MANUALS; do
179 filename
=`find . -name ${file}.texi`
180 if [ "${filename}" ]; then
181 includes
="-I ${includedir} -I `dirname ${filename}`"
182 if [ "$file" = "gm2" ]; then
183 includes
="$includes -I gcc/gcc/m2/target-independent"
184 includes
="$includes -I gcc/gcc/m2/target-independent/m2"
185 elif [ "$file" = "gnat_ugn" ]; then
186 includes
="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn"
188 "${MAKEINFO}" --html -c CONTENTS_OUTPUT_LOCATION=inline --css-ref $CSS $includes -o ${file} ${filename}
189 tar cf ${file}-html.tar ${file}/*.html
190 "${TEXI2DVI}" $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi
191 "${TEXI2PDF}" $includes -o ${file}.pdf ${filename} </dev/null
192 mkdir -p $DOCSDIR/$file
196 # The jit is a special-case, using Sphinx rather than texinfo.
197 # Specifically, the jit docs need Sphinx 3.0 or later.
199 # Use the Sphinx installed in a virtual environment so that
200 # we don't depend on a system package.
202 pushd gcc/gcc/jit/docs
203 make html SPHINXBUILD=/home/gccadmin/venv/bin/sphinx-build || true
205 cp -a gcc/gcc/jit/docs/_build/html jit
206 mkdir -p $DOCSDIR/jit
208 # Work around makeinfo generated file names and references with
209 # "_002d
" instead of "-".
210 find . -name '*.html' | while read f; do
211 # Do this for the contents of each file.
212 sed -i -e 's/_002d/-/g' "$f"
213 # And rename files if necessary.
214 ff=`echo $f | sed -e 's/_002d/-/g'`;
215 if [ "$f" != "$ff" ]; then
216 printf "Renaming
%s to
%s
\n" "$f" "$ff"
221 # Then build a gzipped copy of each of the resulting .html, .ps and .tar files
222 for file in */*.html *.ps *.pdf *.tar; do
223 cat $file | gzip --best > $file.gz
226 # On the 15th of the month, wipe all the old files from the
229 if test $today = 15; then
230 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
231 for m in $MANUALS; do
232 rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz
236 # And copy the resulting files to the web server
237 for file in */*.html *.ps *.pdf *.tar; do
238 if [ -f $DOCSDIR/$file ]; then
240 sed -e '/^<meta name=generator/d' \
241 -e '/^%DVIPSSource:/d' > file1
244 sed -e '/^<meta name=generator/d' \
245 -e '/^%DVIPSSource:/d' > file2
246 if cmp -s file1 file2; then
249 cp $file $DOCSDIR/$file
250 cp $file.gz $DOCSDIR/$file.gz
254 # Again, the jit is a special case, with nested subdirectories
255 # below "jit
", and with some non-HTML files (.png images from us,
256 # plus .css and .js supplied by sphinx, and source files, renamed
257 # from .rst to .txt).
259 -name "*.html
" -o -name "*.png
" \
260 -o -name "*.css
" -o -name "*.js
" \
263 # Note that $file here will contain path fragments beginning
264 # with "jit
/", e.g. "jit
/cp
/topics
/functions.html
"
265 mkdir -p $(dirname $DOCSDIR/$file)
266 cp $file $DOCSDIR/$file
271 # Finally, generate the installation documentation
272 if [ "$RELEASE" = "master
" ]; then
273 SOURCEDIR=$WORKDIR/gcc/gcc/doc
274 DESTDIR=$WWWBASE_PREFORMATTED/install
277 $WORKDIR/gcc/gcc/doc/install.texi2html
279 # Preprocess the entire web site, not just the install docs!
280 echo "Invoking
$WWWPREPROCESS"
281 $WWWPREPROCESS |grep -v '^ Warning: Keeping'
284 # Clean up behind us.