7 my (%targets, %architectures, %kernels);
9 $ENV{'TOPDIR'} = Cwd
::getcwd
();
12 sub parse_targetinfo
{
13 my ($target_dir, $subtarget) = @_;
15 if (open M
, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 SUBTARGET='$subtarget' |") {
16 my ($target_name, $target_arch, $target_kernel, $target_testing_kernel, @target_features);
17 while (defined(my $line = readline M
)) {
20 if ($line =~ /^Target: (.+)$/) {
23 elsif ($line =~ /^Target-Arch-Packages: (.+)$/) {
26 elsif ($line =~ /^Linux-Version: (\d\.\d+)\.\d+$/) {
29 elsif ($line =~ /^Linux-Testing-Version: (\d\.\d+)\.\d+$/) {
30 $target_testing_kernel = $1;
32 elsif ($line =~ /^Target-Features: (.+)$/) {
33 @target_features = split /\s+/, $1;
35 elsif ($line =~ /^@\@$/) {
36 if ($target_name && $target_arch && $target_kernel &&
37 !grep { $_ eq 'broken' or $_ eq 'source-only' } @target_features) {
38 $targets{$target_name} = $target_arch;
39 $architectures{$target_arch} ||= [];
40 push @
{$architectures{$target_arch}}, $target_name;
41 $kernels{$target_name} ||= [];
42 push @
{$kernels{$target_name}}, $target_kernel;
43 if ($target_testing_kernel) {
44 push @
{$kernels{$target_name}}, $target_testing_kernel;
51 undef $target_testing_kernel;
52 @target_features = ();
60 foreach my $target_makefile (glob "target/linux/*/Makefile") {
61 my ($target_dir) = $target_makefile =~ m!^(.+)/Makefile$!;
64 if (open M
, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 val.FEATURES V=s 2>/dev/null |") {
65 if (defined(my $line = readline M
)) {
67 if (grep { $_ eq 'broken' or $_ eq 'source-only' } split /\s+/, $line) {
73 if (open M
, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 val.SUBTARGETS V=s 2>/dev/null |") {
74 if (defined(my $line = readline M
)) {
76 @subtargets = split /\s+/, $line;
81 push @subtargets, 'generic' if @subtargets == 0;
83 foreach my $subtarget (@subtargets) {
84 parse_targetinfo
($target_dir, $subtarget);
89 if (@ARGV == 1 && $ARGV[0] eq 'targets') {
91 foreach my $target_name (sort keys %targets) {
92 printf "%s %s\n", $target_name, $targets{$target_name};
95 elsif (@ARGV == 1 && $ARGV[0] eq 'architectures') {
97 foreach my $target_arch (sort keys %architectures) {
98 printf "%s %s\n", $target_arch, join ' ', @
{$architectures{$target_arch}};
101 elsif (@ARGV == 1 && $ARGV[0] eq 'kernels') {
103 foreach my $target_name (sort keys %targets) {
104 printf "%s %s\n", $target_name, join ' ', @
{$kernels{$target_name}};
108 print "Usage: $0 targets\n";
109 print "Usage: $0 architectures\n";
110 print "Usage: $0 kernels\n";