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
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
48 while [ $# -gt 0 ]; do
51 if [ -n "$RELEASE" ]; then
52 echo "Multiple releases specified" >&2
56 if [ -z "$RELEASE" ]; then
59 if [ -z "$RELEASE" ]; then
60 echo "No release specified with -r" >&2
66 if [ -n "$SUBDIR" ]; then
67 echo "Multiple subdirectories specified" >&2
71 if [ -z "$SUBDIR" ]; then
74 if [ -z "$SUBDIR" ]; then
75 echo "No subdirectory specified with -d" >&2
81 echo "Unknown argument \"$1\"" >&2
88 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
89 echo "Release specified without subdirectory" >&2
93 if [ -z "$SUBDIR" ]; then
94 DOCSDIR
=$WWWBASE/onlinedocs
96 DOCSDIR
=$WWWBASE/onlinedocs
/$SUBDIR
99 if [ ! -d $WWWBASE ]; then
100 echo "WWW base directory \"$WWWBASE\" does not exist." >&2
104 if [ ! -d $DOCSDIR ]; then
109 if [ -z "$RELEASE" ]; then
113 WORKDIR
=/tmp
/gcc-doc-update.$$
118 if [ "$RELEASE" = "master" ]; then
119 git clone
-q $GITROOT gcc
121 git clone
-q -b releases
/gcc-
$RELEASE $GITROOT gcc
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
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"
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
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
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"
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
215 # On the 15th of the month, wipe all the old files from the
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
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
229 sed -e '/^<meta name=generator/d' \
230 -e '/^%DVIPSSource:/d' > file1
233 sed -e '/^<meta name=generator/d' \
234 -e '/^%DVIPSSource:/d' > file2
235 if cmp -s file1 file2
; then
238 cp $file $DOCSDIR/$file
239 cp $file.gz
$DOCSDIR/$file.gz
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).
248 -name "*.html" -o -name "*.png" \
249 -o -name "*.css" -o -name "*.js" \
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
260 # Finally, generate the installation documentation
261 if [ "$RELEASE" = "master" ]; then
262 SOURCEDIR
=$WORKDIR/gcc
/gcc
/doc
263 DESTDIR
=$WWWBASE_PREFORMATTED/install
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.