include $(TOPDIR)/rules.mk in the image makefiles
[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 %conf;
8 my %pkg;
9 my %dep;
10 my %options;
11 my $opt;
12
13 while ($opt = shift @ARGV) {
14 $opt =~ /^-s/ and $options{SDK} = 1;
15 }
16
17 my $line;
18 while ($line = <>) {
19 chomp $line;
20 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
21 $makefile = $1;
22 $src = $2;
23 };
24 $line =~ /^Package: \s*(.+)\s*$/ and do {
25 $name = $1;
26 defined $pkg{$name} or $pkg{$name} = {};
27 $pkg{$name}->{src} = $src;
28 };
29 $line =~ /^(Build-)?Depends: \s*(.+)\s*$/ and do {
30 $pkg{$name}->{depends} ||= [];
31 foreach my $v (split /\s+/, $2) {
32 next if $v =~ /^[\+]?@/;
33 $v =~ s/^\+//;
34 push @{$pkg{$name}->{depends}}, $v;
35 }
36 };
37 }
38
39 $line="";
40
41 foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) {
42 if ($options{SDK}) {
43 $conf{$pkg{$name}->{src}} or print "package-m += $pkg{$name}->{src}\n";
44 $conf{$pkg{$name}->{src}} = 1;
45 } else {
46 print "package-\$(CONFIG_PACKAGE_$name) += $pkg{$name}->{src}\n";
47 }
48
49 my $hasdeps = 0;
50 my $depline = "";
51 foreach my $dep (@{$pkg{$name}->{depends}}) {
52 my $idx;
53 if (defined $pkg{$dep}->{src}) {
54 ($pkg{$name}->{src} ne $pkg{$dep}->{src}) and $idx = $pkg{$dep}->{src};
55 } elsif (defined($pkg{$dep}) && !$options{SDK}) {
56 $idx = $dep;
57 }
58 if ($idx) {
59 next if $dep{$pkg{$name}->{src}."->".$idx};
60 $depline .= " $idx\-compile";
61 $dep{$pkg{$name}->{src}."->".$idx} = 1;
62 }
63 }
64 if ($depline ne "") {
65 $line .= "$pkg{$name}->{src}-compile: $depline\n";
66 }
67 }
68
69 if ($line ne "") {
70 print "\n$line";
71 }
This page took 0.059453 seconds and 5 git commands to generate.