1: #!/usr/bin/perl
2:
3: $srcdir = $ARGV[0];
4: $out = $ARGV[1];
5:
6: open(OUT, ">", $out) || die "Cannot create output file";
7: process($srcdir, "doc/prog-root");
8: close OUT;
9: gen_deps();
10: exit 0;
11:
12: sub include {
13: my $f = shift @_;
14: open(IN, "$f") || die "Unable to find $f";
15: push(@deps, "$f");
16: while (<IN>) {
17: print OUT;
18: }
19: close IN;
20: }
21:
22: sub process {
23: my $dir = shift @_;
24: my $doc = "$dir/" . shift @_;
25: print "$doc\n";
26: open(IN, $doc) || die "Unable to read $doc";
27: push(@deps, $doc);
28: my @docfile = <IN>;
29: close IN;
30: foreach $_ (@docfile) {
31: chomp;
32: /^#/ && next;
33: /^([A-Z]+)\s*(.*)/ || die "Parse error: $_";
34: $cmd = $1;
35: $arg = $2;
36: if ($cmd eq "C") { process("$dir/$arg", "Doc"); }
37: elsif ($cmd eq "H") {
38: push @stack, "H";
39: print OUT "<chapt>$arg\n";
40: } elsif ($cmd eq "S") {
41: print " $arg\n";
42: my @files = map("$dir/$_", split(' ', $arg));
43: my $fargs = join(' ', @files);
44: open(DOC, "$srcdir/doc/kernel-doc -bird $fargs |") || die "Unable to start kernel-doc";
45: push(@deps, @files);
46: while (<DOC>) { print OUT; }
47: close DOC;
48: } elsif ($cmd eq "D") {
49: print " $arg\n";
50: include("$dir/$arg");
51: } else { die "Unknown command: $cmd"; }
52: }
53: }
54:
55: sub gen_deps {
56: open(DEP, ">", "$out.d");
57: print DEP "$out:";
58: foreach $f (@deps) {
59: print DEP " \\\n $f";
60: }
61: print DEP "\n\n";
62:
63: foreach $f (@deps) {
64: print DEP "$f:\n\n";
65: }
66: close DEP;
67: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>