kernel: move mv88e6xxx fix to generic backports
[openwrt/openwrt.git] / scripts / dump-target-info.pl
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use Cwd;
6
7 my (%targets, %architectures, %kernels);
8
9 $ENV{'TOPDIR'} = Cwd::getcwd();
10
11
12 sub parse_targetinfo {
13 my ($target_dir, $subtarget) = @_;
14
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)) {
18 chomp $line;
19
20 if ($line =~ /^Target: (.+)$/) {
21 $target_name = $1;
22 }
23 elsif ($line =~ /^Target-Arch-Packages: (.+)$/) {
24 $target_arch = $1;
25 }
26 elsif ($line =~ /^Linux-Version: (\d\.\d+)\.\d+$/) {
27 $target_kernel = $1;
28 }
29 elsif ($line =~ /^Linux-Testing-Version: (\d\.\d+)\.\d+$/) {
30 $target_testing_kernel = $1;
31 }
32 elsif ($line =~ /^Target-Features: (.+)$/) {
33 @target_features = split /\s+/, $1;
34 }
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;
45 }
46 }
47
48 undef $target_name;
49 undef $target_arch;
50 undef $target_kernel;
51 undef $target_testing_kernel;
52 @target_features = ();
53 }
54 }
55 close M;
56 }
57 }
58
59 sub get_targetinfo {
60 foreach my $target_makefile (glob "target/linux/*/Makefile") {
61 my ($target_dir) = $target_makefile =~ m!^(.+)/Makefile$!;
62 my @subtargets;
63
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)) {
66 chomp $line;
67 if (grep { $_ eq 'broken' or $_ eq 'source-only' } split /\s+/, $line) {
68 next;
69 }
70 }
71 }
72
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)) {
75 chomp $line;
76 @subtargets = split /\s+/, $line;
77 }
78 close M;
79 }
80
81 push @subtargets, 'generic' if @subtargets == 0;
82
83 foreach my $subtarget (@subtargets) {
84 parse_targetinfo($target_dir, $subtarget);
85 }
86 }
87 }
88
89 if (@ARGV == 1 && $ARGV[0] eq 'targets') {
90 get_targetinfo();
91 foreach my $target_name (sort keys %targets) {
92 printf "%s %s\n", $target_name, $targets{$target_name};
93 }
94 }
95 elsif (@ARGV == 1 && $ARGV[0] eq 'architectures') {
96 get_targetinfo();
97 foreach my $target_arch (sort keys %architectures) {
98 printf "%s %s\n", $target_arch, join ' ', @{$architectures{$target_arch}};
99 }
100 }
101 elsif (@ARGV == 1 && $ARGV[0] eq 'kernels') {
102 get_targetinfo();
103 foreach my $target_name (sort keys %targets) {
104 printf "%s %s\n", $target_name, join ' ', @{$kernels{$target_name}};
105 }
106 }
107 else {
108 print "Usage: $0 targets\n";
109 print "Usage: $0 architectures\n";
110 print "Usage: $0 kernels\n";
111 }