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