#!/bin/sh -x# Generate HTML documentation from GCC Texinfo docs.# This version is for GCC 3.1 and later versions.# Run this from /tmp.CVSROOT=/cvs/gccexport CVSROOTPATH=/usr/local/bin:$PATHWWWBASE=/www/gcc/htdocsWWWBASE_PREFORMATTED=/www/gcc/htdocs-preformattedWWWPREPROCESS='/www/gcc/bin/preprocess -r'# Process options -rrelease and -ddirectoryRELEASE=""SUBDIR=""while [ $# -gt 0 ]; docase $1 in-r*)if [ -n "$RELEASE" ]; thenecho "Multiple releases specified" >&2exit 1fiRELEASE="${1#-r}"if [ -z "$RELEASE" ]; thenshiftRELEASE="$1"if [ -z "$RELEASE" ]; thenecho "No release specified with -r" >&2exit 1fifi;;-d*)if [ -n "$SUBDIR" ]; thenecho "Multiple subdirectories specified" >&2exit 1fiSUBDIR="${1#-d}"if [ -z "$SUBDIR" ]; thenshiftSUBDIR="$1"if [ -z "$SUBDIR" ]; thenecho "No subdirectory specified with -d" >&2exit 1fifi;;*)echo "Unknown argument \"$1\"" >&2exit 1;;esacshiftdoneif [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; thenecho "Release specified without subdirectory" >&2exit 1fiif [ -z "$SUBDIR" ]; thenDOCSDIR=$WWWBASE/onlinedocselseDOCSDIR=$WWWBASE/onlinedocs/$SUBDIRfiif [ ! -d $DOCSDIR ]; thenmkdir $DOCSDIRfiif [ -z "$RELEASE" ]; thenRELEASE=HEADfiWORKDIR=/tmp/gcc-doc-update.$$/bin/rm -rf $WORKDIR/bin/mkdir $WORKDIRcd $WORKDIR# Find all the texi files in the repository, except those in directories# we do not care about (texinfo, etc).find $CVSROOT/gcc -name \*.texi,v -print | fgrep -v -f/home/gccadmin/scripts/doc_exclude | sed -e s#$CVSROOT/##g -e s#,v##g -e s#Attic/##g > FILES# Checkout all the texi files.cvs -Q export -r$RELEASE `cat FILES` gcc/gcc/doc/install.texi2html gcc/gcc/doc/include/texinfo.tex gcc/gcc/ada/xgnatugn.adb gcc/gcc/ada/ug_words gcc/gcc/BASE-VER gcc/gcc/DEV-PHASE# Build a tarball of the sources.tar cf docs-sources.tar gcc# The directory to pass to -I; this is the one with texinfo.tex# and fdl.texi.includedir=gcc/gcc/doc/includeMANUALS="cpp cppinternals fastjar gcc gccint gcj g77 gfortran gnat_ug_unx gnat_ug_vms gnat_ug_vxw gnat_ug_wnt gnat_ugn_unw gnat-style gnat_rm libiberty porting"# Generate gnat_ugn_unwif [ -f gcc/gcc/ada/xgnatugn.adb ]; thengnatmake -q gcc/gcc/ada/xgnatugn./xgnatugn unw gcc/gcc/ada/gnat_ugn.texi \gcc/gcc/ada/ug_words gnat_ugn_unw.texifi# Generate gcc-vers.texi.(echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; thenecho "@set DEVELOPMENT"elseecho "@clear DEVELOPMENT"fi) > $includedir/gcc-vers.texi# Now convert the relevant files from texi to HTML, PDF and PostScript.for file in $MANUALS; dofilename=`find . -name ${file}.texi`if [ "${filename}" ]; thenmakeinfo --html -I ${includedir} -I `dirname ${filename}` ${filename}tar cf ${file}-html.tar ${file}/*.htmltexi2dvi -I ${includedir} ${filename} </dev/null && dvips -o ${file}.ps ${file}.dvitexi2pdf -I ${includedir} ${filename} </dev/nullmkdir -p $DOCSDIR/$filefidone# Then build a gzipped copy of each of the resulting .html, .ps and .tar filesfor file in */*.html *.ps *.pdf *.tar; docat $file | gzip --best > $file.gzdone# On the 15th of the month, wipe all the old files from the# web server.today=`date +%d`if test $today = 15; thenfind $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rmfor m in $MANUALS; dorm $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gzdonefi# And copy the resulting files to the web serverfor file in */*.html *.ps *.pdf *.tar; docat $DOCSDIR/$file |sed -e '/^<meta name=generator/d' \-e '/^%DVIPSSource:/d' > file1cat $file |sed -e '/^<meta name=generator/d' \-e '/^%DVIPSSource:/d' > file2if cmp -s file1 file2; then:elsecp $file $DOCSDIR/$filecp $file.gz $DOCSDIR/$file.gzfidonecd $DOCSDIR# Finally, generate the installation documentation (but only for CVS HEAD).if [ "$RELEASE" = "HEAD" ]; thenSOURCEDIR=$WORKDIR/gcc/gcc/docDESTDIR=$WWWBASE_PREFORMATTED/installexport SOURCEDIRexport DESTDIR$WORKDIR/gcc/gcc/doc/install.texi2html# Preprocess the entire web site, not just the install docs!echo "Invoking $WWWPREPROCESS"$WWWPREPROCESS |grep -v '^ Warning: Keeping'fi# Clean up behind us.rm -rf $WORKDIR