136ac495dSmrg#!/bin/bash 236ac495dSmrg 336ac495dSmrg# Runs doxygen and massages the output files. 4*8feb0f0bSmrg# Copyright (C) 2001-2020 Free Software Foundation, Inc. 536ac495dSmrg# 636ac495dSmrg# Synopsis: run_doxygen --mode=[html|latex|man|xml] --host_alias=<alias> \ 736ac495dSmrg# v3srcdir \ 836ac495dSmrg# v3builddir \ 936ac495dSmrg# shortname 1036ac495dSmrg# 1136ac495dSmrg# Originally hacked together by Phil Edwards <pme@gcc.gnu.org> 1236ac495dSmrg 1336ac495dSmrg 1436ac495dSmrg# We can check now that the version of doxygen is >= this variable. 1536ac495dSmrgDOXYVER=1.7.0 1636ac495dSmrg 1736ac495dSmrgfind_doxygen() { 1836ac495dSmrg local -r v_required=`echo $DOXYVER | \ 1936ac495dSmrg awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'` 2036ac495dSmrg local testing_version doxygen maybedoxy v_found 2136ac495dSmrg # thank you goat book 2236ac495dSmrg set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X` 2336ac495dSmrg for dir 2436ac495dSmrg do 2536ac495dSmrg # AC_EXEEXT could come in useful here 2636ac495dSmrg maybedoxy="$dir/doxygen" 2736ac495dSmrg test -f "$maybedoxy" && testing_version=`$maybedoxy --version` 2836ac495dSmrg if test -n "$testing_version"; then 2936ac495dSmrg v_found=`echo $testing_version | \ 3036ac495dSmrg awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'` 3136ac495dSmrg if test $v_found -ge $v_required; then 3236ac495dSmrg doxygen="$maybedoxy" 3336ac495dSmrg break 3436ac495dSmrg fi 3536ac495dSmrg fi 3636ac495dSmrg done 3736ac495dSmrg if test -z "$doxygen"; then 3836ac495dSmrg echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2 3936ac495dSmrg print_usage 4036ac495dSmrg fi 4136ac495dSmrg # We need to use other tools from the same package/version. 4236ac495dSmrg echo :: Using Doxygen tools from ${dir}. 4336ac495dSmrg PATH=$dir:$PATH 4436ac495dSmrg hash -r 4536ac495dSmrg} 4636ac495dSmrg 4736ac495dSmrgprint_usage() { 4836ac495dSmrg cat 1>&2 <<EOF 4936ac495dSmrgUsage: run_doxygen --mode=MODE --host_alias=BUILD_ALIAS [<options>] 5036ac495dSmrg <v3-src-dir> <v3-build-dir> <shortnamesp> 5136ac495dSmrg MODE is one of: 5236ac495dSmrg html Generate user-level HTML library documentation. 5336ac495dSmrg man Generate user-level man pages. 5436ac495dSmrg xml Generate user-level XML pages. 5536ac495dSmrg latex Generate user-level LaTeX pages. 5636ac495dSmrg 5736ac495dSmrg BUILD_ALIAS is the GCC build alias set at configure time. 5836ac495dSmrg 5936ac495dSmrgNote: Requires Doxygen ${DOXYVER} or later; get it at 6036ac495dSmrg ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz 6136ac495dSmrg 6236ac495dSmrgEOF 6336ac495dSmrg exit 1 6436ac495dSmrg} 6536ac495dSmrg 6636ac495dSmrgparse_options() { 6736ac495dSmrg for o 6836ac495dSmrg do 6936ac495dSmrg # Blatantly ripped from autoconf, er, I mean, "gratefully standing 7036ac495dSmrg # on the shoulders of those giants who have gone before us." 7136ac495dSmrg case "$o" in 7236ac495dSmrg -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 7336ac495dSmrg *) arg= ;; 7436ac495dSmrg esac 7536ac495dSmrg 7636ac495dSmrg case "$o" in 7736ac495dSmrg --mode=*) 7836ac495dSmrg mode=$arg ;; 7936ac495dSmrg --host_alias=*) 8036ac495dSmrg host_alias=$arg ;; 8136ac495dSmrg --mode | --host_alias | --help | -h) 8236ac495dSmrg print_usage ;; 8336ac495dSmrg *) 8436ac495dSmrg # this turned out to be a mess, maybe change to --srcdir=, etc 8536ac495dSmrg if test $srcdir = unset; then 8636ac495dSmrg srcdir=$o 8736ac495dSmrg elif test $outdir = unset; then 8836ac495dSmrg builddir=${o} 8936ac495dSmrg outdir=${o}/doc/doxygen 9036ac495dSmrg elif test $shortname = unset; then 9136ac495dSmrg shortname=$o 9236ac495dSmrg else 9336ac495dSmrg echo run_doxygen error: Too many arguments 1>&2 9436ac495dSmrg exit 1 9536ac495dSmrg fi 9636ac495dSmrg ;; 9736ac495dSmrg esac 9836ac495dSmrg done 9936ac495dSmrg} 10036ac495dSmrg 10136ac495dSmrg 10236ac495dSmrg# script begins here 10336ac495dSmrgmode=unset 10436ac495dSmrghost_alias=unset 10536ac495dSmrgsrcdir=unset 10636ac495dSmrgoutdir=unset 10736ac495dSmrgshortname=unset 10836ac495dSmrgdo_html=false 10936ac495dSmrgdo_man=false 11036ac495dSmrgdo_xml=false 11136ac495dSmrgdo_latex=false 11236ac495dSmrgenabled_sections= 11336ac495dSmrggenerate_tagfile= 11436ac495dSmrgDATEtext=`date '+%Y-%m-%d'` 11536ac495dSmrg 11636ac495dSmrg# Show how this script is called. 11736ac495dSmrgecho run_doxygen $* 11836ac495dSmrg 11936ac495dSmrgparse_options $* 12036ac495dSmrgfind_doxygen 12136ac495dSmrg 12236ac495dSmrgif test $srcdir = unset || test $outdir = unset || test $mode = unset || test $shortname = unset || test $host_alias = unset; then 12336ac495dSmrg # this could be better 12436ac495dSmrg echo run_doxygen error: You have not given enough information...! 1>&2 12536ac495dSmrg print_usage 12636ac495dSmrgfi 12736ac495dSmrg 12836ac495dSmrgcase x"$mode" in 12936ac495dSmrg xhtml) 13036ac495dSmrg do_html=true 13136ac495dSmrg enabled_sections=maint 13236ac495dSmrg generate_tagfile="$outdir/html/libstdc++.tag" 13336ac495dSmrg ;; 13436ac495dSmrg xlatex) 13536ac495dSmrg do_latex=true 13636ac495dSmrg enabled_sections=maint 13736ac495dSmrg ;; 13836ac495dSmrg xman) 13936ac495dSmrg do_man=true 14036ac495dSmrg ;; 14136ac495dSmrg xxml) 14236ac495dSmrg do_xml=true 14336ac495dSmrg enabled_sections=maint 14436ac495dSmrg ;; 14536ac495dSmrg *) 14636ac495dSmrg echo run_doxygen error: $mode is an invalid mode 1>&2 14736ac495dSmrg exit 1 ;; 14836ac495dSmrgesac 14936ac495dSmrg 15036ac495dSmrgcase x"$shortname" in 15136ac495dSmrg xYES) 15236ac495dSmrg ;; 15336ac495dSmrg xNO) 15436ac495dSmrg ;; 15536ac495dSmrg *) 15636ac495dSmrg echo run_doxygen error: $shortname is invalid 1>&2 15736ac495dSmrg exit 1 ;; 15836ac495dSmrgesac 15936ac495dSmrg 16036ac495dSmrg 16136ac495dSmrgmkdir -p $outdir 16236ac495dSmrgchmod u+w $outdir 16336ac495dSmrg 16436ac495dSmrg# Run it 16536ac495dSmrg( 16636ac495dSmrg set -e 16736ac495dSmrg cd $builddir 16836ac495dSmrg sed -e "s=@outdir@=${outdir}=g" \ 16936ac495dSmrg -e "s=@srcdir@=${srcdir}=g" \ 17036ac495dSmrg -e "s=@shortname@=${shortname}=g" \ 17136ac495dSmrg -e "s=@builddir@=${builddir}=g" \ 17236ac495dSmrg -e "s=@host_alias@=${host_alias}=g" \ 17336ac495dSmrg -e "s=@enabled_sections@=${enabled_sections}=" \ 17436ac495dSmrg -e "s=@do_html@=${do_html}=" \ 17536ac495dSmrg -e "s=@do_latex@=${do_latex}=" \ 17636ac495dSmrg -e "s=@do_man@=${do_man}=" \ 17736ac495dSmrg -e "s=@do_xml@=${do_xml}=" \ 17836ac495dSmrg -e "s=@generate_tagfile@=${generate_tagfile}=" \ 17936ac495dSmrg ${srcdir}/doc/doxygen/user.cfg.in > ${outdir}/${mode}.cfg 18036ac495dSmrg echo :: NOTE that this may take some time... 18136ac495dSmrg echo doxygen ${outdir}/${mode}.cfg 18236ac495dSmrg doxygen ${outdir}/${mode}.cfg 18336ac495dSmrg) 18436ac495dSmrgret=$? 18536ac495dSmrgtest $ret -ne 0 && exit $ret 18636ac495dSmrg 18736ac495dSmrgif $do_xml; then 18836ac495dSmrg echo :: 18936ac495dSmrg echo :: XML pages begin with 19036ac495dSmrg echo :: ${outdir}/xml/index.xml 19136ac495dSmrgfi 19236ac495dSmrg 19336ac495dSmrgif $do_latex; then 19436ac495dSmrg cd ${outdir}/${mode} 19536ac495dSmrg 19636ac495dSmrg # Grrr, Doxygen 1.8.x changed the -w latex options. 19736ac495dSmrg need_footer=`doxygen -h | sed -n -e '/-w latex/s=.*footer.*=true=p'` 19836ac495dSmrg 19936ac495dSmrg # Also drop in the header file (maybe footer file) and style sheet 20036ac495dSmrg if $need_footer; then 20136ac495dSmrg doxygen -w latex header.tex footer.tex doxygen.sty 20236ac495dSmrg else 20336ac495dSmrg doxygen -w latex header.tex doxygen.sty 20436ac495dSmrg fi 20536ac495dSmrg 20636ac495dSmrg echo :: 20736ac495dSmrg echo :: LaTeX pages begin with 20836ac495dSmrg echo :: ${outdir}/latex/refman.tex 20936ac495dSmrgfi 21036ac495dSmrg 21136ac495dSmrgif $do_html; then 21236ac495dSmrg cd ${outdir}/${mode} 21336ac495dSmrg 21436ac495dSmrg #doxytag -t libstdc++.tag . > /dev/null 2>&1 21536ac495dSmrg 21636ac495dSmrg # Strip pathnames from tag file. 21736ac495dSmrg sed -e '/<path>/d' libstdc++.tag > TEMP 21836ac495dSmrg mv TEMP libstdc++.tag 21936ac495dSmrg 22036ac495dSmrg sed -e "s=@DATE@=${DATEtext}=" \ 22136ac495dSmrg ${srcdir}/doc/doxygen/mainpage.html > index.html 22236ac495dSmrg 22336ac495dSmrg # The following bit of line noise changes annoying 22436ac495dSmrg # std::foo < typename _Ugly1, typename _Ugly2, .... _DefaultUgly17 > 22536ac495dSmrg # to user-friendly 22636ac495dSmrg # std::foo 22736ac495dSmrg # in the major "Compound List" page. 22836ac495dSmrg sed -e 's=\(::[[:alnum:]_]*\)< .* >=\1=' annotated.html > annstrip.html 22936ac495dSmrg mv annstrip.html annotated.html 23036ac495dSmrg 23136ac495dSmrg cp ${srcdir}/doc/doxygen/tables.html tables.html 23236ac495dSmrg 23336ac495dSmrg echo :: 23436ac495dSmrg echo :: HTML pages begin with 23536ac495dSmrg echo :: ${outdir}/html/index.html 23636ac495dSmrgfi 23736ac495dSmrg 23836ac495dSmrg# Mess with the man pages. We don't need documentation of the internal 23936ac495dSmrg# headers, since the man pages for those contain nothing useful anyhow. The 24036ac495dSmrg# man pages for doxygen modules need to be renamed (or deleted). And the 24136ac495dSmrg# generated #include lines need to be changed from the internal names to the 24236ac495dSmrg# standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>"). 24336ac495dSmrgif $do_man; then 24436ac495dSmrgecho :: 24536ac495dSmrgecho :: Fixing up the man pages... 24636ac495dSmrgcd $outdir/man/man3 24736ac495dSmrg 24836ac495dSmrg# File names with embedded spaces (EVIL!) need to be....? renamed or removed? 24936ac495dSmrgfind . -name "* *" -print0 | xargs -0r rm # requires GNU tools 25036ac495dSmrg 25136ac495dSmrg# man pages are for functions/types/other entities, not source files 25236ac495dSmrg# directly. who the heck would type "man foo.h" anyhow? 25336ac495dSmrgfind . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm 25436ac495dSmrgrm -f *.h.3 *.hpp.3 *config* *.cc.3 *.tcc.3 *_t.3 25536ac495dSmrg#rm ext_*.3 tr1_*.3 debug_*.3 25636ac495dSmrg 25736ac495dSmrg# this is used to examine what we would have deleted, for debugging 25836ac495dSmrg#mkdir trash 25936ac495dSmrg#find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash 26036ac495dSmrg#mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash 26136ac495dSmrg 26236ac495dSmrg# Standardize the displayed header names. If anyone who knows perl cares 26336ac495dSmrg# enough to rewrite all this, feel free. This only gets run once a century, 26436ac495dSmrg# and I'm off getting coffee then anyhow, so I didn't care enough to make 26536ac495dSmrg# this super-fast. 26636ac495dSmrgg++ ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader 26736ac495dSmrgproblematic=`egrep -l '#include <.*_.*>' [a-z]*.3` 26836ac495dSmrgfor f in $problematic; do 26936ac495dSmrg # this is also slow, but safe and easy to debug 27036ac495dSmrg oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f` 27136ac495dSmrg newh=`echo $oldh | ./stdheader` 27236ac495dSmrg sed 's=${oldh}=${newh}=' $f > TEMP 27336ac495dSmrg mv TEMP $f 27436ac495dSmrgdone 27536ac495dSmrgrm stdheader 27636ac495dSmrg 27736ac495dSmrg# Some of the pages for generated modules have text that confuses certain 27836ac495dSmrg# implementations of man(1), e.g. on GNU/Linux. We need to have another 27936ac495dSmrg# top-level *roff tag to /stop/ the .SH NAME entry. 28036ac495dSmrgproblematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3` 28136ac495dSmrg#problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3' 28236ac495dSmrg 28336ac495dSmrgfor f in $problematic; do 28436ac495dSmrg sed '/^\.SH NAME/{ 28536ac495dSmrgn 28636ac495dSmrga\ 28736ac495dSmrg\ 28836ac495dSmrg.SH SYNOPSIS 28936ac495dSmrg }' $f > TEMP 29036ac495dSmrg mv TEMP $f 29136ac495dSmrgdone 29236ac495dSmrg 29336ac495dSmrg# Also, break this (generated) line up. It's ugly as sin. 29436ac495dSmrgproblematic=`grep -l '[^^]Definition at line' *.3` 29536ac495dSmrgfor f in $problematic; do 29636ac495dSmrg sed 's/Definition at line/\ 29736ac495dSmrg.PP\ 29836ac495dSmrg&/' $f > TEMP 29936ac495dSmrg mv TEMP $f 30036ac495dSmrgdone 30136ac495dSmrg 30236ac495dSmrgcp ${srcdir}/doc/doxygen/Intro.3 C++Intro.3 30336ac495dSmrg 30436ac495dSmrg# Why didn't I do this at the start? Were rabid weasels eating my brain? 30536ac495dSmrg# Who the fsck would "man std_vector" when the class isn't named that? 30636ac495dSmrg 30736ac495dSmrg# First, deal with nested namespaces. 30836ac495dSmrgfor f in *chrono_*; do 30936ac495dSmrg newname=`echo $f | sed 's/chrono_/chrono::/'` 31036ac495dSmrg mv $f $newname 31136ac495dSmrgdone 31236ac495dSmrgfor f in *__debug_*; do 31336ac495dSmrg newname=`echo $f | sed 's/__debug_/__debug::/'` 31436ac495dSmrg mv $f $newname 31536ac495dSmrgdone 31636ac495dSmrgfor f in *decimal_*; do 31736ac495dSmrg newname=`echo $f | sed 's/decimal_/decimal::/'` 31836ac495dSmrg mv $f $newname 31936ac495dSmrgdone 32036ac495dSmrgfor f in *__detail_*; do 32136ac495dSmrg newname=`echo $f | sed 's/__detail_/__detail::/'` 32236ac495dSmrg mv $f $newname 32336ac495dSmrgdone 32436ac495dSmrgfor f in *__gnu_pbds_detail_*; do 32536ac495dSmrg newname=`echo $f | sed 's/detail_/detail::/'` 32636ac495dSmrg mv $f $newname 32736ac495dSmrgdone 32836ac495dSmrgfor f in *__parallel_*; do 32936ac495dSmrg newname=`echo $f | sed 's/__parallel_/__parallel::/'` 33036ac495dSmrg mv $f $newname 33136ac495dSmrgdone 33236ac495dSmrg 33336ac495dSmrg# Remove inline namespaces used for versioning. 33436ac495dSmrgfor f in *_V2_*; do 33536ac495dSmrg newname=`echo $f | sed 's/_V2_/::/'` 33636ac495dSmrg sed 's/::_V2::/::/g' $f > $newname 33736ac495dSmrg rm $f 33836ac495dSmrgdone 33936ac495dSmrgfor f in *_experimental_filesystem_v?_*; do 34036ac495dSmrg newname=`echo $f | sed 's/_filesystem_v._/::filesystem::/'` 34136ac495dSmrg sed 's/::filesystem::v.::/::filesystem::/g' $f > $newname 34236ac495dSmrg rm $f 34336ac495dSmrgdone 34436ac495dSmrgfor f in *experimental_fundamentals_v?_*; do 34536ac495dSmrg newname=`echo $f | sed 's/experimental_.*_v[[:digit:]]_/experimental::/'` 34636ac495dSmrg sed 's/::experimental::fundamentals_v[[:digit:]]::/::experimental::/g' $f > $newname 34736ac495dSmrg rm $f 34836ac495dSmrgdone 34936ac495dSmrg 35036ac495dSmrg# Then, clean up other top-level namespaces. 35136ac495dSmrgfor f in std_tr1_*; do 35236ac495dSmrg newname=`echo $f | sed 's/^std_tr1_/std::tr1::/'` 35336ac495dSmrg mv $f $newname 35436ac495dSmrgdone 35536ac495dSmrgfor f in std_tr2_*; do 35636ac495dSmrg newname=`echo $f | sed 's/^std_tr2_/std::tr2::/'` 35736ac495dSmrg mv $f $newname 35836ac495dSmrgdone 35936ac495dSmrgfor f in std_*; do 36036ac495dSmrg newname=`echo $f | sed 's/^std_/std::/'` 36136ac495dSmrg mv $f $newname 36236ac495dSmrgdone 36336ac495dSmrgfor f in __gnu_cxx_*; do 36436ac495dSmrg newname=`echo $f | sed 's/^__gnu_cxx_/__gnu_cxx::/'` 36536ac495dSmrg mv $f $newname 36636ac495dSmrgdone 36736ac495dSmrgfor f in __gnu_debug_*; do 36836ac495dSmrg newname=`echo $f | sed 's/^__gnu_debug_/__gnu_debug::/'` 36936ac495dSmrg mv $f $newname 37036ac495dSmrgdone 37136ac495dSmrgfor f in __gnu_parallel_*; do 37236ac495dSmrg newname=`echo $f | sed 's/^__gnu_parallel_/__gnu_parallel::/'` 37336ac495dSmrg mv $f $newname 37436ac495dSmrgdone 37536ac495dSmrgfor f in __gnu_pbds_*; do 37636ac495dSmrg newname=`echo $f | sed 's/^__gnu_pbds_/__gnu_pbds::/'` 37736ac495dSmrg mv $f $newname 37836ac495dSmrgdone 37936ac495dSmrgfor f in __cxxabiv1_*; do 38036ac495dSmrg newname=`echo $f | sed 's/^__cxxabiv1_/abi::/'` 38136ac495dSmrg mv $f $newname 38236ac495dSmrgdone 38336ac495dSmrg 38436ac495dSmrg# Then piecemeal nested classes 38536ac495dSmrg 38636ac495dSmrg 38736ac495dSmrg# Generic removal bits, where there are things in the generated man 38836ac495dSmrg# pages that need to be killed. 38936ac495dSmrgfor f in *_libstdc__-v3_*; do 39036ac495dSmrg rm $f 39136ac495dSmrgdone 39236ac495dSmrg 39336ac495dSmrgfor f in *_src_*; do 39436ac495dSmrg rm $f 39536ac495dSmrgdone 39636ac495dSmrg 39736ac495dSmrg 39836ac495dSmrg# Also, for some reason, typedefs don't get their own man pages. Sigh. 39936ac495dSmrgfor f in ios streambuf istream ostream iostream stringbuf \ 40036ac495dSmrg istringstream ostringstream stringstream filebuf ifstream \ 40136ac495dSmrg ofstream fstream string; 40236ac495dSmrgdo 40336ac495dSmrg echo ".so man3/std::basic_${f}.3" > std::${f}.3 40436ac495dSmrg echo ".so man3/std::basic_${f}.3" > std::w${f}.3 40536ac495dSmrgdone 40636ac495dSmrg 40736ac495dSmrgecho :: 40836ac495dSmrgecho :: Man pages in ${outdir}/man 40936ac495dSmrgfi 41036ac495dSmrg 41136ac495dSmrg# all done 41236ac495dSmrgecho :: 41336ac495dSmrg 41436ac495dSmrgexit 0 415