#!/bin/bash
DOXYVER=1.3.9
find_doxygen() {
local -r v_required=`echo $DOXYVER | \
awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
local testing_version doxygen maybedoxy v_found
set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
for dir
do
maybedoxy="$dir/doxygen"
test -f "$maybedoxy" && testing_version=`$maybedoxy --version`
if test -n "$testing_version"; then
v_found=`echo $testing_version | \
awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
if test $v_found -ge $v_required; then
doxygen="$maybedoxy"
break
fi
fi
done
if test -z "$doxygen"; then
echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2
print_usage
fi
echo :: Using Doxygen tools from ${dir}.
PATH=$dir:$PATH
hash -r
}
print_usage() {
cat 1>&2 <<EOF
Usage: run_doxygen --mode=MODE --host_alias=BUILD_ALIAS [<options>]
<v3-src-dir> <v3-build-dir>
MODE is one of:
user Generate user-level HTML library documentation.
maint Generate maintainers' HTML documentation (lots more;
exposes non-public members, etc).
man Generate user-level man pages.
BUILD_ALIAS is the GCC build alias set at configure time.
more options when i think of them
Note: Requires Doxygen ${DOXYVER} or later; get it at
ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
EOF
exit 1
}
parse_options() {
for o
do
case "$o" in
-*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) arg= ;;
esac
case "$o" in
--mode=*)
mode=$arg ;;
--host_alias=*)
host_alias=$arg ;;
--mode | --host_alias | --help | -h)
print_usage ;;
*)
if test $srcdir = unset; then
srcdir=$o
elif test $outdir = unset; then
builddir=${o}
outdir=${o}/docs/doxygen
else
echo run_doxygen error: Too many arguments 1>&2
exit 1
fi
;;
esac
done
}
mode=unset
host_alias=unset
srcdir=unset
outdir=unset
do_html=false
do_man=false
enabled_sections=
generate_tagfile=
DATEtext=`date '+%Y-%m-%d'`
echo run_doxygen $*
parse_options $*
find_doxygen
if test $srcdir = unset || test $outdir = unset || test $mode = unset || test $host_alias = unset; then
echo run_doxygen error: You have not given enough information...! 1>&2
print_usage
fi
case x"$mode" in
xuser)
do_html=true
LEVELtext='User'
generate_tagfile="$outdir/html_$mode/libstdc++.tag"
;;
xmaint)
do_html=true
enabled_sections=maint
LEVELtext='Maintainer'
generate_tagfile="$outdir/html_$mode/libstdc++.tag"
;;
xman)
do_man=true
;;
*)
echo run_doxygen error: $mode is an invalid mode 1>&2
exit 1 ;;
esac
mkdir -p $outdir
chmod u+w $outdir
if $do_man; then
mkdir -p $outdir/man/man3/ext
chmod -R u+w $outdir/man/man3/ext
fi
(
set -e
cd $builddir
sed -e "s=@outdir@=${outdir}=g" \
-e "s=@srcdir@=${srcdir}=g" \
-e "s=@host_alias@=${host_alias}=g" \
-e "s=@html_output_dir@=html_${mode}=" \
-e "s=@enabled_sections@=${enabled_sections}=" \
-e "s=@do_html@=${do_html}=" \
-e "s=@do_man@=${do_man}=" \
-e "s=@generate_tagfile@=${generate_tagfile}=" \
${srcdir}/docs/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
echo :: NOTE that this may take some time...
echo doxygen ${outdir}/${mode}.cfg
doxygen ${outdir}/${mode}.cfg
echo :: Finished, exit code was $?
)
ret=$?
test $ret -ne 0 && exit $ret
if $do_html; then
cd ${outdir}/html_${mode}
sed -e '/<path>/d' libstdc++.tag > TEMP
mv TEMP libstdc++.tag
sed -e "s=@LEVEL@=${LEVELtext}=" \
-e "s=@DATE@=${DATEtext}=" \
${srcdir}/docs/doxygen/mainpage.html > index.html
sed -e 's=\(::[[:alnum:]_]*\)< .* >=\1=' annotated.html > annstrip.html
mv annstrip.html annotated.html
for f in class*html struct*html; do
sed '1,10s!^<title> Template!<title>Template !' $f > TEMP
mv TEMP $f
done
cp ${srcdir}/docs/doxygen/tables.html tables.html
echo ::
echo :: HTML pages begin with
echo :: ${outdir}/html_${mode}/index.html
fi
if $do_man; then
echo ::
echo :: Fixing up the man pages...
cd $outdir/man/man3
rm -rf ext
find . -name "* *" -print0 | xargs -0r rm
mv s20_3_1_base.3 Intro_functors.3
mv s20_3_2_arithmetic.3 Arithmetic_functors.3
mv s20_3_3_comparisons.3 Comparison_functors.3
mv s20_3_4_logical.3 Logical_functors.3
mv s20_3_5_negators.3 Negation_functors.3
mv s20_3_6_binder.3 Binder_functors.3
mv s20_3_7_adaptors.3 Func_ptr_functors.3
mv s20_3_8_memadaptors.3 Member_ptr_functors.3
mv iterator_tags.3 Iterator_types.3
mv std.3 Namespace_std.3
mv __gnu_cxx.3 Namespace___gnu_cxx.3
find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
rm -f *.h.3 *config* *.cc.3 *.tcc.3 *_t.3
g++ ${srcdir}/docs/doxygen/stdheader.cc -o ./stdheader
problematic=`egrep -l 'for f in $problematic; do
oldh=`sed -n '/fC newh=`echo $oldh | ./stdheader`
sed "s=${oldh}=${newh}=" $f > TEMP
mv TEMP $f
done
rm stdheader
problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
for f in $problematic; do
sed '/^\.SH NAME/{
n
a\
\
.SH SYNOPSIS
}' $f > TEMP
mv TEMP $f
done
problematic=`grep -l '[^^]Definition at line' *.3`
for f in $problematic; do
sed 's/Definition at line/\
.PP\
&/' $f > TEMP
mv TEMP $f
done
cp ${srcdir}/docs/doxygen/Intro.3 C++Intro.3
for f in std_tr1_*; do
newname=`echo $f | sed 's/^std_tr1_/std::tr1::/'`
mv $f $newname
done
for f in std_*; do
newname=`echo $f | sed 's/^std_/std::/'`
mv $f $newname
done
for f in __gnu_cxx_*; do
newname=`echo $f | sed 's/^__gnu_cxx_/__gnu_cxx::/'`
mv $f $newname
done
for f in *_libstdc__-v3_*; do
rm $f
done
for f in *_src_*; do
rm $f
done
for f in ios streambuf istream ostream iostream stringbuf \
istringstream ostringstream stringstream filebuf ifstream \
ofstream fstream string;
do
echo ".so man3/std::basic_${f}.3" > std::${f}.3
echo ".so man3/std::basic_${f}.3" > std::w${f}.3
done
echo ::
echo :: Man pages in ${outdir}/man
fi
echo ::
exit 0