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 {
31 defined $pkg{$src} or $pkg{$src} = {};
32 $pkg{$src}->{src} = $src;
34 $line =~ /^Package: \s*(.+)\s*$/ and do {
36 defined $pkg{$name} or $pkg{$name} = {};
37 $pkg{$name}->{src} = $src;
39 $line =~ /^Provides: \s*(.+)\s*$/ and do {
40 foreach my $vpkg (split /\s+/, $1) {
41 defined $pkg{$vpkg} or $pkg{$vpkg} = {};
42 $pkg{$vpkg}->{virtual} = 1;
45 $line =~ /^Prereq-Check:/ and !defined $prereq{$src} and do {
46 $pkg{$name}->{prereq} = 1;
48 $line =~ /^(Build-)?Depends: \s*(.+)\s*$/ and do {
49 $pkg{$name}->{depends} ||= [];
50 foreach my $v (split /\s+/, $2) {
51 next if $v =~ /^[\+]?@/;
53 push @{$pkg{$name}->{depends}}, $v;
60 foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) {
63 next if defined $pkg{$name}->{virtual};
65 $conf{$pkg{$name}->{src}} or do {
67 $conf{$pkg{$name}->{src}} = 1;
70 $config = "\$(CONFIG_PACKAGE_$name)"
73 print "package-$config += $pkg{$name}->{src}\n";
74 $pkg{$name}->{prereq} and print "prereq-$config += $pkg{$name}->{src}\n";
79 foreach my $dep (@{$pkg{$name}->{depends}}) {
81 next if defined $pkg{$dep}->{virtual};
82 if (defined $pkg{$dep}->{src}) {
83 ($pkg{$name}->{src} ne $pkg{$dep}->{src}) and $idx = $pkg{$dep}->{src};
84 } elsif (defined($pkg{$dep}) && !$options{SDK}) {
87 undef $idx if $idx =~ /^(kernel)|(base-files)$/;
89 next if $dep{$pkg{$name}->{src}."->".$idx};
90 $depline .= " $idx\-compile";
91 $dep{$pkg{$name}->{src}."->".$idx} = 1;
95 $line .= "$pkg{$name}->{src}-compile: $depline\n";