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