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