update_web_docs_git 7.0 KB

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