1 1.1 mrg #!/bin/sh 2 1.1 mrg 3 1.1 mrg # Generate HTML documentation from GCC Texinfo docs. 4 1.1 mrg # 5 1.1 mrg # If you want to run this on a machine different from gcc.gnu.org, you 6 1.1 mrg # may need to adjust GITROOT and WWWBASE below (or override them via the 7 1.1 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 GITROOT=${GITROOT:-"/git/gcc.git"} 13 1.1 mrg export GITROOT 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.1 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.1 mrg gnat_ugn 27 1.1 mrg gnat-style 28 1.1 mrg gnat_rm 29 1.1 mrg libgomp 30 1.1 mrg libitm 31 1.1 mrg libquadmath 32 1.1 mrg libiberty 33 1.1 mrg porting" 34 1.1 mrg 35 1.1 mrg CSS=/gcc.css 36 1.1 mrg 37 1.1 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.1 mrg if [ ! -d $WWWBASE ]; then 97 1.1 mrg echo "WWW base directory \"$WWWBASE\" does not exist." >&2 98 1.1 mrg exit 1 99 1.1 mrg fi 100 1.1 mrg 101 1.1 mrg if [ ! -d $DOCSDIR ]; then 102 1.1 mrg mkdir $DOCSDIR 103 1.1 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=master 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" = "master" ]; then 116 1.1 mrg git clone -q $GITROOT gcc 117 1.1 mrg else 118 1.1 mrg git clone -q -b releases/gcc-$RELEASE $GITROOT gcc 119 1.1 mrg fi 120 1.1 mrg rm -rf gcc/.git 121 1.1 mrg 122 1.1 mrg # Remove all unwanted files. This is needed to avoid packaging all the 123 1.1 mrg # sources instead of only documentation sources. 124 1.1 mrg # Note that we have to preserve gcc/jit/docs since the jit docs are 125 1.1 mrg # not .texi files (Makefile, .rst and .png), and the jit docs use 126 1.1 mrg # include directives to pull in content from jit/jit-common.h and 127 1.1 mrg # jit/notes.txt, so we have to preserve those also. 128 1.1 mrg find gcc -type f \( -name '*.texi' \ 129 1.1 mrg -o -path gcc/gcc/doc/install.texi2html \ 130 1.1 mrg -o -path gcc/gcc/doc/include/texinfo.tex \ 131 1.1 mrg -o -path gcc/gcc/BASE-VER \ 132 1.1 mrg -o -path gcc/gcc/DEV-PHASE \ 133 1.1 mrg -o -path "gcc/gcc/ada/doc/gnat_ugn/*.png" \ 134 1.1 mrg -o -path "gcc/gcc/jit/docs/*" \ 135 1.1 mrg -o -path "gcc/gcc/jit/jit-common.h" \ 136 1.1 mrg -o -path "gcc/gcc/jit/notes.txt" \ 137 1.1 mrg -o -print0 \) | xargs -0 rm -f 138 1.1 mrg 139 1.1 mrg # Build a tarball of the sources. 140 1.1 mrg tar cf docs-sources.tar gcc 141 1.1 mrg 142 1.1 mrg # The directory to pass to -I; this is the one with texinfo.tex 143 1.1 mrg # and fdl.texi. 144 1.1 mrg includedir=gcc/gcc/doc/include 145 1.1 mrg 146 1.1 mrg # Generate gcc-vers.texi. 147 1.1 mrg ( 148 1.1 mrg echo "@set version-GCC $(cat gcc/gcc/BASE-VER)" 149 1.1 mrg if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then 150 1.1 mrg echo "@set DEVELOPMENT" 151 1.1 mrg else 152 1.1 mrg echo "@clear DEVELOPMENT" 153 1.1 mrg fi 154 1.1 mrg echo "@set srcdir $WORKDIR/gcc/gcc" 155 1.1 mrg echo "@set VERSION_PACKAGE (GCC)" 156 1.1 mrg echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" 157 1.1 mrg ) > $includedir/gcc-vers.texi 158 1.1 mrg 159 1.1 mrg # Generate libquadmath-vers.texi. 160 1.1 mrg echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}" \ 161 1.1 mrg > $includedir/libquadmath-vers.texi 162 1.1 mrg 163 1.1 mrg # Now convert the relevant files from texi to HTML, PDF and PostScript. 164 1.1 mrg for file in $MANUALS; do 165 1.1 mrg filename=`find . -name ${file}.texi` 166 1.1 mrg if [ "${filename}" ]; then 167 1.1 mrg includes="-I ${includedir} -I `dirname ${filename}`" 168 1.1 mrg if [ "$file" = "gnat_ugn" ]; then 169 1.1 mrg includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn" 170 1.1 mrg fi 171 1.1 mrg makeinfo --html --css-ref $CSS $includes -o ${file} ${filename} 172 1.1 mrg tar cf ${file}-html.tar ${file}/*.html 173 1.1 mrg texi2dvi $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi 174 1.1 mrg texi2pdf $includes -o ${file}.pdf ${filename} </dev/null 175 1.1 mrg mkdir -p $DOCSDIR/$file 176 1.1 mrg fi 177 1.1 mrg done 178 1.1 mrg 179 1.1 mrg # The jit is a special-case, using sphinx rather than texinfo. 180 1.1 mrg # Specifically, the jit docs need sphinx 1.0 or later. 181 1.1 mrg # 182 1.1 mrg # The jit/docs Makefile uses the executable $(SPHINXBUILD), 183 1.1 mrg # defaulting to "sphinx-build". 184 1.1 mrg # 185 1.1 mrg # sphinx is packaged in Fedora and EPEL 6 within "python-sphinx", 186 1.1 mrg # in RHEL 8 within "python3-sphinx", 187 1.1 mrg # and in openSUSE within "python-Sphinx". 188 1.1 mrg # 189 1.1 mrg # For EPEL6, python-sphinx is sphinx 0.6.6, which is missing various 190 1.1 mrg # directives (e.g. ":c:macro:"), so we need the variant 191 1.1 mrg # python-sphinx10 package. The latter installs its executable as 192 1.1 mrg # /usr/bin/sphinx-1.0-build 193 1.1 mrg # so we needed to override SPHINXBUILD with this when invoking "make". 194 1.1 mrg pushd gcc/gcc/jit/docs 195 1.1 mrg make html || true 196 1.1 mrg popd 197 1.1 mrg cp -a gcc/gcc/jit/docs/_build/html jit 198 1.1 mrg mkdir -p $DOCSDIR/jit 199 1.1 mrg 200 1.1 mrg # Work around makeinfo generated file names and references with 201 1.1 mrg # "_002d" instead of "-". 202 1.1 mrg find . -name '*.html' | while read f; do 203 1.1 mrg # Do this for the contents of each file. 204 1.1 mrg sed -i -e 's/_002d/-/g' "$f" 205 1.1 mrg # And rename files if necessary. 206 1.1 mrg ff=`echo $f | sed -e 's/_002d/-/g'`; 207 1.1 mrg if [ "$f" != "$ff" ]; then 208 1.1 mrg printf "Renaming %s to %s\n" "$f" "$ff" 209 1.1 mrg mv "$f" "$ff" 210 1.1 mrg fi 211 1.1 mrg done 212 1.1 mrg 213 1.1 mrg # Then build a gzipped copy of each of the resulting .html, .ps and .tar files 214 1.1 mrg for file in */*.html *.ps *.pdf *.tar; do 215 1.1 mrg cat $file | gzip --best > $file.gz 216 1.1 mrg done 217 1.1 mrg 218 1.1 mrg # On the 15th of the month, wipe all the old files from the 219 1.1 mrg # web server. 220 1.1 mrg today=`date +%d` 221 1.1 mrg if test $today = 15; then 222 1.1 mrg find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm 223 1.1 mrg for m in $MANUALS; do 224 1.1 mrg rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz 225 1.1 mrg done 226 1.1 mrg fi 227 1.1 mrg 228 1.1 mrg # And copy the resulting files to the web server 229 1.1 mrg for file in */*.html *.ps *.pdf *.tar; do 230 1.1 mrg if [ -f $DOCSDIR/$file ]; then 231 1.1 mrg cat $DOCSDIR/$file | 232 1.1 mrg sed -e '/^<meta name=generator/d' \ 233 1.1 mrg -e '/^%DVIPSSource:/d' > file1 234 1.1 mrg fi 235 1.1 mrg cat $file | 236 1.1 mrg sed -e '/^<meta name=generator/d' \ 237 1.1 mrg -e '/^%DVIPSSource:/d' > file2 238 1.1 mrg if cmp -s file1 file2; then 239 1.1 mrg : 240 1.1 mrg else 241 1.1 mrg cp $file $DOCSDIR/$file 242 1.1 mrg cp $file.gz $DOCSDIR/$file.gz 243 1.1 mrg fi 244 1.1 mrg done 245 1.1 mrg 246 1.1 mrg # Again, the jit is a special case, with nested subdirectories 247 1.1 mrg # below "jit", and with some non-HTML files (.png images from us, 248 1.1 mrg # plus .css and .js supplied by sphinx, and source files, renamed 249 1.1 mrg # from .rst to .txt). 250 1.1 mrg find jit \ 251 1.1 mrg -name "*.html" -o -name "*.png" \ 252 1.1 mrg -o -name "*.css" -o -name "*.js" \ 253 1.1 mrg -o -name "*.txt" | 254 1.1 mrg while read file ; do 255 1.1 mrg # Note that $file here will contain path fragments beginning 256 1.1 mrg # with "jit/", e.g. "jit/cp/topics/functions.html" 257 1.1 mrg mkdir -p $(dirname $DOCSDIR/$file) 258 1.1 mrg cp $file $DOCSDIR/$file 259 1.1 mrg done 260 1.1 mrg 261 1.1 mrg cd $DOCSDIR 262 1.1 mrg 263 1.1 mrg # Finally, generate the installation documentation 264 1.1 mrg if [ "$RELEASE" = "master" ]; then 265 1.1 mrg SOURCEDIR=$WORKDIR/gcc/gcc/doc 266 1.1 mrg DESTDIR=$WWWBASE_PREFORMATTED/install 267 1.1 mrg export SOURCEDIR 268 1.1 mrg export DESTDIR 269 1.1 mrg $WORKDIR/gcc/gcc/doc/install.texi2html 270 1.1 mrg 271 1.1 mrg # Preprocess the entire web site, not just the install docs! 272 1.1 mrg echo "Invoking $WWWPREPROCESS" 273 1.1 mrg $WWWPREPROCESS |grep -v '^ Warning: Keeping' 274 1.1 mrg fi 275 1.1 mrg 276 1.1 mrg # Clean up behind us. 277 1.1 mrg 278 1.1 mrg rm -rf $WORKDIR 279