2005-12-16 Andreas Krebbel <krebbel1@de.ibm.com>
[official-gcc.git] / maintainer-scripts / update_web_docs
blob6c14c68b0707bbd454160afc734a8a049ce54e21
1 #!/bin/sh -x
3 # Generate HTML documentation from GCC Texinfo docs.
4 # This version is for GCC 3.1 and later versions.
6 # Run this from /tmp.
7 CVSROOT=/cvs/gcc
8 export CVSROOT
10 PATH=/usr/local/bin:$PATH
12 WWWBASE=/www/gcc/htdocs
13 WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted
14 WWWPREPROCESS='/www/gcc/bin/preprocess -r'
16 # Process options -rrelease and -ddirectory
17 RELEASE=""
18 SUBDIR=""
20 while [ $# -gt 0 ]; do
21 case $1 in
22 -r*)
23 if [ -n "$RELEASE" ]; then
24 echo "Multiple releases specified" >&2
25 exit 1
27 RELEASE="${1#-r}"
28 if [ -z "$RELEASE" ]; then
29 shift
30 RELEASE="$1"
31 if [ -z "$RELEASE" ]; then
32 echo "No release specified with -r" >&2
33 exit 1
37 -d*)
38 if [ -n "$SUBDIR" ]; then
39 echo "Multiple subdirectories specified" >&2
40 exit 1
42 SUBDIR="${1#-d}"
43 if [ -z "$SUBDIR" ]; then
44 shift
45 SUBDIR="$1"
46 if [ -z "$SUBDIR" ]; then
47 echo "No subdirectory specified with -d" >&2
48 exit 1
53 echo "Unknown argument \"$1\"" >&2
54 exit 1
56 esac
57 shift
58 done
60 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
61 echo "Release specified without subdirectory" >&2
62 exit 1
65 if [ -z "$SUBDIR" ]; then
66 DOCSDIR=$WWWBASE/onlinedocs
67 else
68 DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR
71 if [ ! -d $DOCSDIR ]; then
72 mkdir $DOCSDIR
75 if [ -z "$RELEASE" ]; then
76 RELEASE=HEAD
79 WORKDIR=/tmp/gcc-doc-update.$$
81 /bin/rm -rf $WORKDIR
82 /bin/mkdir $WORKDIR
83 cd $WORKDIR
85 # Find all the texi files in the repository, except those in directories
86 # we do not care about (texinfo, etc).
87 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
90 # Checkout all the texi files.
91 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
93 # Build a tarball of the sources.
94 tar cf docs-sources.tar gcc
96 # The directory to pass to -I; this is the one with texinfo.tex
97 # and fdl.texi.
98 includedir=gcc/gcc/doc/include
100 MANUALS="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"
102 # Generate gnat_ugn_unw
104 if [ -f gcc/gcc/ada/xgnatugn.adb ]; then
105 gnatmake -q gcc/gcc/ada/xgnatugn
106 ./xgnatugn unw gcc/gcc/ada/gnat_ugn.texi \
107 gcc/gcc/ada/ug_words gnat_ugn_unw.texi
110 # Generate gcc-vers.texi.
112 echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"
113 if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then
114 echo "@set DEVELOPMENT"
115 else
116 echo "@clear DEVELOPMENT"
118 ) > $includedir/gcc-vers.texi
120 # Now convert the relevant files from texi to HTML, PDF and PostScript.
121 for file in $MANUALS; do
122 filename=`find . -name ${file}.texi`
123 if [ "${filename}" ]; then
124 makeinfo --html -I ${includedir} -I `dirname ${filename}` ${filename}
125 tar cf ${file}-html.tar ${file}/*.html
126 texi2dvi -I ${includedir} ${filename} </dev/null && dvips -o ${file}.ps ${file}.dvi
127 texi2pdf -I ${includedir} ${filename} </dev/null
128 mkdir -p $DOCSDIR/$file
130 done
132 # Then build a gzipped copy of each of the resulting .html, .ps and .tar files
133 for file in */*.html *.ps *.pdf *.tar; do
134 cat $file | gzip --best > $file.gz
135 done
137 # On the 15th of the month, wipe all the old files from the
138 # web server.
139 today=`date +%d`
140 if test $today = 15; then
141 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
142 for m in $MANUALS; do
143 rm $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz
144 done
147 # And copy the resulting files to the web server
148 for file in */*.html *.ps *.pdf *.tar; do
149 cat $DOCSDIR/$file |
150 sed -e '/^<meta name=generator/d' \
151 -e '/^%DVIPSSource:/d' > file1
152 cat $file |
153 sed -e '/^<meta name=generator/d' \
154 -e '/^%DVIPSSource:/d' > file2
155 if cmp -s file1 file2; then
157 else
158 cp $file $DOCSDIR/$file
159 cp $file.gz $DOCSDIR/$file.gz
161 done
163 cd $DOCSDIR
165 # Finally, generate the installation documentation (but only for CVS HEAD).
166 if [ "$RELEASE" = "HEAD" ]; then
167 SOURCEDIR=$WORKDIR/gcc/gcc/doc
168 DESTDIR=$WWWBASE_PREFORMATTED/install
169 export SOURCEDIR
170 export DESTDIR
171 $WORKDIR/gcc/gcc/doc/install.texi2html
173 # Preprocess the entire web site, not just the install docs!
174 echo "Invoking $WWWPREPROCESS"
175 $WWWPREPROCESS |grep -v '^ Warning: Keeping'
178 # Clean up behind us.
180 rm -rf $WORKDIR