more dependency fixes
[openwrt.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 my %dep;
9
10 my $line;
11 while ($line = <>) {
12 chomp $line;
13 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
14 $makefile = $1;
15 $src = $2;
16 };
17 $line =~ /^Package: \s*(.+)\s*$/ and do {
18 $name = $1;
19 defined $pkg{$name} or $pkg{$name} = {};
20 $pkg{$name}->{src} = $src;
21 };
22 $line =~ /^(Build-)?Depends: \s*(.+)\s*$/ and do {
23 $pkg{$name}->{depends} ||= [];
24 foreach my $v (split /\s+/, $2) {
25 next if $v =~ /^[\+]?@/;
26 $v =~ s/^\+//;
27 push @{$pkg{$name}->{depends}}, $v;
28 }
29 };
30 }
31
32 $line="";
33
34 foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) {
35 print "package-\$(CONFIG_PACKAGE_$name) += $pkg{$name}->{src}\n";
36
37 my $hasdeps = 0;
38 my $depline = "";
39 foreach my $dep (@{$pkg{$name}->{depends}}) {
40 my $idx;
41 if (defined $pkg{$dep}->{src}) {
42 ($pkg{$name}->{src} ne $pkg{$dep}->{src}) and $idx = $pkg{$dep}->{src};
43 } elsif (defined $pkg{$dep}) {
44 $idx = $dep;
45 }
46 if ($idx) {
47 next if $dep{$pkg{$name}->{src}."->".$idx};
48 $depline .= " $idx\-compile";
49 $dep{$pkg{$name}->{src}."->".$idx} = 1;
50 }
51 }
52 if ($depline ne "") {
53 $line .= "$pkg{$name}->{src}-compile: $depline\n";
54 }
55 }
56
57 if ($line ne "") {
58 print "\n$line";
59 }
This page took 0.04939 seconds and 5 git commands to generate.