~ubuntu-branches/ubuntu/lucid/kchmviewer/lucid

« back to all changes in this revision

Viewing changes to admin/doxygen.sh

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Tallon
  • Date: 2006-06-08 20:08:39 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20060608200839-8b7jodug8yvtj126
Tags: upstream-2.5
ImportĀ upstreamĀ versionĀ 2.5

Show diffs side-by-side

added added

removed removed

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