1#!/bin/sh 2 3# Generate HTML documentation from GCC Texinfo docs. 4# This version is for GCC 3.1 and later versions. 5 6set -e 7 8# Run this from /tmp. 9SVNROOT=${SVNROOT:-"file:///svn/gcc"} 10export SVNROOT 11 12PATH=/usr/local/bin:$PATH 13 14MANUALS="cpp 15 cppinternals 16 fastjar 17 gcc 18 gccgo 19 gccint 20 gcj 21 gfortran 22 gfc-internals 23 gnat_ugn 24 gnat-style 25 gnat_rm 26 libgomp 27 libquadmath 28 libiberty 29 porting" 30 31WWWBASE=/www/gcc/htdocs 32WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted 33WWWPREPROCESS='/www/gcc/bin/preprocess -r' 34 35# Process options -rrelease and -ddirectory 36RELEASE="" 37SUBDIR="" 38 39while [ $# -gt 0 ]; do 40 case $1 in 41 -r*) 42 if [ -n "$RELEASE" ]; then 43 echo "Multiple releases specified" >&2 44 exit 1 45 fi 46 RELEASE="${1#-r}" 47 if [ -z "$RELEASE" ]; then 48 shift 49 RELEASE="$1" 50 if [ -z "$RELEASE" ]; then 51 echo "No release specified with -r" >&2 52 exit 1 53 fi 54 fi 55 ;; 56 -d*) 57 if [ -n "$SUBDIR" ]; then 58 echo "Multiple subdirectories specified" >&2 59 exit 1 60 fi 61 SUBDIR="${1#-d}" 62 if [ -z "$SUBDIR" ]; then 63 shift 64 SUBDIR="$1" 65 if [ -z "$SUBDIR" ]; then 66 echo "No subdirectory specified with -d" >&2 67 exit 1 68 fi 69 fi 70 ;; 71 *) 72 echo "Unknown argument \"$1\"" >&2 73 exit 1 74 ;; 75 esac 76 shift 77done 78 79if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then 80 echo "Release specified without subdirectory" >&2 81 exit 1 82fi 83 84if [ -z "$SUBDIR" ]; then 85 DOCSDIR=$WWWBASE/onlinedocs 86else 87 DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR 88fi 89 90if [ ! -d $DOCSDIR ]; then 91 mkdir $DOCSDIR 92 chmod g+w $DOCSDIR 93fi 94 95if [ -z "$RELEASE" ]; then 96 RELEASE=trunk 97fi 98 99WORKDIR=/tmp/gcc-doc-update.$$ 100 101rm -rf $WORKDIR 102mkdir $WORKDIR 103cd $WORKDIR 104if [ "$RELEASE" = "trunk" ]; then 105 svn -q export $SVNROOT/$RELEASE gcc 106else 107 svn -q export $SVNROOT/tags/$RELEASE gcc 108fi 109 110# Remove all unwanted files. This is needed to avoid packaging all the 111# sources instead of only documentation sources. 112# Note that we have to preserve gcc/jit/docs since the jit docs are 113# not .texi files (Makefile, .rst and .png), and the jit docs use 114# include directives to pull in content from jit/jit-common.h and 115# jit/notes.txt, so we have to preserve those also. 116find gcc -type f \( -name '*.texi' \ 117 -o -path gcc/gcc/doc/install.texi2html \ 118 -o -path gcc/gcc/doc/include/texinfo.tex \ 119 -o -path gcc/gcc/BASE-VER \ 120 -o -path gcc/gcc/DEV-PHASE \ 121 -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \ 122 -o -path "gcc/gcc/jit/docs/*" \ 123 -o -path "gcc/gcc/jit/jit-common.h" \ 124 -o -path "gcc/gcc/jit/notes.txt" \ 125 -o -print0 \) | xargs -0 rm -f 126 127# Build a tarball of the sources. 128tar cf docs-sources.tar gcc 129 130# The directory to pass to -I; this is the one with texinfo.tex 131# and fdl.texi. 132includedir=gcc/gcc/doc/include 133 134# Generate gcc-vers.texi. 135( 136 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)" 137 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then 138 echo "@set DEVELOPMENT" 139 else 140 echo "@clear DEVELOPMENT" 141 fi 142 echo "@set srcdir $WORKDIR/gcc/gcc" 143 echo "@set VERSION_PACKAGE (GCC)" 144 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" 145) > $includedir/gcc-vers.texi 146 147# Generate libquadmath-vers.texi. 148echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" \ 149 > $includedir/libquadmath-vers.texi 150 151# Now convert the relevant files from texi to HTML, PDF and PostScript. 152for file in $MANUALS; do 153 filename=`find . -name ${file}.texi` 154 if [ "${filename}" ]; then 155 includes="-I ${includedir} -I `dirname ${filename}`" 156 if [ "$file" = "gnat_ugn" ]; then 157 includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn" 158 fi 159 makeinfo --html $includes -o ${file} ${filename} 160 tar cf ${file}-html.tar ${file}/*.html 161 texi2dvi $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi 162 texi2pdf $includes -o ${file}.pdf ${filename} </dev/null 163 mkdir -p $DOCSDIR/$file 164 fi 165done 166 167# The jit is a special-case, using sphinx rather than texinfo. 168# Specifically, the jit docs need sphinx 1.0 or later. 169# 170# The jit/docs Makefile uses the executable $(SPHINXBUILD), 171# defaulting to "sphinx-build". 172# 173# sphinx is packaged in Fedora and EPEL 6 within "python-sphinx", 174# and in openSUSE within "python-Sphinx". 175# 176# For EPEL6, python-sphinx is sphinx 0.6.6, which is missing various 177# directives (e.g. ":c:macro:"), so we need the variant 178# python-sphinx10 package. The latter installs its executable as 179# /usr/bin/sphinx-1.0-build 180# so we need to override SPHINXBUILD with this when invoking "make". 181pushd gcc/gcc/jit/docs 182make SPHINXBUILD=/usr/bin/sphinx-1.0-build html 183popd 184cp -a gcc/gcc/jit/docs/_build/html jit 185mkdir -p $DOCSDIR/jit 186 187# Work around makeinfo generated file names and references with 188# "_002d" instead of "-". 189find . -name '*.html' | while read f; do 190 # Do this for the contents of each file. 191 sed -i -e 's/_002d/-/g' "$f" 192 # And rename files if necessary. 193 ff=`echo $f | sed -e 's/_002d/-/g'`; 194 if [ "$f" != "$ff" ]; then 195 printf "Renaming %s to %s\n" "$f" "$ff" 196 mv "$f" "$ff" 197 fi 198done 199 200# Then build a gzipped copy of each of the resulting .html, .ps and .tar files 201for file in */*.html *.ps *.pdf *.tar; do 202 cat $file | gzip --best > $file.gz 203done 204 205# On the 15th of the month, wipe all the old files from the 206# web server. 207today=`date +%d` 208if test $today = 15; then 209 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm 210 for m in $MANUALS; do 211 rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz 212 done 213fi 214 215# And copy the resulting files to the web server 216for file in */*.html *.ps *.pdf *.tar; do 217 if [ -f $DOCSDIR/$file ]; then 218 cat $DOCSDIR/$file | 219 sed -e '/^<meta name=generator/d' \ 220 -e '/^%DVIPSSource:/d' > file1 221 fi 222 cat $file | 223 sed -e '/^<meta name=generator/d' \ 224 -e '/^%DVIPSSource:/d' > file2 225 if cmp -s file1 file2; then 226 : 227 else 228 cp $file $DOCSDIR/$file 229 cp $file.gz $DOCSDIR/$file.gz 230 fi 231done 232 233# Again, the jit is a special case, with nested subdirectories 234# below "jit", and with some non-HTML files (.png images from us, 235# plus .css and .js supplied by sphinx, and source files, renamed 236# from .rst to .txt). 237find jit \ 238 -name "*.html" -o -name "*.png" \ 239 -o -name "*.css" -o -name "*.js" \ 240 -o -name "*.txt" | 241 while read file ; do 242 # Note that $file here will contain path fragments beginning 243 # with "jit/", e.g. "jit/cp/topics/functions.html" 244 mkdir -p $(dirname $DOCSDIR/$file) 245 cp $file $DOCSDIR/$file 246 done 247 248cd $DOCSDIR 249 250# Finally, generate the installation documentation 251if [ "$RELEASE" = "trunk" ]; then 252 SOURCEDIR=$WORKDIR/gcc/gcc/doc 253 DESTDIR=$WWWBASE_PREFORMATTED/install 254 export SOURCEDIR 255 export DESTDIR 256 $WORKDIR/gcc/gcc/doc/install.texi2html 257 258 # Preprocess the entire web site, not just the install docs! 259 echo "Invoking $WWWPREPROCESS" 260 $WWWPREPROCESS |grep -v '^ Warning: Keeping' 261fi 262 263# Clean up behind us. 264 265rm -rf $WORKDIR 266