3 # Copyright (C) 2006 OpenWrt.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
21 while ($opt = shift @ARGV) {
22 $opt =~ /^-s/ and $options{SDK} = 1;
28 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
32 $line =~ /^Package: \s*(.+)\s*$/ and do {
34 defined $pkg{$name} or $pkg{$name} = {};
35 $pkg{$name}->{src} = $src;
37 $line =~ /^Provides: \s*(.+)\s*$/ and do {
38 foreach my $vpkg (split /\s+/, $1) {
39 defined $pkg{$vpkg} or $pkg{$vpkg} = {};
40 $pkg{$vpkg}->{virtual} = 1;
43 $line =~ /^Prereq-Check:/ and !defined $prereq{$src} and do {
44 $pkg{$name}->{prereq} = 1;
46 $line =~ /^(Build-)?Depends: \s*(.+)\s*$/ and do {
47 $pkg{$name}->{depends} ||= [];
48 foreach my $v (split /\s+/, $2) {
49 next if $v =~ /^[\+]?@/;
51 push @{$pkg{$name}->{depends}}, $v;
58 foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) {
61 next if defined $pkg{$name}->{virtual};
63 $conf{$pkg{$name}->{src}} or do {
65 $conf{$pkg{$name}->{src}} = 1;
68 $config = "\$(CONFIG_PACKAGE_$name)"
71 print "package-$config += $pkg{$name}->{src}\n";
72 $pkg{$name}->{prereq} and print "prereq-$config += $pkg{$name}->{src}\n";
77 foreach my $dep (@{$pkg{$name}->{depends}}) {
79 next if defined $pkg{$dep}->{virtual};
80 if (defined $pkg{$dep}->{src}) {
81 ($pkg{$name}->{src} ne $pkg{$dep}->{src}) and $idx = $pkg{$dep}->{src};
82 } elsif (defined($pkg{$dep}) && !$options{SDK}) {
85 undef $idx if $idx =~ /^(kernel)|(base-files)$/;
87 next if $dep{$pkg{$name}->{src}."->".$idx};
88 $depline .= " $idx\-compile";
89 $dep{$pkg{$name}->{src}."->".$idx} = 1;
93 $line .= "$pkg{$name}->{src}-compile: $depline\n";