2000-05-05 17:14:44 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
$srcdir = $ARGV[0];
|
2016-04-12 09:14:54 +00:00
|
|
|
$out = $ARGV[1];
|
2000-05-05 17:14:44 +00:00
|
|
|
|
2016-04-12 09:14:54 +00:00
|
|
|
open(OUT, ">", $out) || die "Cannot create output file";
|
|
|
|
process($srcdir);
|
2000-05-05 17:14:44 +00:00
|
|
|
close OUT;
|
2016-04-12 09:14:54 +00:00
|
|
|
gen_deps();
|
2000-05-05 17:14:44 +00:00
|
|
|
exit 0;
|
|
|
|
|
2000-05-31 11:29:56 +00:00
|
|
|
sub include {
|
|
|
|
my $f = shift @_;
|
2016-04-12 09:14:54 +00:00
|
|
|
open(IN, "$f") || die "Unable to find $f";
|
|
|
|
push(@deps, "$f");
|
2000-05-31 11:29:56 +00:00
|
|
|
while (<IN>) {
|
|
|
|
print OUT;
|
|
|
|
}
|
|
|
|
close IN;
|
|
|
|
}
|
|
|
|
|
2000-05-05 17:14:44 +00:00
|
|
|
sub process {
|
|
|
|
my $dir = shift @_;
|
|
|
|
print "$dir/Doc\n";
|
2016-04-12 09:14:54 +00:00
|
|
|
open(IN, "$dir/Doc") || die "Unable to read $dir/Doc";
|
|
|
|
push(@deps, "$dir/Doc");
|
2000-05-05 17:14:44 +00:00
|
|
|
my @docfile = <IN>;
|
|
|
|
close IN;
|
|
|
|
foreach $_ (@docfile) {
|
|
|
|
chomp;
|
|
|
|
/^#/ && next;
|
2000-05-31 11:29:56 +00:00
|
|
|
/^([A-Z]+)\s*(.*)/ || die "Parse error: $_";
|
|
|
|
$cmd = $1;
|
|
|
|
$arg = $2;
|
2000-05-05 17:14:44 +00:00
|
|
|
if ($cmd eq "C") { process("$dir/$arg"); }
|
|
|
|
elsif ($cmd eq "H") {
|
|
|
|
push @stack, "H";
|
2000-06-02 17:23:53 +00:00
|
|
|
print OUT "<chapt>$arg\n";
|
2000-05-05 17:14:44 +00:00
|
|
|
} elsif ($cmd eq "S") {
|
|
|
|
print " $arg\n";
|
2016-04-12 09:14:54 +00:00
|
|
|
my @files = map("$dir/$_", split(' ', $arg));
|
|
|
|
my $fargs = join(' ', @files);
|
|
|
|
open(DOC, "$srcdir/doc/kernel-doc -bird $fargs |") || die "Unable to start kernel-doc";
|
|
|
|
push(@deps, @files);
|
2000-05-31 11:29:56 +00:00
|
|
|
while (<DOC>) { print OUT; }
|
2000-05-05 17:14:44 +00:00
|
|
|
close DOC;
|
2000-05-31 11:29:56 +00:00
|
|
|
} elsif ($cmd eq "D") {
|
|
|
|
print " $arg\n";
|
2000-06-05 09:51:24 +00:00
|
|
|
include("$dir/$arg");
|
2000-05-05 17:14:44 +00:00
|
|
|
} else { die "Unknown command: $cmd"; }
|
|
|
|
}
|
|
|
|
}
|
2016-04-12 09:14:54 +00:00
|
|
|
|
|
|
|
sub gen_deps {
|
|
|
|
open(DEP, ">", "$out.d");
|
|
|
|
print DEP "$out:";
|
|
|
|
foreach $f (@deps) {
|
|
|
|
print DEP " \\\n $f";
|
|
|
|
}
|
|
|
|
print DEP "\n\n";
|
|
|
|
|
|
|
|
foreach $f (@deps) {
|
|
|
|
print DEP "$f:\n\n";
|
|
|
|
}
|
|
|
|
close DEP;
|
|
|
|
}
|