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.
22 while ($opt = shift @ARGV) {
23 $opt =~ /^-s/ and $options{SDK} = 1;
29 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
33 $line =~ /^Package: \s*(.+)\s*$/ and do {
35 defined $pkg{$name} or $pkg{$name} = {};
36 $pkg{$name}->{src} = $src;
38 $line =~ /^Prereq-Check:/ and !defined $prereq{$src} and do {
40 $prereq .= "package-prereq += $src\n";
42 $line =~ /^(Build-)?Depends: \s*(.+)\s*$/ and do {
43 $pkg{$name}->{depends} ||= [];
44 foreach my $v (split /\s+/, $2) {
45 next if $v =~ /^[\+]?@/;
47 push @{$pkg{$name}->{depends}}, $v;
54 foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) {
56 $conf{$pkg{$name}->{src}} or print "package-m += $pkg{$name}->{src}\n";
57 $conf{$pkg{$name}->{src}} = 1;
59 print "package-\$(CONFIG_PACKAGE_$name) += $pkg{$name}->{src}\n";
64 foreach my $dep (@{$pkg{$name}->{depends}}) {
66 if (defined $pkg{$dep}->{src}) {
67 ($pkg{$name}->{src} ne $pkg{$dep}->{src}) and $idx = $pkg{$dep}->{src};
68 } elsif (defined($pkg{$dep}) && !$options{SDK}) {
71 undef $idx if $idx =~ /^(kernel)|(base-files)$/;
73 next if $dep{$pkg{$name}->{src}."->".$idx};
74 $depline .= " $idx\-compile";
75 $dep{$pkg{$name}->{src}."->".$idx} = 1;
79 $line .= "$pkg{$name}->{src}-compile: $depline\n";
84 print "\n$line\n$prereq";