]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/docs/doxygen/run_doxygen
Makefile.am (doxygen, [...]): Tweak targets.
[thirdparty/gcc.git] / libstdc++-v3 / docs / doxygen / run_doxygen
1 #!/bin/sh
2
3 # Runs doxygen and massages the output files.
4 #
5 # Synopsis: run_doxygen --mode=[user|maint|man] v3srcdir v3builddir
6 #
7 # Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
8
9
10 # We can check now that the version of doxygen is >= this variable.
11 DOXYVER=1.2.12
12 doxygen=
13
14 find_doxygen() {
15 v_required=`echo $DOXYVER | \
16 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
17 testing_version=
18 # thank you goat book
19 set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
20 for dir
21 do
22 # AC_EXEEXT could come in useful here
23 maybedoxy="$dir/doxygen"
24 test -f "$maybedoxy" && testing_version=`$maybedoxy --version`
25 if test -n "$testing_version"; then
26 v_found=`echo $testing_version | \
27 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
28 if test $v_found -ge $v_required; then
29 doxygen="$maybedoxy"
30 break
31 fi
32 fi
33 done
34 if test -z "$doxygen"; then
35 echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2
36 print_usage
37 fi
38 }
39
40 print_usage() {
41 cat 1>&2 <<EOF
42 Usage: run_doxygen --mode=MODE [<options>] <v3-src-dir> <v3-build-dir>
43 MODE is one of:
44 user Generate user-level HTML library documentation.
45 maint Generate maintainers' HTML documentation (lots more;
46 exposes non-public members, etc).
47 man Generate user-level man pages.
48
49 more options when i think of them
50
51 Note: Requires Doxygen ${DOXYVER} or later; get it at
52 ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
53
54 EOF
55 exit 1
56 }
57
58 parse_options() {
59 for o
60 do
61 # Blatantly ripped from autoconf, er, I mean, "gratefully standing
62 # on the shoulders of those giants who have gone before us."
63 case "$o" in
64 -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
65 *) arg= ;;
66 esac
67
68 case "$o" in
69 --mode=*)
70 mode=$arg ;;
71 --mode | --help | -h)
72 print_usage ;;
73 *)
74 # this turned out to be a mess, maybe change to --srcdir=, etc
75 if test $srcdir = unset; then
76 srcdir=$o
77 elif test $outdir = unset; then
78 builddir=${o}
79 outdir=${o}/docs/doxygen
80 else
81 echo run_doxygen error: Too many arguments 1>&2
82 exit 1
83 fi
84 ;;
85 esac
86 done
87 }
88
89
90 # script begins here
91 mode=unset
92 srcdir=unset
93 outdir=unset
94 do_html=no
95 do_man=no
96 enabled_sections=
97
98 parse_options $*
99 find_doxygen
100
101 if test $srcdir = unset || test $outdir = unset || test $mode = unset; then
102 # this could be better
103 echo run_doxygen error: You have not given enough information...! 1>&2
104 print_usage
105 fi
106
107 case x"$mode" in
108 xuser) do_html=yes
109 ;;
110 xmaint) do_html=yes
111 enabled_sections=maint
112 ;;
113 xman) do_man=yes
114 ;;
115 *)
116 echo run_doxygen error: $mode is an invalid mode 1>&2
117 exit 1 ;;
118 esac
119
120 #rm -rf $outdir
121 mkdir -p $outdir
122 chmod u+w $outdir
123
124 # work around a stupid doxygen bug
125 test $do_man = yes && {
126 mkdir -p $outdir/man/man3/ext
127 chmod -R u+w $outdir/man/man3/ext
128 }
129
130 set -e
131 (
132 set -e
133 cd $builddir
134 sed -e "s=@outdir@=${outdir}=" \
135 -e "s=@srcdir@=${srcdir}=" \
136 -e "s=@html_output_dir@=html_${mode}=" \
137 -e "s=@enabled_sections@=${enabled_sections}=" \
138 -e "s=@do_html@=${do_html}=" \
139 -e "s=@do_man@=${do_man}=" \
140 ${srcdir}/docs/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
141 echo :: NOTE that this may take some time...
142 echo $doxygen ${outdir}/${mode}.cfg
143 $doxygen ${outdir}/${mode}.cfg
144 echo :: Finished, exit code was $?
145 )
146 set +e
147
148 test $do_html = yes && {
149 echo ::
150 echo :: HTML pages begin with
151 echo :: ${outdir}/html_${mode}/index.html
152 }
153
154 # Mess with the man pages. We don't need documentation of the internal
155 # headers, since the man pages for those contain nothing useful anyhow. The
156 # man pages for doxygen modules need to be renamed (or deleted). And the
157 # generated #include lines need to be changed from the internal names to the
158 # standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>").
159 test $do_man = yes && {
160 echo ::
161 echo :: Fixing up the man pages...
162 cd $outdir/man/man3
163
164 # here's the other end of the "stupid doxygen bug" mentioned above
165 rm -rf ext
166
167 # File names with embedded spaces (EVIL!) need to be....? renamed or removed?
168 find . -name "* *" -print0 | xargs -0 rm # requires GNU tools
169
170 # can leave SGIextensions.3 alone, it's an okay name
171 mv s20_3_1_base.3 Intro_functors.3
172 mv s20_3_2_arithmetic.3 Arithmetic_functors.3
173 mv s20_3_3_comparisons.3 Comparison_functors.3
174 mv s20_3_4_logical.3 Logical_functors.3
175 mv s20_3_5_negators.3 Negation_functors.3
176 mv s20_3_6_binder.3 Binder_functors.3
177 mv s20_3_7_adaptors.3 Func_ptr_functors.3
178 mv s20_3_8_memadaptors.3 Member_ptr_functors.3
179 mv std.3 Namespace_Std.3
180 mv iterator_tags.3 Iterator_types.3
181
182 # man pages are for functions/types/other entities, not source files
183 # directly. who the heck would type "man foo.h" anyhow?
184 find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
185 rm -f *.h.3 *config* *.cc.3 *.tcc.3
186 rm -f *_t.3 # workaround doxygen template parsing bug for now
187 #mkdir trash # this is used to examine what we would have deleted
188 #find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
189 #mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash
190
191 # Standardize the displayed header names. If anyone who knows perl cares
192 # enough to rewrite all this, feel free. This only gets run once a century,
193 # and I'm off getting coffee then anyhow, so I didn't care enough to make
194 # this super-fast.
195 g++ ${srcdir}/docs/doxygen/stdheader.cc -o ./stdheader
196 problematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
197 for f in $problematic; do
198 # this is also slow, but safe and easy to debug
199 oldh=`sed -n '/#include </s/.*<\(.*\)>.*/\1/p' $f`
200 newh=`echo $oldh | ./stdheader`
201 sed "s=${oldh}=${newh}=" $f > TEMP
202 mv TEMP $f
203 done
204 rm stdheader
205
206 # Some of the pages for generated modules have text that confuses certain
207 # implementations of man(1), e.g., Linux's. We need to have another top-level
208 # *roff tag to /stop/ the .SH NAME entry.
209 #problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
210 problematic='Containers.3 Sequences.3 Assoc_containers.3 Allocators.3'
211 for f in $problematic; do
212 sed '/^\.SH NAME/{
213 n
214 a\
215 \
216 .SH SYNOPSIS
217 }' $f > TEMP
218 mv TEMP $f
219 done
220
221 cp ${srcdir}/docs/doxygen/Intro.3 .
222
223 echo ::
224 echo :: Man pages in ${outdir}/man
225 }
226
227 # all done
228 echo ::
229
230 exit 0
231
232 # vim:ts=4:et:
233