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