fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / doc / api / doxygen.sh
blobaab94680199d8455b8ca0baee61de88732747b02
1 #! /bin/sh
3 # doxygen.sh Copyright (C) 2005 by Adriaan de Groot
4 # Based on some code from Doxyfile.am, among other things.
5 # License: GPL version 2.
6 # See file COPYING in kdelibs for details.
8 echo "*** doxygen.sh"
10 # Recurse handling is a little complicated, since normally
11 # subdir (given on the command-line) processing doesn't recurse
12 # but you can force it to do so.
13 recurse=1
14 recurse_given=NO
15 use_modulename=1
16 cleanup=YES
17 preprocess=0
18 manpages=0
20 while test -n "$1" ; do
21 case $1 in
22 --no-cleanup)
23 cleanup=NO
25 --no-recurse)
26 recurse=0
27 recurse_given=YES
29 --recurse)
30 recurse=1
31 recurse_given=YES
33 --no-modulename)
34 use_modulename=0
36 --modulename)
37 use_modulename=1
39 --preprocess)
40 preprocess=1
42 --manpages)
43 manpages=1
45 --help)
46 echo "doxygen.sh usage:"
47 echo "doxygen.sh [--options] <srcdir> [<subdir>]"
48 echo " --no-cleanup Do not remove Doxyfile and other cruft from build"
49 echo " --no-recurse Build only the given top-level directory"
50 echo " --no-modulename Build in apidocs/, not apidocs-module/"
51 echo " --doxdatadir=dir Use dir as the source of global Doxygen files"
52 echo " --installdir=dir Use dir as target to install to"
53 echo " --preprocess Generate source code (KConfigXT, uic, etc.)"
54 echo " --manpages Generate man pages in addition to html"
55 exit 2
57 --doxdatadir=*)
58 DOXDATA=`echo $1 | sed -e 's+--doxdatadir=++'`
60 --installdir=*)
61 PREFIX=`echo $1 | sed -e 's+--installdir=++'`
63 --*)
64 echo "Unknown option: $1"
65 exit 1
68 top_srcdir="$1"
69 break
71 esac
72 shift
73 done
76 ### Sanity check the mandatory "top srcdir" argument.
77 if test -z "$top_srcdir" ; then
78 echo "Usage: doxygen.sh <top_srcdir>"
79 exit 1
81 if test ! -d "$top_srcdir" ; then
82 echo "top_srcdir ($top_srcdir) is not a directory."
83 exit 1
86 ### Normalize top_srcdir so it is an absolute path.
87 if expr "x$top_srcdir" : "x/" > /dev/null ; then
88 # top_srcdir is absolute already
90 else
91 top_srcdir=`cd "$top_srcdir" 2> /dev/null && pwd`
92 if test ! -d "$top_srcdir" ; then
93 echo "top_srcdir ($top_srcdir) is not a directory."
94 exit 1
98 ### Normalize DOXDATA so it is an absolute path.
99 if test -n "$DOXDATA"; then
100 if expr "x$DOXDATA" : "x/" > /dev/null ; then
101 # DOXDATA is absolute already
103 else
104 DOXDATA=`cd "$DOXDATA" 2> /dev/null && pwd`
105 if test ! -d "$DOXDATA" ; then
106 echo "DOXDATA ($DOXDATA) is not a directory."
107 exit 1
113 ### Sanity check and guess QTDOCDIR.
114 if test -z "$QTDOCDIR" ; then
115 if test -z "$QTDIR" ; then
116 for i in /usr/X11R6/share/doc/qt/html
118 QTDOCDIR="$i"
119 test -d "$QTDOCDIR" && break
120 done
121 else
122 for i in share/doc/qt/html doc/html
124 QTDOCDIR="$QTDIR/$i"
125 test -d "$QTDOCDIR" && break
126 done
129 if test -z "$QTDOCDIR" || test ! -d "$QTDOCDIR" ; then
130 if test -z "$QTDOCDIR" ; then
131 echo "* QTDOCDIR could not be guessed."
132 else
133 echo "* QTDOCDIR does not name a directory."
135 if test -z "$QTDOCTAG" ; then
136 echo "* QTDOCDIR set to \"\""
137 QTDOCDIR=""
138 else
139 echo "* But I'll use $QTDOCDIR anyway because of QTDOCTAG."
143 ### Get the "top srcdir", also its name, and handle the case that subdir "."
144 ### is given (which would be top_srcdir then, so it's equal to none-given
145 ### but no recursion either).
147 # top_srcdir="$1" # Already set by options processing
148 module_name=`basename "$top_srcdir"`
149 subdir="$2"
150 if test "x." = "x$subdir" ; then
151 subdir=""
152 if test "x$recurse_given" = "xNO" ; then
153 recurse=0
156 if test "x" != "x$subdir" ; then
157 # If no recurse option given explicitly, default to
158 # no recurse when processing subdirs given on the command-line.
159 if test "x$recurse_given" = "xNO" ; then
160 recurse=0
164 if test -z "$DOXDATA" || test ! -d "$DOXDATA" ; then
165 if test -n "$DOXDATA" ; then
166 echo "* \$DOXDATA is '$DOXDATA' which does not name a directory"
168 DOXDATA="$top_srcdir/doc/common"
171 if test ! -d "$DOXDATA" ; then
172 echo "* \$DOXDATA does not name a directory ( or is unset ), tried \"$DOXDATA\""
173 exit 1
176 if test -n "$PREFIX" && test ! -d "$PREFIX" ; then
177 echo "* \$PREFIX does not name a directory, tried \"$PREFIX\""
178 echo "* \$PREFIX is disabled."
179 PREFIX=""
182 TOPNAME=`grep '^/.*DOXYGEN_NAME' "$top_srcdir/Mainpage.dox" | sed -e 's+.*=++' | sed s+\"++g`
183 if test -z "$TOPNAME" ; then
184 TOPNAME="API Reference"
187 COPYRIGHT=`grep '^/.*DOXYGEN_COPYRIGHT' "$top_srcdir/Mainpage.dox" | sed -e 's+[^=]*=++' | sed s+\"++g`
188 if test -z "$COPYRIGHT" ; then
189 COPYRIGHT="1996-`date +%Y` The KDE developers"
193 # Preprocess source dir and generate source files (KConfigXT, uic, etc.)
194 # @param $1: create or cleanup (parameter for doxygen-preprocess-foo.sh)
196 preprocess_sources()
198 for dir in `find $top_srcdir/$subdir -type d | grep -v ".svn"`; do
199 # execute global preprocessing modules
200 local preproc_base="`dirname $0`"
201 for proc in `find "$preproc_base" -name "doxygen-preprocess-*.sh"`; do
202 (cd $dir && $proc $1)
203 done
204 # execute local preprocessing modules
205 for proc in `find $dir -maxdepth 1 -name "doxygen-preprocess-*.sh"`; do
206 echo "* running $proc"
207 (cd $dir && $proc $1)
208 done
209 done
212 if test "$preprocess" = "1"; then
213 echo "* Generating source code in $top_srcdir/$subdir"
214 preprocess_sources create
215 echo "* Generating source code completed"
218 ### We need some values from top-level files, which
219 ### are not preserved between invocations of this
220 ### script, so factor it out for easy use.
221 create_doxyfile_in()
223 VERSION=`grep '^/.*DOXYGEN_VERSION' "$top_srcdir/Mainpage.dox" | sed -e 's+.*=++'`
224 NAME=`grep '^/.*DOXYGEN_NAME' "$top_srcdir/Mainpage.dox" | sed -e 's+.*=++'`
225 echo "PROJECT_NUMBER = $VERSION" > Doxyfile.in
226 echo "PROJECT_NAME = $NAME" >> Doxyfile.in
229 apidoxdir="$module_name"-apidocs
230 test "x$use_modulename" = "x0" && apidoxdir="apidocs"
232 ### If we're making the top subdir, create the structure
233 ### for the apidox and initialize it. Otherwise, just use the
234 ### structure assumed to be there.
235 if test -z "$subdir" ; then
236 if test ! -d "$apidoxdir" ; then
237 mkdir "$apidoxdir" > /dev/null 2>&1
239 cd "$apidoxdir" > /dev/null 2>&1 || {
240 echo "Cannot create and cd into $apidoxdir"
241 exit 1
244 test -f "Doxyfile.in" || create_doxyfile_in
246 # Copy in logos and the like
247 for i in "favicon.ico" "block_title_bottom.png" "block_title_mid.png" "block_title_top.png" "top-kde.jpg" "top-left.jpg" "top-right.jpg" "top.jpg" "kde.css" "flat.css" "print.css" "tabs.css"
249 cp "$DOXDATA/$i" . > /dev/null 2> /dev/null
250 done
251 for i in "$top_srcdir/doc/api/Dox-"*.png
253 T=`basename "$i" | sed -e 's+Dox-++'`
254 test -f "$i" && cp "$i" "./$T" > /dev/null 2> /dev/null
255 done
257 top_builddir="."
258 srcdir="$1"
259 subdir="."
260 else
261 cd "$apidoxdir" > /dev/null 2>&1 || {
262 echo "Cannot cd into $apidoxdir -- maybe you need to"
263 echo "build the top-level dox first."
264 exit 1
267 if test "x1" = "x$recurse" ; then
268 # OK, so --recurse was requested
269 if test ! -f "subdirs.top" ; then
270 echo "* No subdirs.top available in the $apidoxdir."
271 echo "* The --recurse option will be ignored."
272 recurse=0
277 ### Read a single line (TODO: support \ continuations) from the Mainpage.dox.
278 ### Used to extract variable assignments from it.
279 extract_line()
281 file="$2" ; test -z "$file" && file="$srcdir/Mainpage.dox"
282 test -f "$file" || return
283 pattern=`echo "$1" | tr + .`
284 grep "^//[[:space:]]*$1" "$file" | \
285 sed -e "s+//[[:space:]]*$pattern.*=[[:space:]]*++"
288 ### Try to order the top-level subdirectories so that we get the smallest
289 ### amount of re-processing due to missing tag files.
290 create_subdirs()
292 echo "* Sorting top-level subdirs"
294 ( cd "$top_srcdir" &&
295 for dir in *
297 # For each Mainpage.dox, get the list (possibly empty) of
298 # referenced tag files.
299 list=""
300 if test -d "$dir" && test -f "$dir/Mainpage.dox" ; then
301 # Need this dir at the very least, even if it doesn't reference
302 echo "$dir" "$dir"
303 list=`grep DOXYGEN_REFERENCES $dir/Mainpage.dox | sed 's/.*=//'`
306 # Print the partial order pairs that we now know. This
307 # is *expected* to produce loops in the partial order;
308 # these cannot be avoided.
309 for req in $list ; do
310 echo $req $dir
311 done
313 done ) | grep -v / | tsort 2> /dev/null > subdirs.top
317 apidox_manpages()
319 mp=`extract_line DOXYGEN_GENERATE_MAN`
320 if test -z "$mp" ; then
321 mp="YES"
323 echo "GENERATE_MAN = $mp" >> "$subdir/Doxyfile"
324 echo "MAN_OUTPUT = man" >> "$subdir/Doxyfile"
325 echo "MAN_EXTENSION = .3" >> "$subdir/Doxyfile"
326 echo "MAN_LINKS = YES" >> "$subdir/Doxyfile"
329 ### Add HTML header, footer, CSS tags to Doxyfile.
330 ### Assumes $subdir is set. Argument is a string
331 ### to stick in front of the file if needed.
332 apidox_htmlfiles()
334 dox_header="$top_srcdir/doc/api/$1header.html"
335 dox_footer="$top_srcdir/doc/api/$1footer.html"
336 dox_css="$top_srcdir/doc/api/doxygen.css"
337 test -f "$dox_header" || dox_header="$DOXDATA/$1header.html"
338 test -f "$dox_footer" || dox_footer="$DOXDATA/$1footer.html"
339 test -f "$dox_css" || dox_css="$DOXDATA/doxygen.css"
341 echo "HTML_HEADER = $dox_header" >> "$subdir/Doxyfile" ; \
342 echo "HTML_FOOTER = $dox_footer" >> "$subdir/Doxyfile" ; \
343 echo "HTML_STYLESHEET = $dox_css" >> "$subdir/Doxyfile"
346 apidox_specials()
348 line=`extract_line DOXYGEN_PROJECTNAME "$1"`
349 test -n "$line" && echo "PROJECT_NAME = \"$line\"" >> "$2"
350 line=`extract_line DOXYGEN_PROJECTVERSION "$1"`
351 test -n "$line" && echo "PROJECT_NUMBER = \"$line\"" >> "$2"
354 apidox_local()
356 for i in "$top_srcdir/doc/api/Doxyfile.local"
358 if test -f "$i" ; then
359 cat "$i" >> "$subdir/Doxyfile"
360 break
362 done
365 ### Post-process HTML files by substituting in the menu files
367 # In non-top directories, both <!-- menu --> and <!-- gmenu -->
368 # are calculated and replaced. Top directories get an empty <!-- menu -->
369 # if any.
370 doxyndex()
372 # Special case top-level to have an empty MENU.
373 if test "x$subdir" = "x." ; then
374 MENU=""
375 htmldir="."
376 htmltop="$top_builddir" # Just ., presumably
377 echo "* Post-processing top-level files"
378 else
379 MENU="<ul>"
380 htmldir="$subdir/html"
381 htmltop="$top_builddir.." # top_builddir ends with /
382 echo "* Post-processing files in $htmldir"
384 # Build a little PHP file that maps class names to file
385 # names, for the quick-class-picker functionality.
386 # (The quick-class-picker is disabled due to styling
387 # problems in IE & FF).
389 echo "<?php \$map = array("; \
390 for htmlfile in `find $htmldir/ -type f -name "class[A-Z]*.html" | grep -v "\-members.html$"`; do
391 classname=`echo $htmlfile | sed -e "s,.*/class\\(.*\\).html,\1," -e "s,_1_1,::,g" -e "s,_01, ,g" -e "s,_4,>,g" -e "s+_00+,+g" -e "s+_3+<+g" | tr "[A-Z]" "[a-z]"`
392 echo " \"$classname\" => \"$htmlfile\","
393 done | sort ; \
394 echo ") ?>"
395 ) > "$subdir/classmap.inc"
397 # This is a list of pairs, with / separators so we can use
398 # basename and dirname (a crude shell hack) to split them
399 # into parts. For each, if the file part exists (as a html
400 # file) tack it onto the MENU variable as a <li> with link.
401 for i in "Main Page/index" \
402 "Modules/modules" \
403 "Namespace List/namespaces" \
404 "Class Hierarchy/hierarchy" \
405 "Alphabetical List/classes" \
406 "Class List/annotated" \
407 "File List/files" \
408 "Directories/dirs" \
409 "Namespace Members/namespacemembers" \
410 "Class Members/functions" \
411 "Related Pages/pages"
413 NAME=`dirname "$i"`
414 FILE=`basename "$i"`
415 test -f "$htmldir/$FILE.html" && MENU="$MENU<li><a href=\"$FILE.html\">$NAME</a></li>"
416 done
418 MENU="$MENU</ul>"
422 # Get the list of global Menu entries.
423 GMENU=`cat subdirs | tr -d '\n'`
425 PMENU=`grep '<!-- pmenu' "$htmldir/index.html" | sed -e 's+.*pmenu *++' -e 's+ *-->++' | awk '{ c=split($0,a,"/"); for (j=1; j<=c; j++) { printf " / <a href=\""; if (j==c) { printf("./index.html"); } for (k=j; k<c; k++) { printf "../index.html"; } if (j<c) { printf("../html/index.html"); } printf "\">%s</a>\n" , a[j]; } }' | tr -d '\n'`
427 # Map the PHP file into HTML options so that
428 # it can be substituted in for the quick-class-picker.
429 CMENU=""
430 # For now, leave the CMENU disabled
431 CMENUBEGIN="<!--"
432 CMENUEND="-->"
434 if test "x$subdir" = "x." ; then
435 # Disable CMENU on toplevel anyway
436 CMENUBEGIN="<!--"
437 CMENUEND="-->"
438 else
439 test -f "$subdir/classmap.inc" && \
440 CMENU=`grep '=>' "$subdir/classmap.inc" | sed -e 's+"\([^"]*\)" => "'"$subdir/html/"'\([^"]*\)"+<option value="\2">\1<\/option>+' | tr -d '\n'`
442 if test -f "$subdir/classmap.inc" && grep "=>" "$subdir/classmap.inc" > /dev/null 2>&1 ; then
443 # Keep the menu, it's useful
445 else
446 CMENUBEGIN="<!--"
447 CMENUEND="-->"
451 # Now substitute in the MENU in every file. This depends
452 # on HTML_HEADER (ie. header.html) containing the
453 # <!-- menu --> comment.
454 for i in "$htmldir"/*.html
456 if test -f "$i" ; then
457 sed -e "s+<!-- menu -->+$MENU+" \
458 -e "s+<!-- gmenu -->+$GMENU+" \
459 -e "s+<!-- pmenu.*-->+$PMENU+" \
460 -e "s+<!-- cmenu.begin -->+$CMENUBEGIN+" \
461 -e "s+<!-- cmenu.end -->+$CMENUEND+" \
462 < "$i" | sed -e "s+@topdir@+$htmltop+g" | sed -e "s+@topname@+$TOPNAME+g" | sed -e "s+@copyright@+$COPYRIGHT+g" > "$i.new" && mv "$i.new" "$i"
463 sed -e "s+<!-- cmenu -->+$CMENU+" < "$i" > "$i.new"
464 test -s "$i.new" && mv "$i.new" "$i"
465 echo "* Added menus to $i"
467 done
469 ## Allen: Comment this out for now.
470 ## Basically, I think it's annoying. We need something less obtrusive.
471 ## # For each class, post-process it to check for bc-ness
472 ## for i in "$htmldir"/class*.html
473 ## do
474 ## test "$htmldir/classes.html" = "$i" && continue
475 ## if test -f "$i" ; then
476 ## grep -l 'bc.html#_bc' "$i" > /dev/null || \
477 ## { sed -e 's+<!-- BC -->+<div class="bic">This class is not guaranteed to be binary compatible across releases.</div>+' "$i" > "$i.new" ; test -s "$i.new" && mv "$i.new" "$i" ; }
478 ## echo "* Added BC warning to $i"
479 ## fi
480 ## done
488 ### Handle the Doxygen processing of a toplevel directory.
489 apidox_toplevel()
491 echo ""
492 echo "*** Creating API documentation main page for $module_name"
493 echo "*"
494 #rm -f "Doxyfile"
495 for i in "$top_srcdir/doc/api/Doxyfile.global" \
496 "$DOXDATA/Doxyfile.global"
498 if test -f "$i" ; then
499 cp "$i" Doxyfile
500 break
502 done
504 if test ! -f "Doxyfile" ; then
505 echo "* Cannot create Doxyfile."
506 exit 1
509 cat "$top_builddir/Doxyfile.in" >> Doxyfile
513 echo "INPUT = $top_srcdir"
514 echo "DOTFILE_DIRS = $top_srcdir"
515 echo "OUTPUT_DIRECTORY = $top_builddir"
516 echo "RECURSIVE = NO"
517 echo "ALPHABETICAL_INDEX = NO"
518 echo "HTML_OUTPUT = ."
519 } >> Doxyfile
520 apidox_htmlfiles "main"
521 if test "$manpages" = "1"; then
522 apidox_manpages
525 # KDevelop has a top-level Makefile.am with settings.
526 for i in "$top_srcdir/Mainpage.dox"
528 if test -f "$i" ; then
529 grep '^//[[:space:]]*DOXYGEN_SET_' "$i" | \
530 sed -e 's+//[[:space:]]*DOXYGEN_SET_++' -e "s+@topdir@+$top_srcdir+g" >> Doxyfile
531 apidox_specials "$srcdir/Mainpage.dox" "$subdir/Doxyfile"
533 break
535 done
537 apidox_local
539 doxygen Doxyfile
541 ( cd "$top_srcdir" && find . -name Mainpage.dox ) | sed -e 's+/Mainpage.dox$++' -e 's+^\./++' | sort > subdirs.in
542 for i in `cat subdirs.in`
544 test "x." = "x$i" && continue;
546 dir=`dirname "$i"`
547 file=`basename "$i"`
548 if test "x." = "x$dir" ; then
549 dir=""
550 else
551 dir="$dir/"
553 indent=`echo "$dir" | sed -e 's+[^/]*/+\&nbsp;\&nbsp;+g' | sed -e 's+&+\\\&+g'`
554 entryname=`extract_line DOXYGEN_SET_PROJECT_NAME "$top_srcdir/$dir/$file/Mainpage.dox"`
555 test -z "$entryname" && entryname="$file"
557 if grep DOXYGEN_EMPTY "$top_srcdir/$dir/$file/Mainpage.dox" > /dev/null 2>&1 ; then
558 echo "<li>$indent$file</li>"
559 else
560 echo "<li>$indent<a href=\"@topdir@/$dir$file/html/index.html\">$entryname</a></li>"
562 done > subdirs
564 doxyndex
567 ### Handle the Doxygen processing of a non-toplevel directory.
569 # $1 is empty to generate tag files only.
570 # $1 is non-empty to generate HTML.
572 # Additionally, the environment variable $NO_APPEND_TAG may be set
573 # to a non-empty value to suppress adding the tag for this subdir
574 # to the list of tag files (used when re-generating a single subdir).
576 apidox_subdir()
578 echo ""
579 if test -z "$1" ; then
580 echo "*** Creating tag file in $subdir"
581 else
582 echo "*** Creating apidox in $subdir"
584 echo "*"
585 #rm -f "$subdir/Doxyfile"
586 if test ! -d "$top_srcdir/$subdir" ; then
587 echo "* No source (sub)directory $subdir"
588 return
590 for i in "$top_srcdir/doc/api/Doxyfile.global" \
591 "$DOXDATA/Doxyfile.global"
593 if test -f "$i" ; then
594 cp "$i" "$subdir/Doxyfile"
595 break
597 done
600 test -f "Doxyfile.in" || create_doxyfile_in
601 cat "Doxyfile.in" >> "$subdir/Doxyfile"
604 echo "PROJECT_NAME = \"$subdir\""
605 if test -d "$top_srcdir/doc/common" ; then
606 echo "INPUT = $top_srcdir/doc/common $srcdir"
607 else
608 echo "INPUT = $srcdir"
610 echo "DOTFILE_DIRS = $top_srcdir $srcdir"
611 echo "OUTPUT_DIRECTORY = ."
612 if grep -l "$subdir/" subdirs.in > /dev/null 2>&1 ; then
613 echo "RECURSIVE = NO"
615 echo "HTML_OUTPUT = $subdir/html"
616 if test -d "$top_srcdir/doc/api"; then
617 echo "IMAGE_PATH = $top_srcdir/doc/api $srcdir $srcdir/doc/pics"
618 echo "EXAMPLE_PATH = $top_srcdir/doc/api/examples $srcdir/examples $srcdir/doc/examples"
619 else
620 echo "IMAGE_PATH = $srcdir $srcdir/doc/pics"
621 echo "EXAMPLE_PATH = $srcdir/examples $srcdir/doc/examples"
623 } >> "$subdir/Doxyfile"
625 apidox_htmlfiles ""
626 if test "$manpages" = "1"; then
627 apidox_manpages
630 # Mainpage.doxs may contain overrides to our settings,
631 # so copy them in.
632 grep '^//[[:space:]]*DOXYGEN_SET_' "$srcdir/Mainpage.dox" | \
633 sed -e 's+//[[:space:]]*DOXYGEN_SET_++' -e "s+@topdir@+$top_srcdir+g" >> "$subdir/Doxyfile"
634 apidox_specials "$srcdir/Mainpage.dox" "$subdir/Doxyfile"
636 excludes=`extract_line DOXYGEN_EXCLUDE`
637 if test -n "$excludes"; then
638 patterns=""
639 dirs=""
640 for item in `echo "$excludes"`; do
641 if test -d "$top_srcdir/$subdir/$item"; then
642 dirs="$dirs $top_srcdir/$subdir/$item/"
643 else
644 patterns="$patterns $item"
646 done
647 echo "EXCLUDE_PATTERNS += $patterns" >> "$subdir/Doxyfile"
648 echo "EXCLUDE += $dirs" >> "$subdir/Doxyfile"
651 echo "TAGFILES = \\" >> "$subdir/Doxyfile"
652 ## For now, don't support \ continued references lines
653 tags=`extract_line DOXYGEN_REFERENCES`
654 for i in $tags qt ; do
655 tagsubdir=`dirname $i` ; tag=`basename $i`
656 tagpath=""
657 not_found=""
659 if test "x$tagsubdir" = "x." ; then
660 tagsubdir=""
661 else
662 tagsubdir="$tagsubdir/"
665 # Find location of tag file
666 if test -f "$tagsubdir$tag/$tag.tag" ; then
667 file="$tagsubdir$tag/$tag.tag"
668 loc="$tagsubdir$tag/html"
669 else
670 # This checks for dox built with_out_ --no-modulename
671 # in the same build dir as this dox run was started in.
672 file=`ls -1 ../*-apidocs/"$tagsubdir$tag/$tag.tag" 2> /dev/null`
674 if test -n "$file" ; then
675 loc=`echo "$file" | sed -e "s/$tag.tag\$/html/"`
676 else
677 # If the tag file doesn't exist yet, but should
678 # because we have the right dirs here, queue
679 # this directory for re-processing later.
680 if test -d "$top_srcdir/$tagsubdir$tag" ; then
681 echo "* Need to re-process $subdir for tag $i"
682 echo "$subdir" >> "subdirs.later"
683 else
684 # Re-check in $PREFIX if needed.
685 test -n "$PREFIX" && \
686 file=`cd "$PREFIX" && \
687 ls -1 *-apidocs/"$tagsubdir$tag/$tag.tag" 2> /dev/null`
689 # If something is found, patch it up. The location must be
690 # relative to the installed location of the dox and the
691 # file must be absolute.
692 if test -n "$file" ; then
693 loc=`echo "../$file" | sed -e "s/$tag.tag\$/html/"`
694 file="$PREFIX/$file"
695 echo "* Tags for $tagsubdir$tag will only work when installed."
696 not_found="YES"
701 if test "$tag" = "qt" ; then
702 if test -z "$QTDOCDIR" ; then
703 echo " $file" >> "$subdir/Doxyfile"
704 else
705 if test -z "$file" ; then
706 # Really no Qt tags
707 echo "\\" >> "$subdir/Doxyfile"
708 else
709 echo " $file=$QTDOCDIR \\" >> "$subdir/Doxyfile"
712 else
713 if test -n "$file" ; then
714 test -z "$not_found" && echo "* Found tag $file"
715 echo " $file=../$top_builddir$loc \\" >> "$subdir/Doxyfile"
718 done
720 if test -z "$1" ; then
721 echo "" >> "$subdir/Doxyfile"
722 echo "GENERATE_HTML=NO" >> "$subdir/Doxyfile"
723 echo "GENERATE_TAGFILE=$subdir/$subdirname.tag" >> "$subdir/Doxyfile"
724 test -z "$NO_APPEND_TAG" && echo " $subdir/$subdirname.tag \\" >> subdirs.tag
725 else
726 #test -s subdirs.tag && grep -v "$subdir/$subdirname.tag" subdirs.tag >> "$subdir/Doxyfile"
727 echo "" >> "$subdir/Doxyfile"
728 echo "GENERATE_HTML=YES" >> "$subdir/Doxyfile"
731 apidox_local
733 if grep '^DOXYGEN_EMPTY' "$srcdir/Mainpage.dox" > /dev/null 2>&1 ; then
734 # This directory is empty, so don't process it, but
735 # *do* handle subdirs that might have dox.
737 else
738 # Regular processing
739 doxygen "$subdir/Doxyfile"
740 if test -n "$1" ; then
741 doxyndex
746 ### Run a given subdir by setting up global variables first.
748 # $1 is the subdir to process
749 # $2 is the flag for apidox_subdir
751 do_subdir()
753 local subdir=`echo "$1" | sed -e 's+/$++'`
754 srcdir="$top_srcdir/$subdir"
755 subdirname=`basename "$subdir"`
756 mkdir -p "$subdir" 2> /dev/null
757 if test ! -d "$subdir" ; then
758 echo "Can't create dox subdirectory $subdir"
759 return
761 top_builddir=`echo "/$subdir" | sed -e 's+/[^/]*+../+g'`
762 apidox_subdir "$2"
766 ### Create installdox-slow in the toplevel
767 create_installdox()
769 # Fix up the installdox script so it accepts empty args
771 # This code is copied from the installdox generated by Doxygen,
772 # copyright by Dimitri van Heesch and released under the GPL.
773 # This does a _slow_ update of the dox, because it loops
774 # over the given substitutions instead of assuming all the
775 # needed ones are given.
777 cat <<\EOF
778 #! /usr/bin/env perl
780 %subst = () ;
781 $quiet = 0;
783 if (open(F,"search.cfg"))
785 $_=<F> ; s/[ \t\n]*$//g ; $subst{"_doc"} = $_;
786 $_=<F> ; s/[ \t\n]*$//g ; $subst{"_cgi"} = $_;
789 while ( @ARGV ) {
790 $_ = shift @ARGV;
791 if ( s/^-// ) {
792 if ( /^l(.*)/ ) {
793 $v = ($1 eq "") ? shift @ARGV : $1;
794 ($v =~ /\/$/) || ($v .= "/");
795 $_ = $v;
796 if ( /(.+)\@(.+)/ ) {
797 $subst{$1} = $2;
798 } else {
799 print STDERR "Argument $_ is invalid for option -l\n";
800 &usage();
803 elsif ( /^q/ ) {
804 $quiet = 1;
806 elsif ( /^\?|^h/ ) {
807 &usage();
809 else {
810 print STDERR "Illegal option -$_\n";
811 &usage();
814 else {
815 push (@files, $_ );
820 if ( ! @files ) {
821 if (opendir(D,".")) {
822 foreach $file ( readdir(D) ) {
823 $match = ".html";
824 next if ( $file =~ /^\.\.?$/ );
825 ($file =~ /$match/) && (push @files, $file);
826 ($file =~ "tree.js") && (push @files, $file);
828 closedir(D);
832 if ( ! @files ) {
833 print STDERR "Warning: No input files given and none found!\n";
836 foreach $f (@files)
838 if ( ! $quiet ) {
839 print "Editing: $f...\n";
841 $oldf = $f;
842 $f .= ".bak";
843 unless (rename $oldf,$f) {
844 print STDERR "Error: cannot rename file $oldf\n";
845 exit 1;
847 if (open(F,"<$f")) {
848 unless (open(G,">$oldf")) {
849 print STDERR "Error: opening file $oldf for writing\n";
850 exit 1;
852 if ($oldf ne "tree.js") {
853 while (<F>) {
854 foreach $sub (keys %subst) {
855 s/doxygen\=\"$sub\:([^ \"\t\>\<]*)\" (href|src)=\"\1/doxygen\=\"$sub:$subst{$sub}\" \2=\"$subst{$sub}/g;
856 print G "$_";
860 else {
861 while (<F>) {
862 foreach $sub (keys %subst) {
863 s/\"$sub\:([^ \"\t\>\<]*)\", \"\1/\"$sub:$subst{$sub}\" ,\"$subst{$sub}/g;
864 print G "$_";
869 else {
870 print STDERR "Warning file $f does not exist\n";
872 unlink $f;
875 sub usage {
876 print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n";
877 print STDERR "Options:\n";
878 print STDERR " -l tagfile\@linkName tag file + URL or directory \n";
879 print STDERR " -q Quiet mode\n\n";
880 exit 1;
885 # Do only the subdirs that match the RE passed in as $1
886 do_subdirs_re()
888 RE=`echo "$1" | sed -e 's+/$++'`
890 # Here's a queue of dirs to re-process later when
891 # all the rest have been done already.
892 > subdirs.later
894 # subdirs.top lists _all_ subdirs of top in the order they
895 # should be handled; subdirs.in lists those dirs that contain
896 # dox. So the intersection of the two is the ordered list
897 # of top-level subdirs that contain dox.
899 # subdirs.top also doesn't contain ".", so that special
900 # case can be ignored in the loop.
904 for i in `grep "^$RE" subdirs.top`
906 if test "x$i" = "x." ; then
907 continue
909 # Calculate intersection of this element and the
910 # set of dox dirs.
911 if grep "^$i\$" subdirs.in > /dev/null 2>&1 ; then
912 echo "$i"
913 mkdir -p "$i" 2> /dev/null
915 # Handle the subdirs of this one
916 for j in `grep "$i/" subdirs.in`
918 echo "$j"
919 mkdir -p "$j" 2> /dev/null
920 done
922 done
924 # Now we still need to handle whatever is left
925 for i in `cat subdirs.in`
927 test -d "$i" || echo "$i"
928 mkdir -p "$i" 2> /dev/null
929 done
930 ) > subdirs.sort
932 # Run once for the tags
933 for i in `cat subdirs.sort`
935 do_subdir "$i"
936 done
938 # Run again for the HTML
939 for i in `cat subdirs.sort`
941 do_subdir "$i" true
942 done
946 if test "x." = "x$top_builddir" ; then
947 apidox_toplevel
948 create_subdirs
949 create_installdox > installdox-slow
950 if test "x$recurse" = "x1" ; then
951 if test "x$module_name" = "xkdelibs" ; then
952 if test -z "$QTDOCTAG" && test -d "$QTDOCDIR" && \
953 test ! -f "qt/qt.tag" ; then
954 # Special case: create a qt tag file.
955 echo "*** Creating a tag file for the Qt library:"
956 mkdir qt
957 doxytag -t qt/qt.tag "$QTDOCDIR" > /dev/null 2>&1
960 if test -n "$QTDOCTAG" && test -r "$QTDOCTAG" ; then
961 echo "*** Copying tag file for the Qt library:"
962 mkdir qt
963 cp "$QTDOCTAG" qt/qt.tag
966 do_subdirs_re "."
969 else
970 if test "x$recurse" = "x1" ; then
971 do_subdirs_re "$subdir"
972 else
973 NO_APPEND_TAG=true do_subdir "$subdir"
974 do_subdir "$subdir" true
979 # At the end of a run, clean up stuff.
980 if test "YES" = "$cleanup" ; then
981 rm -f subdirs.in subdirs.later subdirs.sort subdirs.top Doxyfile.in
982 #rm -f `find . -name Doxyfile`
983 # rm -f qt/qt.tag
984 # rmdir qt > /dev/null 2>&1
985 if test "$preprocess" = "1"; then
986 echo "* Cleaning up previously generated source code in $top_srcdir/$subdir"
987 preprocess_sources cleanup
988 echo "* Cleaning up previously generated source code done"
993 exit 0