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