OSDN Git Service

* crontab: Add 4.2 branch. Set trunk to 4.3.
[pf3gnuchains/gcc-fork.git] / maintainer-scripts / update_web_docs_svn
1 #!/bin/sh -x
2
3 # Generate HTML documentation from GCC Texinfo docs.
4 # This version is for GCC 3.1 and later versions.
5
6 set -e
7
8 # Run this from /tmp.
9 SVNROOT=${SVNROOT:-"file:///svn/gcc"}
10 export SVNROOT
11
12 PATH=/usr/local/bin:$PATH
13
14 WWWBASE=/www/gcc/htdocs
15 WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted
16 WWWPREPROCESS='/www/gcc/bin/preprocess -r'
17
18 # Process options -rrelease and -ddirectory
19 RELEASE=""
20 SUBDIR=""
21
22 while [ $# -gt 0 ]; do
23   case $1 in
24     -r*)
25       if [ -n "$RELEASE" ]; then
26         echo "Multiple releases specified" >&2
27         exit 1
28       fi
29       RELEASE="${1#-r}"
30       if [ -z "$RELEASE" ]; then
31         shift
32         RELEASE="$1"
33         if [ -z "$RELEASE" ]; then
34           echo "No release specified with -r" >&2
35           exit 1
36         fi
37       fi
38       ;;
39     -d*)
40       if [ -n "$SUBDIR" ]; then
41         echo "Multiple subdirectories specified" >&2
42         exit 1
43       fi
44       SUBDIR="${1#-d}"
45       if [ -z "$SUBDIR" ]; then
46         shift
47         SUBDIR="$1"
48         if [ -z "$SUBDIR" ]; then
49           echo "No subdirectory specified with -d" >&2
50           exit 1
51         fi
52       fi
53       ;;
54     *)
55       echo "Unknown argument \"$1\"" >&2
56       exit 1
57       ;;
58   esac
59   shift
60 done
61
62 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
63   echo "Release specified without subdirectory" >&2
64   exit 1
65 fi
66
67 if [ -z "$SUBDIR" ]; then
68   DOCSDIR=$WWWBASE/onlinedocs
69 else
70   DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR
71 fi
72
73 if [ ! -d $DOCSDIR ]; then
74   mkdir $DOCSDIR
75 fi
76
77 if [ -z "$RELEASE" ]; then
78   RELEASE=trunk
79 fi
80
81 WORKDIR=/tmp/gcc-doc-update.$$
82
83 rm -rf $WORKDIR
84 mkdir $WORKDIR
85 cd $WORKDIR
86 if [ "$RELEASE" = "trunk" ]; then
87   svn -q export $SVNROOT/$RELEASE gcc
88 else
89   svn -q export $SVNROOT/tags/$RELEASE gcc
90 fi
91
92 # Remove all unwanted files.  This is needed (a) to build the Ada
93 # generator programs with the installed library, not the new one and
94 # (b) to avoid packaging all the sources instead of only documentation
95 # sources.
96 find gcc -type f \( -name '*.texi' \
97   -o -path gcc/gcc/doc/install.texi2html \
98   -o -path gcc/gcc/doc/include/texinfo.tex \
99   -o -path gcc/gcc/ada/xgnatugn.adb \
100   -o -path gcc/gcc/ada/ug_words \
101   -o -path gcc/gcc/BASE-VER \
102   -o -path gcc/gcc/DEV-PHASE \
103   -o -print0 \) | xargs -0 rm -f
104
105 # Build a tarball of the sources.
106 tar cf docs-sources.tar gcc
107
108 # The directory to pass to -I; this is the one with texinfo.tex
109 # and fdl.texi.
110 includedir=gcc/gcc/doc/include
111
112 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"
113
114 # Generate gnat_ugn_unw
115
116 if [ -f gcc/gcc/ada/xgnatugn.adb ]; then
117    gnatmake -q gcc/gcc/ada/xgnatugn
118    ./xgnatugn unw gcc/gcc/ada/gnat_ugn.texi \
119      gcc/gcc/ada/ug_words gnat_ugn_unw.texi
120 fi
121
122 # Generate gcc-vers.texi.
123 (
124    echo "@set version-GCC $(cat gcc/gcc/BASE-VER)"
125    if [ "$(cat gcc/gcc/DEV-PHASE)" = "experimental" ]; then
126       echo "@set DEVELOPMENT"
127    else
128       echo "@clear DEVELOPMENT"
129    fi
130    echo "@set srcdir $WORKDIR/gcc/gcc"
131 ) > $includedir/gcc-vers.texi
132
133 # Now convert the relevant files from texi to HTML, PDF and PostScript.
134 for file in $MANUALS; do
135   filename=`find . -name ${file}.texi`
136   if [ "${filename}" ]; then
137     makeinfo --html -I ${includedir} -I `dirname ${filename}` ${filename}
138     tar cf ${file}-html.tar ${file}/*.html
139     texi2dvi -I ${includedir} ${filename} </dev/null && dvips -o ${file}.ps ${file}.dvi
140     texi2pdf -I ${includedir} ${filename} </dev/null
141     mkdir -p $DOCSDIR/$file
142   fi
143 done
144
145 # Then build a gzipped copy of each of the resulting .html, .ps and .tar files
146 for file in */*.html *.ps *.pdf *.tar; do
147   cat $file | gzip --best > $file.gz
148 done
149
150 # On the 15th of the month, wipe all the old files from the
151 # web server.
152 today=`date +%d`
153 if test $today = 15; then
154   find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
155   for m in $MANUALS; do
156     rm -f $DOCSDIR/$m/*.html $DOCSDIR/$m/*.html.gz
157   done
158 fi
159
160 # And copy the resulting files to the web server
161 for file in */*.html *.ps *.pdf *.tar; do
162   if [ -f $DOCSDIR/$file ]; then
163     cat $DOCSDIR/$file | 
164       sed -e '/^<meta name=generator/d' \
165           -e '/^%DVIPSSource:/d' > file1
166   fi
167   cat $file |
168     sed -e '/^<meta name=generator/d' \
169         -e '/^%DVIPSSource:/d' > file2
170   if cmp -s file1 file2; then
171     :
172   else
173     cp $file $DOCSDIR/$file
174     cp $file.gz $DOCSDIR/$file.gz
175   fi
176 done
177
178 cd $DOCSDIR
179
180 # Finally, generate the installation documentation
181 if [ "$RELEASE" = "trunk" ]; then
182   SOURCEDIR=$WORKDIR/gcc/gcc/doc
183   DESTDIR=$WWWBASE_PREFORMATTED/install
184   export SOURCEDIR
185   export DESTDIR
186   $WORKDIR/gcc/gcc/doc/install.texi2html
187
188   # Preprocess the entire web site, not just the install docs!
189   echo "Invoking $WWWPREPROCESS"
190   $WWWPREPROCESS |grep -v '^  Warning: Keeping'
191 fi
192
193 # Clean up behind us.
194
195 rm -rf $WORKDIR