3 # Runs doxygen and massages the output files.
4 # Copyright (C) 2001, 2002, 2003, 2004, 2008, 2009, 2010
5 # Free Software Foundation, Inc.
7 # Synopsis: run_doxygen --mode=[html|latex|man|xml] --host_alias=<alias> \
12 # Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
15 # We can check now that the version of doxygen is >= this variable.
19 local -r v_required=`echo $DOXYVER | \
20 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
21 local testing_version doxygen maybedoxy v_found
23 set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
26 # AC_EXEEXT could come in useful here
27 maybedoxy="$dir/doxygen"
28 test -f "$maybedoxy" && testing_version=`$maybedoxy --version`
29 if test -n "$testing_version"; then
30 v_found=`echo $testing_version | \
31 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
32 if test $v_found -ge $v_required; then
38 if test -z "$doxygen"; then
39 echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2
42 # We need to use other tools from the same package/version.
43 echo :: Using Doxygen tools from ${dir}.
50 Usage: run_doxygen --mode=MODE --host_alias=BUILD_ALIAS [<options>]
51 <v3-src-dir> <v3-build-dir> <shortnamesp>
53 html Generate user-level HTML library documentation.
54 man Generate user-level man pages.
55 xml Generate user-level XML pages.
56 latex Generate user-level LaTeX pages.
58 BUILD_ALIAS is the GCC build alias set at configure time.
60 Note: Requires Doxygen ${DOXYVER} or later; get it at
61 ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
70 # Blatantly ripped from autoconf, er, I mean, "gratefully standing
71 # on the shoulders of those giants who have gone before us."
73 -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
82 --mode | --host_alias | --help | -h)
85 # this turned out to be a mess, maybe change to --srcdir=, etc
86 if test $srcdir = unset; then
88 elif test $outdir = unset; then
90 outdir=${o}/doc/doxygen
91 elif test $shortname = unset; then
94 echo run_doxygen error: Too many arguments 1>&2
115 DATEtext=`date '+%Y-%m-%d'`
117 # Show how this script is called.
123 if test $srcdir = unset || test $outdir = unset || test $mode = unset || test $shortname = unset || test $host_alias = unset; then
124 # this could be better
125 echo run_doxygen error: You have not given enough information...! 1>&2
132 enabled_sections=maint
133 generate_tagfile="$outdir/html/libstdc++.tag"
137 enabled_sections=maint
144 enabled_sections=maint
147 echo run_doxygen error: $mode is an invalid mode 1>&2
151 case x"$shortname" in
157 echo run_doxygen error: $shortname is invalid 1>&2
172 sed -e "s=@outdir@=${outdir}=g" \
173 -e "s=@srcdir@=${srcdir}=g" \
174 -e "s=@shortname@=${shortname}=g" \
175 -e "s=@builddir@=${builddir}=g" \
176 -e "s=@host_alias@=${host_alias}=g" \
177 -e "s=@enabled_sections@=${enabled_sections}=" \
178 -e "s=@do_html@=${do_html}=" \
179 -e "s=@do_latex@=${do_latex}=" \
180 -e "s=@do_man@=${do_man}=" \
181 -e "s=@do_xml@=${do_xml}=" \
182 -e "s=@generate_tagfile@=${generate_tagfile}=" \
183 ${srcdir}/doc/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
184 echo :: NOTE that this may take some time...
185 echo doxygen ${outdir}/${mode}.cfg
186 doxygen ${outdir}/${mode}.cfg
187 echo :: Finished, exit code was $?
190 test $ret -ne 0 && exit $ret
193 mkdir -p $outdir/latex
199 sed -e "s=@outdir@=${outdir}=g" \
200 -e "s=@srcdir@=${srcdir}=g" \
201 -e "s=@shortname@=${shortname}=g" \
202 -e "s=@builddir@=${builddir}=g" \
203 -e "s=@host_alias@=${host_alias}=g" \
204 -e "s=@enabled_sections@=${enabled_sections}=" \
205 -e "s=@do_html@=${do_html}=" \
206 -e "s=@do_latex@=${do_latex}=" \
207 -e "s=@do_man@=${do_man}=" \
208 -e "s=@do_xml@=${do_xml}=" \
209 -e "s=@generate_tagfile@=${generate_tagfile}=" \
210 ${srcdir}/doc/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
211 echo :: NOTE that this may take some time...
212 echo doxygen ${outdir}/${mode}.cfg
213 doxygen ${outdir}/${mode}.cfg
215 # Also drop in the header file and style sheet
217 doxygen -w latex header.tex doxygen.sty
218 echo :: Finished, exit code was $?
220 echo :: LaTeX pages begin with
221 echo :: ${outdir}/latex/refman.tex
224 test $ret -ne 0 && exit $ret
229 #doxytag -t libstdc++.tag . > /dev/null 2>&1
230 sed -e '/<path>/d' libstdc++.tag > TEMP
231 mv TEMP libstdc++.tag
233 sed -e "s=@DATE@=${DATEtext}=" \
234 ${srcdir}/doc/doxygen/mainpage.html > index.html
236 # The following bit of line noise changes annoying
237 # std::foo < typename _Ugly1, typename _Ugly2, .... _DefaultUgly17 >
240 # in the major "Compound List" page.
241 sed -e 's=\(::[[:alnum:]_]*\)< .* >=\1=' annotated.html > annstrip.html
242 mv annstrip.html annotated.html
244 cp ${srcdir}/doc/doxygen/tables.html tables.html
246 echo :: HTML pages begin with
247 echo :: ${outdir}/html/index.html
250 # Mess with the man pages. We don't need documentation of the internal
251 # headers, since the man pages for those contain nothing useful anyhow. The
252 # man pages for doxygen modules need to be renamed (or deleted). And the
253 # generated #include lines need to be changed from the internal names to the
254 # standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>").
257 echo :: Fixing up the man pages...
260 # File names with embedded spaces (EVIL!) need to be....? renamed or removed?
261 find . -name "* *" -print0 | xargs -0r rm # requires GNU tools
263 # man pages are for functions/types/other entities, not source files
264 # directly. who the heck would type "man foo.h" anyhow?
265 find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
266 rm -f *.h.3 *.hpp.3 *config* *.cc.3 *.tcc.3 *_t.3
267 #rm ext_*.3 tr1_*.3 debug_*.3
269 # this is used to examine what we would have deleted, for debugging
271 #find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
272 #mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash
274 # Standardize the displayed header names. If anyone who knows perl cares
275 # enough to rewrite all this, feel free. This only gets run once a century,
276 # and I'm off getting coffee then anyhow, so I didn't care enough to make
278 g++ ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader
279 problematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
280 for f in $problematic; do
281 # this is also slow, but safe and easy to debug
282 oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f`
283 newh=`echo $oldh | ./stdheader`
284 sed "s=${oldh}=${newh}=" $f > TEMP
289 # Some of the pages for generated modules have text that confuses certain
290 # implementations of man(1), e.g., Linux's. We need to have another top-level
291 # *roff tag to /stop/ the .SH NAME entry.
292 problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
293 #problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
295 for f in $problematic; do
305 # Also, break this (generated) line up. It's ugly as sin.
306 problematic=`grep -l '[^^]Definition at line' *.3`
307 for f in $problematic; do
308 sed 's/Definition at line/\
314 cp ${srcdir}/doc/doxygen/Intro.3 C++Intro.3
316 # Why didn't I do this at the start? Were rabid weasels eating my brain?
317 # Who the fsck would "man std_vector" when the class isn't named that?
319 # First, deal with nested namespaces.
320 for f in *chrono_*; do
321 newname=`echo $f | sed 's/chrono_/chrono::/'`
324 for f in *__debug_*; do
325 newname=`echo $f | sed 's/__debug_/__debug::/'`
328 for f in *decimal_*; do
329 newname=`echo $f | sed 's/decimal_/decimal::/'`
332 for f in *__detail_*; do
333 newname=`echo $f | sed 's/__detail_/__detail::/'`
336 for f in *__parallel_*; do
337 newname=`echo $f | sed 's/__parallel_/__parallel::/'`
340 for f in *__profile_*; do
341 newname=`echo $f | sed 's/__profile_/__profile::/'`
344 for f in *__atomic0_*; do
345 newname=`echo $f | sed 's/__atomic0_/__atomic0::/'`
348 for f in *__atomic2_*; do
349 newname=`echo $f | sed 's/__atomic2_/__atomic2::/'`
353 # Then, clean up other top-level namespaces.
354 for f in std_tr1_*; do
355 newname=`echo $f | sed 's/^std_tr1_/std::tr1::/'`
359 newname=`echo $f | sed 's/^std_/std::/'`
362 for f in __gnu_cxx_*; do
363 newname=`echo $f | sed 's/^__gnu_cxx_/__gnu_cxx::/'`
366 for f in __gnu_debug_*; do
367 newname=`echo $f | sed 's/^__gnu_debug_/__gnu_debug::/'`
370 for f in __gnu_parallel_*; do
371 newname=`echo $f | sed 's/^__gnu_parallel_/__gnu_parallel::/'`
374 for f in __gnu_profile_*; do
375 newname=`echo $f | sed 's/^__gnu_profile_/__gnu_profile::/'`
378 for f in __gnu_pbds_*; do
379 newname=`echo $f | sed 's/^__gnu_pbds_/__gnu_pbds::/'`
382 for f in __cxxabiv1_*; do
383 newname=`echo $f | sed 's/^__cxxabiv1_/abi::/'`
387 # Then piecemeal nested classes
388 for f in *__future_base_*; do
389 newname=`echo $f | sed 's/__future_base_/__future_base::/'`
395 # Generic removal bits, where there are things in the generated man
396 # pages that need to be killed.
397 for f in *_libstdc__-v3_*; do
406 # Also, for some reason, typedefs don't get their own man pages. Sigh.
407 for f in ios streambuf istream ostream iostream stringbuf \
408 istringstream ostringstream stringstream filebuf ifstream \
409 ofstream fstream string;
411 echo ".so man3/std::basic_${f}.3" > std::${f}.3
412 echo ".so man3/std::basic_${f}.3" > std::w${f}.3
416 echo :: Man pages in ${outdir}/man