xref: /openbsd-src/gnu/gcc/libstdc++-v3/docs/doxygen/run_doxygen (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert#!/bin/bash
2*404b540aSrobert
3*404b540aSrobert# Runs doxygen and massages the output files.
4*404b540aSrobert# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5*404b540aSrobert#
6*404b540aSrobert# Synopsis:  run_doxygen --mode=[user|maint|man] --host_alias=<alias> \
7*404b540aSrobert#                        v3srcdir  v3builddir
8*404b540aSrobert#
9*404b540aSrobert# Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
10*404b540aSrobert
11*404b540aSrobert
12*404b540aSrobert# We can check now that the version of doxygen is >= this variable.
13*404b540aSrobertDOXYVER=1.3.9
14*404b540aSrobert
15*404b540aSrobertfind_doxygen() {
16*404b540aSrobert    local -r v_required=`echo $DOXYVER |  \
17*404b540aSrobert                awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
18*404b540aSrobert    local testing_version doxygen maybedoxy v_found
19*404b540aSrobert    # thank you goat book
20*404b540aSrobert    set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
21*404b540aSrobert    for dir
22*404b540aSrobert    do
23*404b540aSrobert      # AC_EXEEXT could come in useful here
24*404b540aSrobert      maybedoxy="$dir/doxygen"
25*404b540aSrobert      test -f "$maybedoxy" && testing_version=`$maybedoxy --version`
26*404b540aSrobert      if test -n "$testing_version"; then
27*404b540aSrobert       v_found=`echo $testing_version |  \
28*404b540aSrobert                awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
29*404b540aSrobert       if test $v_found -ge $v_required; then
30*404b540aSrobert         doxygen="$maybedoxy"
31*404b540aSrobert         break
32*404b540aSrobert       fi
33*404b540aSrobert      fi
34*404b540aSrobert    done
35*404b540aSrobert    if test -z "$doxygen"; then
36*404b540aSrobert        echo run_doxygen error:  Could not find Doxygen $DOXYVER in path. 1>&2
37*404b540aSrobert        print_usage
38*404b540aSrobert    fi
39*404b540aSrobert    # We need to use other tools from the same package/version.
40*404b540aSrobert    echo :: Using Doxygen tools from ${dir}.
41*404b540aSrobert    PATH=$dir:$PATH
42*404b540aSrobert    hash -r
43*404b540aSrobert}
44*404b540aSrobert
45*404b540aSrobertprint_usage() {
46*404b540aSrobert    cat 1>&2 <<EOF
47*404b540aSrobertUsage:  run_doxygen --mode=MODE --host_alias=BUILD_ALIAS [<options>]
48*404b540aSrobert                    <v3-src-dir> <v3-build-dir>
49*404b540aSrobert      MODE is one of:
50*404b540aSrobert          user           Generate user-level HTML library documentation.
51*404b540aSrobert          maint          Generate maintainers' HTML documentation (lots more;
52*404b540aSrobert                             exposes non-public members, etc).
53*404b540aSrobert          man            Generate user-level man pages.
54*404b540aSrobert
55*404b540aSrobert      BUILD_ALIAS is the GCC build alias set at configure time.
56*404b540aSrobert
57*404b540aSrobert      more options when i think of them
58*404b540aSrobert
59*404b540aSrobertNote:  Requires Doxygen ${DOXYVER} or later; get it at
60*404b540aSrobert       ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
61*404b540aSrobert
62*404b540aSrobertEOF
63*404b540aSrobert    exit 1
64*404b540aSrobert}
65*404b540aSrobert
66*404b540aSrobertparse_options() {
67*404b540aSrobert  for o
68*404b540aSrobert  do
69*404b540aSrobert    # Blatantly ripped from autoconf, er, I mean, "gratefully standing
70*404b540aSrobert    # on the shoulders of those giants who have gone before us."
71*404b540aSrobert    case "$o" in
72*404b540aSrobert      -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
73*404b540aSrobert      *) arg= ;;
74*404b540aSrobert    esac
75*404b540aSrobert
76*404b540aSrobert    case "$o" in
77*404b540aSrobert      --mode=*)
78*404b540aSrobert        mode=$arg ;;
79*404b540aSrobert      --host_alias=*)
80*404b540aSrobert        host_alias=$arg ;;
81*404b540aSrobert      --mode | --host_alias | --help | -h)
82*404b540aSrobert        print_usage ;;
83*404b540aSrobert      *)
84*404b540aSrobert        # this turned out to be a mess, maybe change to --srcdir=, etc
85*404b540aSrobert        if test $srcdir = unset; then
86*404b540aSrobert          srcdir=$o
87*404b540aSrobert        elif test $outdir = unset; then
88*404b540aSrobert          builddir=${o}
89*404b540aSrobert          outdir=${o}/docs/doxygen
90*404b540aSrobert        else
91*404b540aSrobert          echo run_doxygen error:  Too many arguments 1>&2
92*404b540aSrobert          exit 1
93*404b540aSrobert        fi
94*404b540aSrobert        ;;
95*404b540aSrobert      esac
96*404b540aSrobert  done
97*404b540aSrobert}
98*404b540aSrobert
99*404b540aSrobert
100*404b540aSrobert# script begins here
101*404b540aSrobertmode=unset
102*404b540aSroberthost_alias=unset
103*404b540aSrobertsrcdir=unset
104*404b540aSrobertoutdir=unset
105*404b540aSrobertdo_html=false
106*404b540aSrobertdo_man=false
107*404b540aSrobertenabled_sections=
108*404b540aSrobertgenerate_tagfile=
109*404b540aSrobertDATEtext=`date '+%Y-%m-%d'`
110*404b540aSrobert
111*404b540aSrobert# Show how this script is called.
112*404b540aSrobertecho run_doxygen $*
113*404b540aSrobert
114*404b540aSrobertparse_options $*
115*404b540aSrobertfind_doxygen
116*404b540aSrobert
117*404b540aSrobertif test $srcdir = unset || test $outdir = unset || test $mode = unset || test $host_alias = unset; then
118*404b540aSrobert    # this could be better
119*404b540aSrobert    echo run_doxygen error:  You have not given enough information...! 1>&2
120*404b540aSrobert    print_usage
121*404b540aSrobertfi
122*404b540aSrobert
123*404b540aSrobertcase x"$mode" in
124*404b540aSrobert    xuser)
125*404b540aSrobert      do_html=true
126*404b540aSrobert      LEVELtext='User'
127*404b540aSrobert      generate_tagfile="$outdir/html_$mode/libstdc++.tag"
128*404b540aSrobert      ;;
129*404b540aSrobert    xmaint)
130*404b540aSrobert      do_html=true
131*404b540aSrobert      enabled_sections=maint
132*404b540aSrobert      LEVELtext='Maintainer'
133*404b540aSrobert      generate_tagfile="$outdir/html_$mode/libstdc++.tag"
134*404b540aSrobert      ;;
135*404b540aSrobert    xman)
136*404b540aSrobert      do_man=true
137*404b540aSrobert      ;;
138*404b540aSrobert    *)
139*404b540aSrobert      echo run_doxygen error:  $mode is an invalid mode 1>&2
140*404b540aSrobert      exit 1 ;;
141*404b540aSrobertesac
142*404b540aSrobert
143*404b540aSrobert#rm -rf $outdir
144*404b540aSrobertmkdir -p $outdir
145*404b540aSrobertchmod u+w $outdir
146*404b540aSrobert
147*404b540aSrobert# work around a stupid doxygen bug
148*404b540aSrobertif $do_man; then
149*404b540aSrobert    mkdir -p $outdir/man/man3/ext
150*404b540aSrobert    chmod -R u+w $outdir/man/man3/ext
151*404b540aSrobertfi
152*404b540aSrobert
153*404b540aSrobert(
154*404b540aSrobert  set -e
155*404b540aSrobert  cd $builddir
156*404b540aSrobert  sed -e "s=@outdir@=${outdir}=g" \
157*404b540aSrobert      -e "s=@srcdir@=${srcdir}=g" \
158*404b540aSrobert      -e "s=@builddir@=${builddir}=g" \
159*404b540aSrobert      -e "s=@host_alias@=${host_alias}=g" \
160*404b540aSrobert      -e "s=@html_output_dir@=html_${mode}=" \
161*404b540aSrobert      -e "s=@enabled_sections@=${enabled_sections}=" \
162*404b540aSrobert      -e "s=@do_html@=${do_html}=" \
163*404b540aSrobert      -e "s=@do_man@=${do_man}=" \
164*404b540aSrobert      -e "s=@generate_tagfile@=${generate_tagfile}=" \
165*404b540aSrobert      ${srcdir}/docs/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
166*404b540aSrobert  echo :: NOTE that this may take some time...
167*404b540aSrobert  echo doxygen ${outdir}/${mode}.cfg
168*404b540aSrobert  doxygen ${outdir}/${mode}.cfg
169*404b540aSrobert  echo :: Finished, exit code was $?
170*404b540aSrobert)
171*404b540aSrobertret=$?
172*404b540aSroberttest $ret -ne 0 && exit $ret
173*404b540aSrobert
174*404b540aSrobertif $do_html; then
175*404b540aSrobert  cd ${outdir}/html_${mode}
176*404b540aSrobert
177*404b540aSrobert  #doxytag -t libstdc++.tag . > /dev/null 2>&1
178*404b540aSrobert  sed -e '/<path>/d' libstdc++.tag > TEMP
179*404b540aSrobert  mv TEMP libstdc++.tag
180*404b540aSrobert
181*404b540aSrobert  sed -e "s=@LEVEL@=${LEVELtext}=" \
182*404b540aSrobert      -e "s=@DATE@=${DATEtext}=" \
183*404b540aSrobert      ${srcdir}/docs/doxygen/mainpage.html > index.html
184*404b540aSrobert
185*404b540aSrobert  # The following bit of line noise changes annoying
186*404b540aSrobert  #   std::foo < typename _Ugly1, typename _Ugly2, .... _DefaultUgly17 >
187*404b540aSrobert  # to user-friendly
188*404b540aSrobert  #   std::foo
189*404b540aSrobert  # in the major "Compound List" page.
190*404b540aSrobert  sed -e 's=\(::[[:alnum:]_]*\)&lt; .* &gt;=\1=' annotated.html > annstrip.html
191*404b540aSrobert  mv annstrip.html annotated.html
192*404b540aSrobert
193*404b540aSrobert  # Work around a bug in doxygen 1.3.
194*404b540aSrobert  for f in class*html struct*html; do
195*404b540aSrobert      sed '1,10s!^<title> Template!<title>Template !' $f > TEMP
196*404b540aSrobert      mv TEMP $f
197*404b540aSrobert  done
198*404b540aSrobert
199*404b540aSrobert  cp ${srcdir}/docs/doxygen/tables.html tables.html
200*404b540aSrobert  echo ::
201*404b540aSrobert  echo :: HTML pages begin with
202*404b540aSrobert  echo :: ${outdir}/html_${mode}/index.html
203*404b540aSrobertfi
204*404b540aSrobert
205*404b540aSrobert# Mess with the man pages.  We don't need documentation of the internal
206*404b540aSrobert# headers, since the man pages for those contain nothing useful anyhow.  The
207*404b540aSrobert# man pages for doxygen modules need to be renamed (or deleted).  And the
208*404b540aSrobert# generated #include lines need to be changed from the internal names to the
209*404b540aSrobert# standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>").
210*404b540aSrobertif $do_man; then
211*404b540aSrobertecho ::
212*404b540aSrobertecho :: Fixing up the man pages...
213*404b540aSrobertcd $outdir/man/man3
214*404b540aSrobert
215*404b540aSrobert# here's the other end of the "stupid doxygen bug" mentioned above
216*404b540aSrobertrm -rf ext
217*404b540aSrobert
218*404b540aSrobert# File names with embedded spaces (EVIL!) need to be....?  renamed or removed?
219*404b540aSrobertfind . -name "* *" -print0 | xargs -0r rm        # requires GNU tools
220*404b540aSrobert
221*404b540aSrobert# can leave SGIextensions.3 alone, it's an okay name
222*404b540aSrobertmv s20_3_1_base.3           Intro_functors.3
223*404b540aSrobertmv s20_3_2_arithmetic.3     Arithmetic_functors.3
224*404b540aSrobertmv s20_3_3_comparisons.3    Comparison_functors.3
225*404b540aSrobertmv s20_3_4_logical.3        Logical_functors.3
226*404b540aSrobertmv s20_3_5_negators.3       Negation_functors.3
227*404b540aSrobertmv s20_3_6_binder.3         Binder_functors.3
228*404b540aSrobertmv s20_3_7_adaptors.3       Func_ptr_functors.3
229*404b540aSrobertmv s20_3_8_memadaptors.3    Member_ptr_functors.3
230*404b540aSrobertmv iterator_tags.3          Iterator_types.3
231*404b540aSrobertmv std.3                    Namespace_std.3
232*404b540aSrobertmv __gnu_cxx.3              Namespace___gnu_cxx.3
233*404b540aSrobert
234*404b540aSrobert# man pages are for functions/types/other entities, not source files
235*404b540aSrobert# directly.  who the heck would type "man foo.h" anyhow?
236*404b540aSrobertfind . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
237*404b540aSrobertrm -f *.h.3 *config* *.cc.3 *.tcc.3 *_t.3
238*404b540aSrobert# this is used to examine what we would have deleted, for debugging
239*404b540aSrobert#mkdir trash
240*404b540aSrobert#find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
241*404b540aSrobert#mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3  trash
242*404b540aSrobert
243*404b540aSrobert# Standardize the displayed header names.  If anyone who knows perl cares
244*404b540aSrobert# enough to rewrite all this, feel free.  This only gets run once a century,
245*404b540aSrobert# and I'm off getting coffee then anyhow, so I didn't care enough to make
246*404b540aSrobert# this super-fast.
247*404b540aSrobertg++ ${srcdir}/docs/doxygen/stdheader.cc -o ./stdheader
248*404b540aSrobertproblematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
249*404b540aSrobertfor f in $problematic; do
250*404b540aSrobert    # this is also slow, but safe and easy to debug
251*404b540aSrobert    oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f`
252*404b540aSrobert    newh=`echo $oldh | ./stdheader`
253*404b540aSrobert    sed "s=${oldh}=${newh}=" $f > TEMP
254*404b540aSrobert    mv TEMP $f
255*404b540aSrobertdone
256*404b540aSrobertrm stdheader
257*404b540aSrobert
258*404b540aSrobert# Some of the pages for generated modules have text that confuses certain
259*404b540aSrobert# implementations of man(1), e.g., Linux's.  We need to have another top-level
260*404b540aSrobert# *roff tag to /stop/ the .SH NAME entry.
261*404b540aSrobert#problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
262*404b540aSrobertproblematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
263*404b540aSrobertfor f in $problematic; do
264*404b540aSrobert    sed '/^\.SH NAME/{
265*404b540aSrobertn
266*404b540aSroberta\
267*404b540aSrobert\
268*404b540aSrobert.SH SYNOPSIS
269*404b540aSrobert    }' $f > TEMP
270*404b540aSrobert    mv TEMP $f
271*404b540aSrobertdone
272*404b540aSrobert
273*404b540aSrobert# Also, break this (generated) line up.  It's ugly as sin.
274*404b540aSrobertproblematic=`grep -l '[^^]Definition at line' *.3`
275*404b540aSrobertfor f in $problematic; do
276*404b540aSrobert    sed 's/Definition at line/\
277*404b540aSrobert.PP\
278*404b540aSrobert&/'  $f > TEMP
279*404b540aSrobert    mv TEMP $f
280*404b540aSrobertdone
281*404b540aSrobert
282*404b540aSrobertcp ${srcdir}/docs/doxygen/Intro.3 C++Intro.3
283*404b540aSrobert
284*404b540aSrobert# Why didn't I do this at the start?  Were rabid weasels eating my brain?
285*404b540aSrobert# Who the fsck would "man std_vector" when the class isn't named that?
286*404b540aSrobertfor f in std_tr1_*; do
287*404b540aSrobert    newname=`echo $f | sed 's/^std_tr1_/std::tr1::/'`
288*404b540aSrobert    mv $f $newname
289*404b540aSrobertdone
290*404b540aSrobertfor f in std_*; do
291*404b540aSrobert    newname=`echo $f | sed 's/^std_/std::/'`
292*404b540aSrobert    mv $f $newname
293*404b540aSrobertdone
294*404b540aSrobertfor f in __gnu_cxx_*; do
295*404b540aSrobert    newname=`echo $f | sed 's/^__gnu_cxx_/__gnu_cxx::/'`
296*404b540aSrobert    mv $f $newname
297*404b540aSrobertdone
298*404b540aSrobert
299*404b540aSrobert# Generic reoval bits, where there are things in the generated man
300*404b540aSrobert# pages that need to be killed.
301*404b540aSrobertfor f in *_libstdc__-v3_*; do
302*404b540aSrobert    rm $f
303*404b540aSrobertdone
304*404b540aSrobert
305*404b540aSrobertfor f in *_src_*; do
306*404b540aSrobert    rm $f
307*404b540aSrobertdone
308*404b540aSrobert
309*404b540aSrobert
310*404b540aSrobert# Also, for some reason, typedefs don't get their own man pages.  Sigh.
311*404b540aSrobertfor f in ios streambuf istream ostream iostream stringbuf \
312*404b540aSrobert         istringstream ostringstream stringstream filebuf ifstream \
313*404b540aSrobert         ofstream fstream string;
314*404b540aSrobertdo
315*404b540aSrobert    echo ".so man3/std::basic_${f}.3" > std::${f}.3
316*404b540aSrobert    echo ".so man3/std::basic_${f}.3" > std::w${f}.3
317*404b540aSrobertdone
318*404b540aSrobert
319*404b540aSrobertecho ::
320*404b540aSrobertecho :: Man pages in ${outdir}/man
321*404b540aSrobertfi
322*404b540aSrobert
323*404b540aSrobert# all done
324*404b540aSrobertecho ::
325*404b540aSrobert
326*404b540aSrobertexit 0
327*404b540aSrobert
328*404b540aSrobert# vim:ts=4:et:
329