Put the language option into a QString right from the beginning.
[kdbg.git] / admin / doxygen.sh
blob3e233d705de2e05b1988a721bdb6389baf07e755
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
18 while test -n "$1" ; do
19 case "x$1" in
20 "x--no-cleanup" )
21 cleanup=NO
23 "x--no-recurse" )
24 recurse=0
25 recurse_given=YES
27 "x--recurse" )
28 recurse=1
29 recurse_given=YES
31 "x--no-modulename" )
32 use_modulename=0
34 "x--modulename" )
35 use_modulename=1
37 "x--help" )
38 echo "doxygen.sh usage:"
39 echo "doxygen.sh [--no-recurse] [--no-modulename] <srcdir> [<subdir>]"
40 exit 2
42 x--doxdatadir=* )
43 DOXDATA=`echo $1 | sed -e 's+--doxdatadir=++'`
45 x--installdir=*)
46 PREFIX=`echo $1 | sed -e 's+--installdir=++'`
48 x--* )
49 echo "Unknown option: $1"
50 exit 1
52 * )
53 top_srcdir="$1"
54 break
56 esac
57 shift
58 done
61 ### Sanity check the mandatory "top srcdir" argument.
62 if test -z "$top_srcdir" ; then
63 echo "Usage: doxygen.sh <top_srcdir>"
64 exit 1
66 if test ! -d "$top_srcdir" ; then
67 echo "top_srcdir ($top_srcdir) is not a directory."
68 exit 1
71 ### Normalize top_srcdir so it is an absolute path.
72 if expr "x$top_srcdir" : "x/" > /dev/null ; then
73 # top_srcdir is absolute already
75 else
76 top_srcdir=`cd "$top_srcdir" 2> /dev/null && pwd`
77 if test ! -d "$top_srcdir" ; then
78 echo "top_srcdir ($top_srcdir) is not a directory."
79 exit 1
85 ### Sanity check and guess QTDOCDIR.
86 if test -z "$QTDOCDIR" ; then
87 if test -z "$QTDIR" ; then
88 for i in /usr/X11R6/share/doc/qt/html
90 QTDOCDIR="$i"
91 test -d "$QTDOCDIR" && break
92 done
93 else
94 for i in share/doc/qt/html doc/html
96 QTDOCDIR="$QTDIR/$i"
97 test -d "$QTDOCDIR" && break
98 done
101 if test -z "$QTDOCDIR" || test ! -d "$QTDOCDIR" ; then
102 if test -z "$QTDOCDIR" ; then
103 echo "* QTDOCDIR could not be guessed."
104 else
105 echo "* QTDOCDIR does not name a directory."
107 if test -z "$QTDOCTAG" ; then
108 echo "* QTDOCDIR set to \"\""
109 QTDOCDIR=""
110 else
111 echo "* But I'll use $QTDOCDIR anyway because of QTDOCTAG."
115 ### Get the "top srcdir", also its name, and handle the case that subdir "."
116 ### is given (which would be top_srcdir then, so it's equal to none-given
117 ### but no recursion either).
119 # top_srcdir="$1" # Already set by options processing
120 module_name=`basename "$top_srcdir"`
121 subdir="$2"
122 if test "x." = "x$subdir" ; then
123 subdir=""
124 if test "x$recurse_given" = "xNO" ; then
125 recurse=0
128 if test "x" != "x$subdir" ; then
129 # If no recurse option given explicitly, default to
130 # no recurse when processing subdirs given on the command-line.
131 if test "x$recurse_given" = "xNO" ; then
132 recurse=0
136 if test -z "$DOXDATA" || test ! -d "$DOXDATA" ; then
137 if test -n "$DOXDATA" ; then
138 echo "* \$DOXDATA is '$DOXDATA' which does not name a directory"
140 DOXDATA="$top_srcdir/doc/common"
143 if test ! -d "$DOXDATA" ; then
144 echo "* \$DOXDATA does not name a directory ( or is unset ), tried \"$DOXDATA\""
145 exit 1
148 if test -n "$PREFIX" && test ! -d "$PREFIX" ; then
149 echo "* \$PREFIX does not name a directory, tried \"$PREFIX\""
150 echo "* \$PREFIX is disabled."
151 PREFIX=""
154 ### We need some values from top-level files, which
155 ### are not preserved between invocations of this
156 ### script, so factor it out for easy use.
157 create_doxyfile_in()
159 eval `grep 'VERSION="' "$top_srcdir/admin/cvs.sh"`
160 echo "PROJECT_NUMBER = $VERSION" > Doxyfile.in
161 grep '^KDE_INIT_DOXYGEN' "$top_srcdir/configure.in.in" | \
162 sed -e 's+[^[]*\[\([^]]*\)+PROJECT_NAME = "\1"+' \
163 -e 's+].*++' >> Doxyfile.in
166 apidoxdir="$module_name"-apidocs
167 test "x$use_modulename" = "x0" && apidoxdir="apidocs"
169 ### If we're making the top subdir, create the structure
170 ### for the apidox and initialize it. Otherwise, just use the
171 ### structure assumed to be there.
172 if test -z "$subdir" ; then
173 if test ! -d "$apidoxdir" ; then
174 mkdir "$apidoxdir" > /dev/null 2>&1
176 cd "$apidoxdir" > /dev/null 2>&1 || {
177 echo "Cannot create and cd into $apidoxdir"
178 exit 1
181 test -f "Doxyfile.in" || create_doxyfile_in
183 # Copy in logos and the like
184 for i in "favicon.ico" "kde_gear_64.png"
186 cp "$DOXDATA/$i" . > /dev/null 2> /dev/null
187 done
188 for i in "$top_srcdir/doc/api/Dox-"*.png
190 T=`basename "$i" | sed -e 's+Dox-++'`
191 test -f "$i" && cp "$i" "./$T" > /dev/null 2> /dev/null
192 done
194 top_builddir="."
195 srcdir="$1"
196 subdir="."
197 else
198 cd "$apidoxdir" > /dev/null 2>&1 || {
199 echo "Cannot cd into $apidoxdir -- maybe you need to"
200 echo "build the top-level dox first."
201 exit 1
204 if test "x1" = "x$recurse" ; then
205 # OK, so --recurse was requested
206 if test ! -f "subdirs.top" ; then
207 echo "* No subdirs.top available in the $apidoxdir."
208 echo "* The --recurse option will be ignored."
209 recurse=0
214 ### Read a single line (TODO: support \ continuations) from the Makefile.am.
215 ### Used to extract variable assignments from it.
216 extract_line()
218 file="$2" ; test -z "$file" && file="$srcdir/Makefile.am"
219 pattern=`echo "$1" | tr + .`
220 grep "^$1" "$file" | \
221 sed -e "s+$pattern.*=\s*++"
224 ### Handle the COMPILE_{FIRST,LAST,BEFORE,AFTER} part of Makefile.am
225 ### in the toplevel. Copied from admin/cvs.sh. Licence presumed LGPL).
226 create_subdirs()
228 echo "* Sorting top-level subdirs"
229 dirs=
230 idirs=
231 if test -f "$top_srcdir/inst-apps"; then
232 idirs=`cat "$top_srcdir/"inst-apps`
233 else
234 idirs=`cd "$top_srcdir" && ls -1 | sort`
237 compilefirst=""
238 compilelast=""
239 if test -f "$top_srcdir/"Makefile.am.in ; then
240 compilefirst=`sed -ne 's#^COMPILE_FIRST[ ]*=[ ]*##p' "$top_srcdir/"Makefile.am.in | head -n 1`
241 compilelast=`sed -ne 's#^COMPILE_LAST[ ]*=[ ]*##p' "$top_srcdir/"Makefile.am.in | head -n 1`
243 for i in $idirs; do
244 if test -f "$top_srcdir/$i"/Makefile.am; then
245 case " $compilefirst $compilelast " in
246 *" $i "*) ;;
247 *) dirs="$dirs $i"
248 esac
250 done
252 : > ./_SUBDIRS
254 for d in $compilefirst; do
255 echo $d >> ./_SUBDIRS
256 done
258 (for d in $dirs; do
259 list=""
260 if test -f "$top_srcdir/"Makefile.am.in ; then
261 list=`sed -ne "s#^COMPILE_BEFORE_$d""[ ]*=[ ]*##p" "$top_srcdir/"Makefile.am.in | head -n 1`
263 for s in $list; do
264 echo $s $d
265 done
266 list=""
267 if test -f "$top_srcdir/"Makefile.am.in ; then
268 list=`sed -ne "s#^COMPILE_AFTER_$d""[ ]*=[ ]*##p" "$top_srcdir/"Makefile.am.in | head -n 1`
270 for s in $list; do
271 echo $d $s
272 done
273 echo $d $d
274 done ) | tsort >> ./_SUBDIRS
276 for d in $compilelast; do
277 echo $d >> ./_SUBDIRS
278 done
280 test -r _SUBDIRS && mv _SUBDIRS subdirs.top || true
284 ### Add HTML header, footer, CSS tags to Doxyfile.
285 ### Assumes $subdir is set. Argument is a string
286 ### to stick in front of the file if needed.
287 apidox_htmlfiles()
289 dox_header="$top_srcdir/doc/api/$1header.html"
290 dox_footer="$top_srcdir/doc/api/$1footer.html"
291 dox_css="$top_srcdir/doc/api/doxygen.css"
292 test -f "$dox_header" || dox_header="$DOXDATA/$1header.html"
293 test -f "$dox_footer" || dox_footer="$DOXDATA/$1footer.html"
294 test -f "$dox_css" || dox_css="$DOXDATA/doxygen.css"
296 echo "HTML_HEADER = $dox_header" >> "$subdir/Doxyfile" ; \
297 echo "HTML_FOOTER = $dox_footer" >> "$subdir/Doxyfile" ; \
298 echo "HTML_STYLESHEET = $dox_css" >> "$subdir/Doxyfile"
301 apidox_specials()
303 line=`extract_line DOXYGEN_PROJECTNAME "$1"`
304 test -n "$line" && echo "PROJECT_NAME = \"$line\"" >> "$2"
307 apidox_local()
309 for i in "$top_srcdir/doc/api/Doxyfile.local"
311 if test -f "$i" ; then
312 cat "$i" >> "$subdir/Doxyfile"
313 break
315 done
318 ### Post-process HTML files by substituting in the menu files
320 # In non-top directories, both <!-- menu --> and <!-- gmenu -->
321 # are calculated and replaced. Top directories get an empty <!-- menu -->
322 # if any.
323 doxyndex()
325 # Special case top-level to have an empty MENU.
326 if test "x$subdir" = "x." ; then
327 MENU=""
328 htmldir="."
329 htmltop="$top_builddir" # Just ., presumably
330 echo "* Post-processing top-level files"
331 else
332 MENU="<ul>"
333 htmldir="$subdir/html"
334 htmltop="$top_builddir.." # top_builddir ends with /
335 echo "* Post-processing files in $htmldir"
337 # Build a little PHP file that maps class names to file
338 # names, for the quick-class-picker functionality.
339 # (The quick-class-picker is disabled due to styling
340 # problems in IE & FF).
342 echo "<?php \$map = array("; \
343 for htmlfile in `find $htmldir/ -type f -name "class[A-Z]*.html" | grep -v "\-members.html$"`; do
344 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]"`
345 echo " \"$classname\" => \"$htmlfile\","
346 done | sort ; \
347 echo ") ?>"
348 ) > "$subdir/classmap.inc"
350 # This is a list of pairs, with / separators so we can use
351 # basename and dirname (a crude shell hack) to split them
352 # into parts. For each, if the file part exists (as a html
353 # file) tack it onto the MENU variable as a <li> with link.
354 for i in "Main Page/index" \
355 "Modules/modules" \
356 "Namespace List/namespaces" \
357 "Class Hierarchy/hierarchy" \
358 "Alphabetical List/classes" \
359 "Class List/annotated" \
360 "File List/files" \
361 "Directories/dirs" \
362 "Namespace Members/namespacemembers" \
363 "Class Members/functions" \
364 "Related Pages/pages"
366 NAME=`dirname "$i"`
367 FILE=`basename "$i"`
368 test -f "$htmldir/$FILE.html" && MENU="$MENU<li><a href=\"$FILE.html\">$NAME</a></li>"
369 done
371 MENU="$MENU</ul>"
375 # Get the list of global Menu entries.
376 GMENU=`cat subdirs | tr -d '\n'`
378 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("."); } for (k=j; k<c; k++) { printf "../"; } if (j<c) { printf("../html/index.html"); } printf "\">%s</a>\n" , a[j]; } }' | tr -d '\n'`
380 # Map the PHP file into HTML options so that
381 # it can be substituted in for the quick-class-picker.
382 CMENU=""
383 # For now, leave the CMENU disabled
384 CMENUBEGIN="<!--"
385 CMENUEND="-->"
387 if test "x$subdir" = "x." ; then
388 # Disable CMENU on toplevel anyway
389 CMENUBEGIN="<!--"
390 CMENUEND="-->"
391 else
392 test -f "$subdir/classmap.inc" && \
393 CMENU=`grep '=>' "$subdir/classmap.inc" | sed -e 's+"\([^"]*\)" => "'"$subdir/html/"'\([^"]*\)"+<option value="\2">\1<\/option>+' | tr -d '\n'`
395 if test -f "$subdir/classmap.inc" && grep "=>" "$subdir/classmap.inc" > /dev/null 2>&1 ; then
396 # Keep the menu, it's useful
398 else
399 CMENUBEGIN="<!--"
400 CMENUEND="-->"
404 # Now substitute in the MENU in every file. This depends
405 # on HTML_HEADER (ie. header.html) containing the
406 # <!-- menu --> comment.
407 for i in "$htmldir"/*.html
409 if test -f "$i" ; then
410 sed -e "s+<!-- menu -->+$MENU+" \
411 -e "s+<!-- gmenu -->+$GMENU+" \
412 -e "s+<!-- pmenu.*-->+$PMENU+" \
413 -e "s+<!-- cmenu.begin -->+$CMENUBEGIN+" \
414 -e "s+<!-- cmenu.end -->+$CMENUEND+" \
415 < "$i" | sed -e "s+@topdir@+$htmltop+g" > "$i.new" && mv "$i.new" "$i"
416 sed -e "s+<!-- cmenu -->+$CMENU+" < "$i" > "$i.new"
417 test -s "$i.new" && mv "$i.new" "$i"
419 done
427 ### Handle the Doxygen processing of a toplevel directory.
428 apidox_toplevel()
430 echo ""
431 echo "*** Creating API documentation main page for $module_name"
432 echo "*"
433 rm -f "Doxyfile"
434 for i in "$top_srcdir/doc/api/Doxyfile.global" \
435 "$top_srcdir/admin/Doxyfile.global" \
436 "$DOXDATA/Doxyfile.global"
438 if test -f "$i" ; then
439 cp "$i" Doxyfile
440 break
442 done
444 if test ! -f "Doxyfile" ; then
445 echo "* Cannot create Doxyfile."
446 exit 1
449 cat "$top_builddir/Doxyfile.in" >> Doxyfile
452 echo "INPUT = $top_srcdir" >> Doxyfile
453 echo "OUTPUT_DIRECTORY = $top_builddir" >> Doxyfile ; \
454 echo "FILE_PATTERNS = *.dox" >> Doxyfile ; \
455 echo "RECURSIVE = NO" >> Doxyfile ; \
456 echo "ALPHABETICAL_INDEX = NO" >> Doxyfile ; \
457 echo "HTML_OUTPUT = ." >> Doxyfile ; \
458 apidox_htmlfiles "main"
460 # KDevelop has a top-level Makefile.am with settings.
461 for i in "$top_srcdir/Makefile.am.in" "$top_srcdir/Makefile.am"
463 if test -f "$i" ; then
464 grep '^DOXYGEN_SET_' "$i" | \
465 sed -e 's+DOXYGEN_SET_++' -e "s+@topdir@+$top_srcdir+" >> Doxyfile
466 apidox_specials "$srcdir/Makefile.am" "$subdir/Doxyfile"
468 break
470 done
472 apidox_local
474 doxygen Doxyfile
476 ( cd "$top_srcdir" && grep -l '^include.*Doxyfile.am' `find . -name Makefile.am` ) | sed -e 's+/Makefile.am$++' -e 's+^\./++' | sort > subdirs.in
477 for i in `cat subdirs.in`
479 test "x." = "x$i" && continue;
481 dir=`dirname "$i"`
482 file=`basename "$i"`
483 if test "x." = "x$dir" ; then
484 dir=""
485 else
486 dir="$dir/"
488 indent=`echo "$dir" | sed -e 's+[^/]*/+\&nbsp;\&nbsp;+g' | sed -e 's+&+\\\&+g'`
489 entryname=`extract_line DOXYGEN_SET_PROJECT_NAME "$top_srcdir/$dir/$file/Makefile.am"`
490 test -z "$entryname" && entryname="$file"
492 if grep DOXYGEN_EMPTY "$top_srcdir/$dir/$file/Makefile.am" > /dev/null 2>&1 ; then
493 echo "<li>$indent$file</li>"
494 else
495 echo "<li>$indent<a href=\"@topdir@/$dir$file/html/index.html\">$entryname</a></li>"
497 done > subdirs
499 doxyndex
502 ### Handle the Doxygen processing of a non-toplevel directory.
503 apidox_subdir()
505 echo ""
506 echo "*** Creating apidox in $subdir"
507 echo "*"
508 rm -f "$subdir/Doxyfile"
509 if test ! -d "$top_srcdir/$subdir" ; then
510 echo "* No source (sub)directory $subdir"
511 return
513 for i in "$top_srcdir/doc/api/Doxyfile.global" \
514 "$top_srcdir/admin/Doxyfile.global" \
515 "$DOXDATA/Doxyfile.global"
517 if test -f "$i" ; then
518 cp "$i" "$subdir/Doxyfile"
519 break
521 done
524 test -f "Doxyfile.in" || create_doxyfile_in
525 cat "Doxyfile.in" >> "$subdir/Doxyfile"
527 echo "PROJECT_NAME = \"$subdir\"" >> "$subdir/Doxyfile"
528 echo "INPUT = $srcdir" >> "$subdir/Doxyfile"
529 echo "OUTPUT_DIRECTORY = ." >> "$subdir/Doxyfile"
530 if grep -l "$subdir/" subdirs.in > /dev/null 2>&1 ; then
531 echo "RECURSIVE = NO" >> "$subdir/Doxyfile"
533 echo "HTML_OUTPUT = $subdir/html" >> "$subdir/Doxyfile"
534 echo "GENERATE_TAGFILE = $subdir/$subdirname.tag" >> "$subdir/Doxyfile"
535 test -d "$top_srcdir/doc/api" && \
536 echo "IMAGE_PATH = $top_srcdir/doc/api" >> "$subdir/Doxyfile"
538 apidox_htmlfiles ""
540 # Makefile.ams may contain overrides to our settings,
541 # so copy them in.
542 grep '^DOXYGEN_SET_' "$srcdir/Makefile.am" | \
543 sed -e 's+DOXYGEN_SET_++' >> "$subdir/Doxyfile"
544 apidox_specials "$srcdir/Makefile.am" "$subdir/Doxyfile"
546 excludes=`extract_line DOXYGEN_EXCLUDE`
547 if test -n "$excludes"; then
548 patterns=""
549 dirs=""
550 for item in `echo "$excludes"`; do
551 if test -d "$top_srcdir/$subdir/$item"; then
552 dirs="$dirs $top_srcdir/$subdir/$item/"
553 else
554 patterns="$patterns $item"
556 done
557 echo "EXCLUDE_PATTERNS += $patterns" >> "$subdir/Doxyfile"
558 echo "EXCLUDE += $dirs" >> "$subdir/Doxyfile"
561 echo "TAGFILES = \\" >> "$subdir/Doxyfile"
562 ## For now, don't support \ continued references lines
563 tags=`extract_line DOXYGEN_REFERENCES`
564 for i in $tags qt ; do
565 tagsubdir=`dirname $i` ; tag=`basename $i`
566 tagpath=""
567 not_found=""
569 if test "x$tagsubdir" = "x." ; then
570 tagsubdir=""
571 else
572 tagsubdir="$tagsubdir/"
575 # Find location of tag file
576 if test -f "$tagsubdir$tag/$tag.tag" ; then
577 file="$tagsubdir$tag/$tag.tag"
578 loc="$tagsubdir$tag/html"
579 else
580 # This checks for dox built with_out_ --no-modulename
581 # in the same build dir as this dox run was started in.
582 file=`ls -1 ../*-apidocs/"$tagsubdir$tag/$tag.tag" 2> /dev/null`
584 if test -n "$file" ; then
585 loc=`echo "$file" | sed -e "s/$tag.tag\$/html/"`
586 else
587 # If the tag file doesn't exist yet, but should
588 # because we have the right dirs here, queue
589 # this directory for re-processing later.
590 if test -d "$top_srcdir/$tagsubdir$tag" ; then
591 echo "* Need to re-process $subdir for tag $i"
592 echo "$subdir" >> "subdirs.later"
593 else
594 # Re-check in $PREFIX if needed.
595 test -n "$PREFIX" && \
596 file=`cd "$PREFIX" && \
597 ls -1 *-apidocs/"$tagsubdir$tag/$tag.tag" 2> /dev/null`
599 # If something is found, patch it up. The location must be
600 # relative to the installed location of the dox and the
601 # file must be absolute.
602 if test -n "$file" ; then
603 loc=`echo "../$file" | sed -e "s/$tag.tag\$/html/"`
604 file="$PREFIX/$file"
605 echo "* Tags for $tagsubdir$tag will only work when installed."
606 not_found="YES"
611 if test "$tag" = "qt" ; then
612 if test -z "$QTDOCDIR" ; then
613 echo " $file" >> "$subdir/Doxyfile"
614 else
615 if test -z "$file" ; then
616 # Really no Qt tags
617 echo "" >> "$subdir/Doxyfile"
618 else
619 echo " $file=$QTDOCDIR" >> "$subdir/Doxyfile"
622 else
623 if test -n "$file" ; then
624 test -z "$not_found" && echo "* Found tag $file"
625 echo " $file=../$top_builddir$loc \\" >> "$subdir/Doxyfile"
628 done
630 apidox_local
632 if grep '^DOXYGEN_EMPTY' "$srcdir/Makefile.am" > /dev/null 2>&1 ; then
633 # This directory is empty, so don't process it, but
634 # *do* handle subdirs that might have dox.
636 else
637 # Regular processing
638 doxygen "$subdir/Doxyfile"
639 doxyndex
643 ### Run a given subdir by setting up global variables first.
644 do_subdir()
646 subdir=`echo "$1" | sed -e 's+/$++'`
647 srcdir="$top_srcdir/$subdir"
648 subdirname=`basename "$subdir"`
649 mkdir -p "$subdir" 2> /dev/null
650 if test ! -d "$subdir" ; then
651 echo "Can't create dox subdirectory $subdir"
652 return
654 top_builddir=`echo "/$subdir" | sed -e 's+/[^/]*+../+g'`
655 apidox_subdir
659 ### Create installdox-slow in the toplevel
660 create_installdox()
662 # Fix up the installdox script so it accepts empty args
664 # This code is copied from the installdox generated by Doxygen,
665 # copyright by Dimitri van Heesch and released under the GPL.
666 # This does a _slow_ update of the dox, because it loops
667 # over the given substitutions instead of assuming all the
668 # needed ones are given.
670 cat <<\EOF
671 #! /usr/bin/env perl
673 %subst = () ;
674 $quiet = 0;
676 if (open(F,"search.cfg"))
678 $_=<F> ; s/[ \t\n]*$//g ; $subst{"_doc"} = $_;
679 $_=<F> ; s/[ \t\n]*$//g ; $subst{"_cgi"} = $_;
682 while ( @ARGV ) {
683 $_ = shift @ARGV;
684 if ( s/^-// ) {
685 if ( /^l(.*)/ ) {
686 $v = ($1 eq "") ? shift @ARGV : $1;
687 ($v =~ /\/$/) || ($v .= "/");
688 $_ = $v;
689 if ( /(.+)\@(.+)/ ) {
690 $subst{$1} = $2;
691 } else {
692 print STDERR "Argument $_ is invalid for option -l\n";
693 &usage();
696 elsif ( /^q/ ) {
697 $quiet = 1;
699 elsif ( /^\?|^h/ ) {
700 &usage();
702 else {
703 print STDERR "Illegal option -$_\n";
704 &usage();
707 else {
708 push (@files, $_ );
713 if ( ! @files ) {
714 if (opendir(D,".")) {
715 foreach $file ( readdir(D) ) {
716 $match = ".html";
717 next if ( $file =~ /^\.\.?$/ );
718 ($file =~ /$match/) && (push @files, $file);
719 ($file =~ "tree.js") && (push @files, $file);
721 closedir(D);
725 if ( ! @files ) {
726 print STDERR "Warning: No input files given and none found!\n";
729 foreach $f (@files)
731 if ( ! $quiet ) {
732 print "Editing: $f...\n";
734 $oldf = $f;
735 $f .= ".bak";
736 unless (rename $oldf,$f) {
737 print STDERR "Error: cannot rename file $oldf\n";
738 exit 1;
740 if (open(F,"<$f")) {
741 unless (open(G,">$oldf")) {
742 print STDERR "Error: opening file $oldf for writing\n";
743 exit 1;
745 if ($oldf ne "tree.js") {
746 while (<F>) {
747 foreach $sub (keys %subst) {
748 s/doxygen\=\"$sub\:([^ \"\t\>\<]*)\" (href|src)=\"\1/doxygen\=\"$sub:$subst{$sub}\" \2=\"$subst{$sub}/g;
749 print G "$_";
753 else {
754 while (<F>) {
755 foreach $sub (keys %subst) {
756 s/\"$sub\:([^ \"\t\>\<]*)\", \"\1/\"$sub:$subst{$sub}\" ,\"$subst{$sub}/g;
757 print G "$_";
762 else {
763 print STDERR "Warning file $f does not exist\n";
765 unlink $f;
768 sub usage {
769 print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n";
770 print STDERR "Options:\n";
771 print STDERR " -l tagfile\@linkName tag file + URL or directory \n";
772 print STDERR " -q Quiet mode\n\n";
773 exit 1;
778 # Do only the subdirs that match the RE passed in as $1
779 do_subdirs_re()
781 RE=`echo "$1" | sed -e 's+/$++'`
783 # Here's a queue of dirs to re-process later when
784 # all the rest have been done already.
785 > subdirs.later
787 # subdirs.top lists _all_ subdirs of top in the order they
788 # should be handled; subdirs.in lists those dirs that contain
789 # dox. So the intersection of the two is the ordered list
790 # of top-level subdirs that contain dox.
792 # subdirs.top also doesn't contain ".", so that special
793 # case can be ignored in the loop.
797 for i in `grep "^$RE" subdirs.top`
799 if test "x$i" = "x." ; then
800 continue
802 # Calculate intersection of this element and the
803 # set of dox dirs.
804 if grep "^$i\$" subdirs.in > /dev/null 2>&1 ; then
805 echo "$i"
806 mkdir -p "$i" 2> /dev/null
808 # Handle the subdirs of this one
809 for j in `grep "$i/" subdirs.in`
811 echo "$j"
812 mkdir -p "$j" 2> /dev/null
813 done
815 done
817 # Now we still need to handle whatever is left
818 for i in `cat subdirs.in`
820 test -d "$i" || echo "$i"
821 mkdir -p "$i" 2> /dev/null
822 done
823 ) > subdirs.sort
824 for i in `cat subdirs.sort`
826 do_subdir "$i"
827 done
829 if test -s "subdirs.later" ; then
830 sort subdirs.later | uniq > subdirs.sort
831 for i in `cat subdirs.sort`
833 : > subdirs.later
834 echo "*** Reprocessing $i"
835 do_subdir "$i"
836 test -s "subdirs.later" && echo "* Some tag files were still not found."
837 done
841 if test "x." = "x$top_builddir" ; then
842 apidox_toplevel
843 create_subdirs
844 create_installdox > installdox-slow
845 if test "x$recurse" = "x1" ; then
846 if test "x$module_name" = "xkdelibs" ; then
847 if test -z "$QTDOCTAG" && test -d "$QTDOCDIR" && \
848 test ! -f "qt/qt.tag" ; then
849 # Special case: create a qt tag file.
850 echo "*** Creating a tag file for the Qt library:"
851 mkdir qt
852 doxytag -t qt/qt.tag "$QTDOCDIR" > /dev/null 2>&1
855 if test -n "$QTDOCTAG" && test -r "$QTDOCTAG" ; then
856 echo "*** Copying tag file for the Qt library:"
857 mkdir qt
858 cp "$QTDOCTAG" qt/qt.tag
861 do_subdirs_re "."
864 else
865 if test "x$recurse" = "x1" ; then
866 do_subdirs_re "$subdir"
867 else
868 do_subdir "$subdir"
873 # At the end of a run, clean up stuff.
874 if test "YES" = "$cleanup" ; then
875 rm -f subdirs.in subdirs.later subdirs.sort subdirs.top Doxyfile.in
876 rm -f `find . -name Doxyfile`
877 rm -f qt/qt.tag
878 rmdir qt > /dev/null 2>&1
882 exit 0