You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
1.9 KiB
92 lines
1.9 KiB
19 years ago
|
#!/usr/bin/perl
|
||
19 years ago
|
#
|
||
|
# Copyright (C) 2006 OpenWrt.org
|
||
|
#
|
||
|
# This is free software, licensed under the GNU General Public License v2.
|
||
|
# See /LICENSE for more information.
|
||
|
#
|
||
|
|
||
19 years ago
|
use strict;
|
||
|
|
||
|
my $name;
|
||
|
my $src;
|
||
|
my $makefile;
|
||
19 years ago
|
my %conf;
|
||
19 years ago
|
my %pkg;
|
||
18 years ago
|
my %prereq;
|
||
19 years ago
|
my %dep;
|
||
19 years ago
|
my %options;
|
||
|
my $opt;
|
||
|
|
||
|
while ($opt = shift @ARGV) {
|
||
|
$opt =~ /^-s/ and $options{SDK} = 1;
|
||
|
}
|
||
19 years ago
|
|
||
|
my $line;
|
||
|
while ($line = <>) {
|
||
|
chomp $line;
|
||
|
$line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
|
||
|
$makefile = $1;
|
||
|
$src = $2;
|
||
|
};
|
||
|
$line =~ /^Package: \s*(.+)\s*$/ and do {
|
||
|
$name = $1;
|
||
|
defined $pkg{$name} or $pkg{$name} = {};
|
||
|
$pkg{$name}->{src} = $src;
|
||
|
};
|
||
18 years ago
|
$line =~ /^Prereq-Check:/ and !defined $prereq{$src} and do {
|
||
18 years ago
|
$pkg{$name}->{prereq} = 1;
|
||
18 years ago
|
};
|
||
19 years ago
|
$line =~ /^(Build-)?Depends: \s*(.+)\s*$/ and do {
|
||
19 years ago
|
$pkg{$name}->{depends} ||= [];
|
||
|
foreach my $v (split /\s+/, $2) {
|
||
19 years ago
|
next if $v =~ /^[\+]?@/;
|
||
19 years ago
|
$v =~ s/^\+//;
|
||
|
push @{$pkg{$name}->{depends}}, $v;
|
||
|
}
|
||
19 years ago
|
};
|
||
|
}
|
||
|
|
||
19 years ago
|
$line="";
|
||
|
|
||
19 years ago
|
foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) {
|
||
18 years ago
|
my $config;
|
||
|
|
||
19 years ago
|
if ($options{SDK}) {
|
||
18 years ago
|
$conf{$pkg{$name}->{src}} or do {
|
||
|
$config = 'm';
|
||
|
$conf{$pkg{$name}->{src}} = 1;
|
||
|
};
|
||
19 years ago
|
} else {
|
||
18 years ago
|
$config = "\$(CONFIG_PACKAGE_$name)"
|
||
|
}
|
||
|
if ($config) {
|
||
|
print "package-$config += $pkg{$name}->{src}\n";
|
||
|
$pkg{$name}->{prereq} and print "prereq-$config += $pkg{$name}->{src}\n";
|
||
19 years ago
|
}
|
||
19 years ago
|
|
||
19 years ago
|
my $hasdeps = 0;
|
||
19 years ago
|
my $depline = "";
|
||
19 years ago
|
foreach my $dep (@{$pkg{$name}->{depends}}) {
|
||
19 years ago
|
my $idx;
|
||
19 years ago
|
if (defined $pkg{$dep}->{src}) {
|
||
|
($pkg{$name}->{src} ne $pkg{$dep}->{src}) and $idx = $pkg{$dep}->{src};
|
||
19 years ago
|
} elsif (defined($pkg{$dep}) && !$options{SDK}) {
|
||
19 years ago
|
$idx = $dep;
|
||
|
}
|
||
18 years ago
|
undef $idx if $idx =~ /^(kernel)|(base-files)$/;
|
||
19 years ago
|
if ($idx) {
|
||
|
next if $dep{$pkg{$name}->{src}."->".$idx};
|
||
|
$depline .= " $idx\-compile";
|
||
|
$dep{$pkg{$name}->{src}."->".$idx} = 1;
|
||
19 years ago
|
}
|
||
|
}
|
||
19 years ago
|
if ($depline ne "") {
|
||
|
$line .= "$pkg{$name}->{src}-compile: $depline\n";
|
||
19 years ago
|
}
|
||
|
}
|
||
19 years ago
|
|
||
|
if ($line ne "") {
|
||
18 years ago
|
print "\n$line";
|
||
19 years ago
|
}
|