a910a9937bbdebbc77fe9ef7adcdf9a9de3a039a
[openwrt-10.03/.git] / scripts / gen_deps.pl
1 #!/usr/bin/perl
2 use strict;
3
4 my $name;
5 my $src;
6 my $makefile;
7 my %pkg;
8
9 my $line;
10 while ($line = <>) {
11         chomp $line;
12         $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
13                 $makefile = $1;
14                 $src = $2;
15         };
16         $line =~ /^Package: \s*(.+)\s*$/ and do {
17                 $name = $1;
18                 defined $pkg{$name} or $pkg{$name} = {};
19                 $pkg{$name}->{src} = $src;
20         };
21         $line =~ /^Depends: \s*(.+)\s*$/ and do {
22                 my @dep = split /,\s*/, $1;
23                 $pkg{$name}->{depends} = \@dep;
24         };
25 }
26
27 foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) {
28         my $hasdeps = 0;
29         $line = "$pkg{$name}->{src}-compile:";
30         foreach my $dep (@{$pkg{$name}->{depends}}) {
31                 if (defined $pkg{$dep}->{src} && $pkg{$name}->{src} ne $pkg{$dep}->{src}) {
32                         $hasdeps = 1;
33                         $line .= " $pkg{$dep}->{src}-compile";
34                 }
35         }
36         if ($hasdeps) {
37                 print "$line\n";
38         }
39 }