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_ug_unx 24 gnat_ug_vms 25 gnat_ug_vxw 26 gnat_ug_wnt 27 gnat_ugn_unw 28 gnat-style 29 gnat_rm 30 libgomp 31 libquadmath 32 libiberty 33 porting" 34 35WWWBASE=/www/gcc/htdocs 36WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted 37WWWPREPROCESS='/www/gcc/bin/preprocess -r' 38 39# Process options -rrelease and -ddirectory 40RELEASE="" 41SUBDIR="" 42 43while [ $# -gt 0 ]; do 44 case $1 in 45 -r*) 46 if [ -n "$RELEASE" ]; then 47 echo "Multiple releases specified" >&2 48 exit 1 49 fi 50 RELEASE="${1#-r}" 51 if [ -z "$RELEASE" ]; then 52 shift 53 RELEASE="$1" 54 if [ -z "$RELEASE" ]; then 55 echo "No release specified with -r" >&2 56 exit 1 57 fi 58 fi 59 ;; 60 -d*) 61 if [ -n "$SUBDIR" ]; then 62 echo "Multiple subdirectories specified" >&2 63 exit 1 64 fi 65 SUBDIR="${1#-d}" 66 if [ -z "$SUBDIR" ]; then 67 shift 68 SUBDIR="$1" 69 if [ -z "$SUBDIR" ]; then 70 echo "No subdirectory specified with -d" >&2 71 exit 1 72 fi 73 fi 74 ;; 75 *) 76 echo "Unknown argument \"$1\"" >&2 77 exit 1 78 ;; 79 esac 80 shift 81done 82 83if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then 84 echo "Release specified without subdirectory" >&2 85 exit 1 86fi 87 88if [ -z "$SUBDIR" ]; then 89 DOCSDIR=$WWWBASE/onlinedocs 90else 91 DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR 92fi 93 94if [ ! -d $DOCSDIR ]; then 95 mkdir $DOCSDIR 96 chmod g+w $DOCSDIR 97fi 98 99if [ -z "$RELEASE" ]; then 100 RELEASE=trunk 101fi 102 103WORKDIR=/tmp/gcc-doc-update.$$ 104 105rm -rf $WORKDIR 106mkdir $WORKDIR 107cd $WORKDIR 108if [ "$RELEASE" = "trunk" ]; then 109 svn -q export $SVNROOT/$RELEASE gcc 110else 111 svn -q export $SVNROOT/tags/$RELEASE gcc 112fi 113 114# Remove all unwanted files. This is needed (a) to build the Ada 115# generator programs with the installed library, not the new one and 116# (b) to avoid packaging all the sources instead of only documentation 117# sources. 118find gcc -type f \( -name '*.texi' \ 119 -o -path gcc/gcc/doc/install.texi2html \ 120 -o -path gcc/gcc/doc/include/texinfo.tex \ 121 -o -path gcc/gcc/ada/xgnatugn.adb \ 122 -o -path gcc/gcc/ada/ug_words \ 123 -o -path gcc/gcc/BASE-VER \ 124 -o -path gcc/gcc/DEV-PHASE \ 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 gnat_ugn_unw 135 136if [ -f gcc/gcc/ada/xgnatugn.adb ]; then 137 gnatmake -q gcc/gcc/ada/xgnatugn 138 ./xgnatugn unw gcc/gcc/ada/gnat_ugn.texi \ 139 gcc/gcc/ada/ug_words gnat_ugn_unw.texi 140fi 141 142# Generate gcc-vers.texi. 143( 144 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)" 145 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then 146 echo "@set DEVELOPMENT" 147 else 148 echo "@clear DEVELOPMENT" 149 fi 150 echo "@set srcdir $WORKDIR/gcc/gcc" 151 echo "@set VERSION_PACKAGE (GCC)" 152 echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" 153) > $includedir/gcc-vers.texi 154 155# Generate libquadmath-vers.texi. 156echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" \ 157 > $includedir/libquadmath-vers.texi 158 159# Now convert the relevant files from texi to HTML, PDF and PostScript. 160for file in $MANUALS; do 161 filename=`find . -name ${file}.texi` 162 if [ "${filename}" ]; then 163 includes="-I ${includedir} -I `dirname ${filename}`" 164 if [ "$file" = "gnat_ugn_unw" ]; then 165 includes="$includes -I gcc/gcc/ada" 166 fi 167 makeinfo --html $includes -o ${file} ${filename} 168 tar cf ${file}-html.tar ${file}/*.html 169 texi2dvi $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi 170 texi2pdf $includes -o ${file}.pdf ${filename} </dev/null 171 mkdir -p $DOCSDIR/$file 172 fi 173done 174 175# Then build a gzipped copy of each of the resulting .html, .ps and .tar files 176for file in */*.html *.ps *.pdf *.tar; do 177 cat $file | gzip --best > $file.gz 178done 179 180# On the 15th of the month, wipe all the old files from the 181# web server. 182today=`date +%d` 183if test $today = 15; then 184 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm 185 for m in $MANUALS; do 186 rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz 187 done 188fi 189 190# And copy the resulting files to the web server 191for file in */*.html *.ps *.pdf *.tar; do 192 if [ -f $DOCSDIR/$file ]; then 193 cat $DOCSDIR/$file | 194 sed -e '/^<meta name=generator/d' \ 195 -e '/^%DVIPSSource:/d' > file1 196 fi 197 cat $file | 198 sed -e '/^<meta name=generator/d' \ 199 -e '/^%DVIPSSource:/d' > file2 200 if cmp -s file1 file2; then 201 : 202 else 203 cp $file $DOCSDIR/$file 204 cp $file.gz $DOCSDIR/$file.gz 205 fi 206done 207 208cd $DOCSDIR 209 210# Finally, generate the installation documentation 211if [ "$RELEASE" = "trunk" ]; then 212 SOURCEDIR=$WORKDIR/gcc/gcc/doc 213 DESTDIR=$WWWBASE_PREFORMATTED/install 214 export SOURCEDIR 215 export DESTDIR 216 $WORKDIR/gcc/gcc/doc/install.texi2html 217 218 # Preprocess the entire web site, not just the install docs! 219 echo "Invoking $WWWPREPROCESS" 220 $WWWPREPROCESS |grep -v '^ Warning: Keeping' 221fi 222 223# Clean up behind us. 224 225rm -rf $WORKDIR 226