update_web_docs_svn 6.7 KB

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