Revision 7152e5ef tools/progdoc

View differences:

tools/progdoc
1 1
#!/usr/bin/perl
2 2

  
3 3
$srcdir = $ARGV[0];
4
$out = $ARGV[1];
4 5

  
5
open(OUT, ">prog.sgml") || die "Cannot create output file";
6
include("doc/prog-head.sgml");
7
process("");
8
include("doc/prog-foot.sgml");
6
open(OUT, ">", $out) || die "Cannot create output file";
7
process($srcdir);
9 8
close OUT;
9
gen_deps();
10 10
exit 0;
11 11

  
12 12
sub include {
13 13
  my $f = shift @_;
14
  open(IN, "$srcdir/$f") || die "Unable to find $f";
14
  open(IN, "$f") || die "Unable to find $f";
15
  push(@deps, "$f");
15 16
  while (<IN>) {
16 17
    print OUT;
17 18
  }
......
21 22
sub process {
22 23
  my $dir = shift @_;
23 24
  print "$dir/Doc\n";
24
  open(IN, "$srcdir/$dir/Doc") || die "Unable to read $dir/Doc";
25
  open(IN, "$dir/Doc") || die "Unable to read $dir/Doc";
26
  push(@deps, "$dir/Doc");
25 27
  my @docfile = <IN>;
26 28
  close IN;
27 29
  foreach $_ (@docfile) {
......
36 38
      print OUT "<chapt>$arg\n";
37 39
    } elsif ($cmd eq "S") {
38 40
      print "    $arg\n";
39
      open(DOC, "cd $srcdir/$dir ; $srcdir/doc/kernel-doc -bird $arg |") || die "Unable to start kernel-doc";
41
      my @files = map("$dir/$_", split(' ', $arg));
42
      my $fargs = join(' ', @files);
43
      open(DOC, "$srcdir/doc/kernel-doc -bird $fargs |") || die "Unable to start kernel-doc";
44
      push(@deps, @files);
40 45
      while (<DOC>) { print OUT; }
41 46
      close DOC;
42 47
    } elsif ($cmd eq "D") {
......
45 50
    } else { die "Unknown command: $cmd"; }
46 51
  }
47 52
}
53

  
54
sub gen_deps {
55
  open(DEP, ">", "$out.d");
56
  print DEP "$out:";
57
  foreach $f (@deps) {
58
    print DEP " \\\n  $f";
59
  }
60
  print DEP "\n\n";
61

  
62
  foreach $f (@deps) {
63
    print DEP "$f:\n\n";
64
  }
65
  close DEP;
66
}

Also available in: Unified diff