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 WWWBASE
=${WWWBASE:-"/www/gcc/htdocs"}
38 WWWBASE_PREFORMATTED
=/www
/gcc
/htdocs-preformatted
39 WWWPREPROCESS
='/www/gcc/bin/preprocess -r'
41 # Process options -rrelease and -ddirectory
45 while [ $# -gt 0 ]; do
48 if [ -n "$RELEASE" ]; then
49 echo "Multiple releases specified" >&2
53 if [ -z "$RELEASE" ]; then
56 if [ -z "$RELEASE" ]; then
57 echo "No release specified with -r" >&2
63 if [ -n "$SUBDIR" ]; then
64 echo "Multiple subdirectories specified" >&2
68 if [ -z "$SUBDIR" ]; then
71 if [ -z "$SUBDIR" ]; then
72 echo "No subdirectory specified with -d" >&2
78 echo "Unknown argument \"$1\"" >&2
85 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
86 echo "Release specified without subdirectory" >&2
90 if [ -z "$SUBDIR" ]; then
91 DOCSDIR
=$WWWBASE/onlinedocs
93 DOCSDIR
=$WWWBASE/onlinedocs
/$SUBDIR
96 if [ ! -d $WWWBASE ]; then
97 echo "WWW base directory \"$WWWBASE\" does not exist." >&2
101 if [ ! -d $DOCSDIR ]; then
106 if [ -z "$RELEASE" ]; then
110 WORKDIR
=/tmp
/gcc-doc-update.$$
115 if [ "$RELEASE" = "master" ]; then
116 git clone
-q $GITROOT gcc
118 git clone
-q -b releases
/gcc-
$RELEASE $GITROOT gcc
122 # Remove all unwanted files. This is needed to avoid packaging all the
123 # sources instead of only documentation sources.
124 # Note that we have to preserve gcc/jit/docs since the jit docs are
125 # not .texi files (Makefile, .rst and .png), and the jit docs use
126 # include directives to pull in content from jit/jit-common.h and
127 # jit/notes.txt, so we have to preserve those also.
128 find gcc
-type f \
( -name '*.texi' \
129 -o -path gcc
/gcc
/doc
/install.texi2html \
130 -o -path gcc
/gcc
/doc
/include
/texinfo.tex \
131 -o -path gcc
/gcc
/BASE-VER \
132 -o -path gcc
/gcc
/DEV-PHASE \
133 -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \
134 -o -path "gcc/gcc/jit/docs/*" \
135 -o -path "gcc/gcc/jit/jit-common.h" \
136 -o -path "gcc/gcc/jit/notes.txt" \
137 -o -print0 \
) |
xargs -0 rm -f
139 # Build a tarball of the sources.
140 tar cf docs-sources.
tar gcc
142 # The directory to pass to -I; this is the one with texinfo.tex
144 includedir
=gcc
/gcc
/doc
/include
146 # Generate gcc-vers.texi.
148 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"
149 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then
150 echo "@set DEVELOPMENT"
152 echo "@clear DEVELOPMENT"
154 echo "@set srcdir $WORKDIR/gcc/gcc"
155 echo "@set VERSION_PACKAGE (GCC)"
156 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}"
157 ) > $includedir/gcc-vers.texi
159 # Generate libquadmath-vers.texi.
160 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" \
161 > $includedir/libquadmath-vers.texi
163 # Now convert the relevant files from texi to HTML, PDF and PostScript.
164 for file in $MANUALS; do
165 filename
=`find . -name ${file}.texi`
166 if [ "${filename}" ]; then
167 includes
="-I ${includedir} -I `dirname ${filename}`"
168 if [ "$file" = "gnat_ugn" ]; then
169 includes
="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn"
171 makeinfo
--html --css-ref $CSS $includes -o ${file} ${filename}
172 tar cf
${file}-html.
tar ${file}/*.html
173 texi2dvi
$includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi
174 texi2pdf
$includes -o ${file}.pdf
${filename} </dev
/null
175 mkdir
-p $DOCSDIR/$file
179 # The jit is a special-case, using sphinx rather than texinfo.
180 # Specifically, the jit docs need sphinx 1.0 or later.
182 # The jit/docs Makefile uses the executable $(SPHINXBUILD),
183 # defaulting to "sphinx-build".
185 # sphinx is packaged in Fedora and EPEL 6 within "python-sphinx",
186 # and in openSUSE within "python-Sphinx".
188 # For EPEL6, python-sphinx is sphinx 0.6.6, which is missing various
189 # directives (e.g. ":c:macro:"), so we need the variant
190 # python-sphinx10 package. The latter installs its executable as
191 # /usr/bin/sphinx-1.0-build
192 # so we need to override SPHINXBUILD with this when invoking "make".
193 pushd gcc
/gcc
/jit
/docs
194 make SPHINXBUILD
=/usr
/bin
/sphinx-1.0
-build html || true
196 cp -a gcc
/gcc
/jit
/docs
/_build
/html jit
197 mkdir
-p $DOCSDIR/jit
199 # Work around makeinfo generated file names and references with
200 # "_002d" instead of "-".
201 find .
-name '*.html' |
while read f
; do
202 # Do this for the contents of each file.
203 sed -i -e 's/_002d/-/g' "$f"
204 # And rename files if necessary.
205 ff
=`echo $f | sed -e 's/_002d/-/g'`;
206 if [ "$f" != "$ff" ]; then
207 printf "Renaming %s to %s\n" "$f" "$ff"
212 # Then build a gzipped copy of each of the resulting .html, .ps and .tar files
213 for file in */*.html
*.ps
*.pdf
*.
tar; do
214 cat $file |
gzip --best > $file.gz
217 # On the 15th of the month, wipe all the old files from the
220 if test $today = 15; then
221 find $DOCSDIR -type f
-maxdepth 1 -print |
grep -v index.html |
xargs rm
222 for m
in $MANUALS; do
223 rm -f $DOCSDIR/$m/*.html
$DOCSDIR/$m/*.html.gz
227 # And copy the resulting files to the web server
228 for file in */*.html
*.ps
*.pdf
*.
tar; do
229 if [ -f $DOCSDIR/$file ]; then
231 sed -e '/^<meta name=generator/d' \
232 -e '/^%DVIPSSource:/d' > file1
235 sed -e '/^<meta name=generator/d' \
236 -e '/^%DVIPSSource:/d' > file2
237 if cmp -s file1 file2
; then
240 cp $file $DOCSDIR/$file
241 cp $file.gz
$DOCSDIR/$file.gz
245 # Again, the jit is a special case, with nested subdirectories
246 # below "jit", and with some non-HTML files (.png images from us,
247 # plus .css and .js supplied by sphinx, and source files, renamed
248 # from .rst to .txt).
250 -name "*.html" -o -name "*.png" \
251 -o -name "*.css" -o -name "*.js" \
254 # Note that $file here will contain path fragments beginning
255 # with "jit/", e.g. "jit/cp/topics/functions.html"
256 mkdir
-p $
(dirname $DOCSDIR/$file)
257 cp $file $DOCSDIR/$file
262 # Finally, generate the installation documentation
263 if [ "$RELEASE" = "master" ]; then
264 SOURCEDIR
=$WORKDIR/gcc
/gcc
/doc
265 DESTDIR
=$WWWBASE_PREFORMATTED/install
268 $WORKDIR/gcc
/gcc
/doc
/install.texi2html
270 # Preprocess the entire web site, not just the install docs!
271 echo "Invoking $WWWPREPROCESS"
272 $WWWPREPROCESS |
grep -v '^ Warning: Keeping'
275 # Clean up behind us.