]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/scripts/run_doxygen
run_doxygen: Allow doxygen 1.7.1 again.
[thirdparty/gcc.git] / libstdc++-v3 / scripts / run_doxygen
1 #!/bin/bash
2
3 # Runs doxygen and massages the output files.
4 # Copyright (C) 2001, 2002, 2003, 2004, 2008, 2009, 2010
5 # Free Software Foundation, Inc.
6 #
7 # Synopsis: run_doxygen --mode=[html|latex|man|xml] --host_alias=<alias> \
8 # v3srcdir \
9 # v3builddir \
10 # shortname
11 #
12 # Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
13
14
15 # We can check now that the version of doxygen is >= this variable.
16 DOXYVER=1.7.1
17
18 find_doxygen() {
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
22 # thank you goat book
23 set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
24 for dir
25 do
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
33 doxygen="$maybedoxy"
34 break
35 fi
36 fi
37 done
38 if test -z "$doxygen"; then
39 echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2
40 print_usage
41 fi
42 # We need to use other tools from the same package/version.
43 echo :: Using Doxygen tools from ${dir}.
44 PATH=$dir:$PATH
45 hash -r
46 }
47
48 print_usage() {
49 cat 1>&2 <<EOF
50 Usage: run_doxygen --mode=MODE --host_alias=BUILD_ALIAS [<options>]
51 <v3-src-dir> <v3-build-dir> <shortnamesp>
52 MODE is one of:
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.
57
58 BUILD_ALIAS is the GCC build alias set at configure time.
59
60 Note: Requires Doxygen ${DOXYVER} or later; get it at
61 ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
62
63 EOF
64 exit 1
65 }
66
67 parse_options() {
68 for o
69 do
70 # Blatantly ripped from autoconf, er, I mean, "gratefully standing
71 # on the shoulders of those giants who have gone before us."
72 case "$o" in
73 -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
74 *) arg= ;;
75 esac
76
77 case "$o" in
78 --mode=*)
79 mode=$arg ;;
80 --host_alias=*)
81 host_alias=$arg ;;
82 --mode | --host_alias | --help | -h)
83 print_usage ;;
84 *)
85 # this turned out to be a mess, maybe change to --srcdir=, etc
86 if test $srcdir = unset; then
87 srcdir=$o
88 elif test $outdir = unset; then
89 builddir=${o}
90 outdir=${o}/doc/doxygen
91 elif test $shortname = unset; then
92 shortname=$o
93 else
94 echo run_doxygen error: Too many arguments 1>&2
95 exit 1
96 fi
97 ;;
98 esac
99 done
100 }
101
102
103 # script begins here
104 mode=unset
105 host_alias=unset
106 srcdir=unset
107 outdir=unset
108 shortname=unset
109 do_html=false
110 do_man=false
111 do_xml=false
112 do_latex=false
113 enabled_sections=
114 generate_tagfile=
115 DATEtext=`date '+%Y-%m-%d'`
116
117 # Show how this script is called.
118 echo run_doxygen $*
119
120 parse_options $*
121 find_doxygen
122
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
126 print_usage
127 fi
128
129 case x"$mode" in
130 xhtml)
131 do_html=true
132 enabled_sections=maint
133 generate_tagfile="$outdir/html/libstdc++.tag"
134 ;;
135 xlatex)
136 do_latex=true
137 enabled_sections=maint
138 ;;
139 xman)
140 do_man=true
141 ;;
142 xxml)
143 do_xml=true
144 enabled_sections=maint
145 ;;
146 *)
147 echo run_doxygen error: $mode is an invalid mode 1>&2
148 exit 1 ;;
149 esac
150
151 case x"$shortname" in
152 xYES)
153 ;;
154 xNO)
155 ;;
156 *)
157 echo run_doxygen error: $shortname is invalid 1>&2
158 exit 1 ;;
159 esac
160
161
162 mkdir -p $outdir
163 chmod u+w $outdir
164
165 # Run it
166 (
167 set -e
168 cd $builddir
169 sed -e "s=@outdir@=${outdir}=g" \
170 -e "s=@srcdir@=${srcdir}=g" \
171 -e "s=@shortname@=${shortname}=g" \
172 -e "s=@builddir@=${builddir}=g" \
173 -e "s=@host_alias@=${host_alias}=g" \
174 -e "s=@enabled_sections@=${enabled_sections}=" \
175 -e "s=@do_html@=${do_html}=" \
176 -e "s=@do_latex@=${do_latex}=" \
177 -e "s=@do_man@=${do_man}=" \
178 -e "s=@do_xml@=${do_xml}=" \
179 -e "s=@generate_tagfile@=${generate_tagfile}=" \
180 ${srcdir}/doc/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
181 echo :: NOTE that this may take some time...
182 echo doxygen ${outdir}/${mode}.cfg
183 doxygen ${outdir}/${mode}.cfg
184 )
185 ret=$?
186 test $ret -ne 0 && exit $ret
187
188 if $do_xml; then
189 echo ::
190 echo :: XML pages begin with
191 echo :: ${outdir}/xml/index.xml
192 fi
193
194 if $do_latex; then
195 cd ${outdir}/${mode}
196
197 # Also drop in the header file and style sheet
198 doxygen -w latex header.tex doxygen.sty
199
200 echo ::
201 echo :: LaTeX pages begin with
202 echo :: ${outdir}/latex/refman.tex
203 fi
204
205 if $do_html; then
206 cd ${outdir}/${mode}
207
208 #doxytag -t libstdc++.tag . > /dev/null 2>&1
209 sed -e '/<path>/d' libstdc++.tag > TEMP
210 mv TEMP libstdc++.tag
211
212 sed -e "s=@DATE@=${DATEtext}=" \
213 ${srcdir}/doc/doxygen/mainpage.html > index.html
214
215 # The following bit of line noise changes annoying
216 # std::foo < typename _Ugly1, typename _Ugly2, .... _DefaultUgly17 >
217 # to user-friendly
218 # std::foo
219 # in the major "Compound List" page.
220 sed -e 's=\(::[[:alnum:]_]*\)&lt; .* &gt;=\1=' annotated.html > annstrip.html
221 mv annstrip.html annotated.html
222
223 cp ${srcdir}/doc/doxygen/tables.html tables.html
224
225 echo ::
226 echo :: HTML pages begin with
227 echo :: ${outdir}/html/index.html
228 fi
229
230 # Mess with the man pages. We don't need documentation of the internal
231 # headers, since the man pages for those contain nothing useful anyhow. The
232 # man pages for doxygen modules need to be renamed (or deleted). And the
233 # generated #include lines need to be changed from the internal names to the
234 # standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>").
235 if $do_man; then
236 echo ::
237 echo :: Fixing up the man pages...
238 cd $outdir/man/man3
239
240 # File names with embedded spaces (EVIL!) need to be....? renamed or removed?
241 find . -name "* *" -print0 | xargs -0r rm # requires GNU tools
242
243 # man pages are for functions/types/other entities, not source files
244 # directly. who the heck would type "man foo.h" anyhow?
245 find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
246 rm -f *.h.3 *.hpp.3 *config* *.cc.3 *.tcc.3 *_t.3
247 #rm ext_*.3 tr1_*.3 debug_*.3
248
249 # this is used to examine what we would have deleted, for debugging
250 #mkdir trash
251 #find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
252 #mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash
253
254 # Standardize the displayed header names. If anyone who knows perl cares
255 # enough to rewrite all this, feel free. This only gets run once a century,
256 # and I'm off getting coffee then anyhow, so I didn't care enough to make
257 # this super-fast.
258 g++ ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader
259 problematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
260 for f in $problematic; do
261 # this is also slow, but safe and easy to debug
262 oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f`
263 newh=`echo $oldh | ./stdheader`
264 sed "s=${oldh}=${newh}=" $f > TEMP
265 mv TEMP $f
266 done
267 rm stdheader
268
269 # Some of the pages for generated modules have text that confuses certain
270 # implementations of man(1), e.g., Linux's. We need to have another top-level
271 # *roff tag to /stop/ the .SH NAME entry.
272 problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
273 #problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
274
275 for f in $problematic; do
276 sed '/^\.SH NAME/{
277 n
278 a\
279 \
280 .SH SYNOPSIS
281 }' $f > TEMP
282 mv TEMP $f
283 done
284
285 # Also, break this (generated) line up. It's ugly as sin.
286 problematic=`grep -l '[^^]Definition at line' *.3`
287 for f in $problematic; do
288 sed 's/Definition at line/\
289 .PP\
290 &/' $f > TEMP
291 mv TEMP $f
292 done
293
294 cp ${srcdir}/doc/doxygen/Intro.3 C++Intro.3
295
296 # Why didn't I do this at the start? Were rabid weasels eating my brain?
297 # Who the fsck would "man std_vector" when the class isn't named that?
298
299 # First, deal with nested namespaces.
300 for f in *chrono_*; do
301 newname=`echo $f | sed 's/chrono_/chrono::/'`
302 mv $f $newname
303 done
304 for f in *__debug_*; do
305 newname=`echo $f | sed 's/__debug_/__debug::/'`
306 mv $f $newname
307 done
308 for f in *decimal_*; do
309 newname=`echo $f | sed 's/decimal_/decimal::/'`
310 mv $f $newname
311 done
312 for f in *__detail_*; do
313 newname=`echo $f | sed 's/__detail_/__detail::/'`
314 mv $f $newname
315 done
316 for f in *__parallel_*; do
317 newname=`echo $f | sed 's/__parallel_/__parallel::/'`
318 mv $f $newname
319 done
320 for f in *__profile_*; do
321 newname=`echo $f | sed 's/__profile_/__profile::/'`
322 mv $f $newname
323 done
324 for f in *__atomic0_*; do
325 newname=`echo $f | sed 's/__atomic0_/__atomic0::/'`
326 mv $f $newname
327 done
328 for f in *__atomic2_*; do
329 newname=`echo $f | sed 's/__atomic2_/__atomic2::/'`
330 mv $f $newname
331 done
332
333 # Then, clean up other top-level namespaces.
334 for f in std_tr1_*; do
335 newname=`echo $f | sed 's/^std_tr1_/std::tr1::/'`
336 mv $f $newname
337 done
338 for f in std_*; do
339 newname=`echo $f | sed 's/^std_/std::/'`
340 mv $f $newname
341 done
342 for f in __gnu_cxx_*; do
343 newname=`echo $f | sed 's/^__gnu_cxx_/__gnu_cxx::/'`
344 mv $f $newname
345 done
346 for f in __gnu_debug_*; do
347 newname=`echo $f | sed 's/^__gnu_debug_/__gnu_debug::/'`
348 mv $f $newname
349 done
350 for f in __gnu_parallel_*; do
351 newname=`echo $f | sed 's/^__gnu_parallel_/__gnu_parallel::/'`
352 mv $f $newname
353 done
354 for f in __gnu_profile_*; do
355 newname=`echo $f | sed 's/^__gnu_profile_/__gnu_profile::/'`
356 mv $f $newname
357 done
358 for f in __gnu_pbds_*; do
359 newname=`echo $f | sed 's/^__gnu_pbds_/__gnu_pbds::/'`
360 mv $f $newname
361 done
362 for f in __cxxabiv1_*; do
363 newname=`echo $f | sed 's/^__cxxabiv1_/abi::/'`
364 mv $f $newname
365 done
366
367 # Then piecemeal nested classes
368 for f in *__future_base_*; do
369 newname=`echo $f | sed 's/__future_base_/__future_base::/'`
370 mv $f $newname
371 done
372
373
374
375 # Generic removal bits, where there are things in the generated man
376 # pages that need to be killed.
377 for f in *_libstdc__-v3_*; do
378 rm $f
379 done
380
381 for f in *_src_*; do
382 rm $f
383 done
384
385
386 # Also, for some reason, typedefs don't get their own man pages. Sigh.
387 for f in ios streambuf istream ostream iostream stringbuf \
388 istringstream ostringstream stringstream filebuf ifstream \
389 ofstream fstream string;
390 do
391 echo ".so man3/std::basic_${f}.3" > std::${f}.3
392 echo ".so man3/std::basic_${f}.3" > std::w${f}.3
393 done
394
395 echo ::
396 echo :: Man pages in ${outdir}/man
397 fi
398
399 # all done
400 echo ::
401
402 exit 0