blob: 135b8bdb142b2e2b05b9ebb763a2c7b119ab3865 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/usr/bin/perl
use FileHandle;
sub check_line($$$)
{
my $dir=shift;
my $obj=shift;
my $arg=shift;
my $arg2="";
$arg=$arg." ";
while ($arg ne "") {
if ($arg =~ m|^([^ /]+)/ |) {
my $newdir=$1;
# print "include $dir/$newdir/Makefile\n";
open_makefile("$dir/$newdir/Makefile");
$arg =~ s/^[^ ]+ //;
} else {
$arg =~ s/^([^ ]+ )//;
$arg2 = $arg2.$1;
}
}
$arg2 =~ s/\s+$//;
if ($arg2 ne "") {
# print "arg=$arg2\n";
print OUT "$obj$arg2\n";
}
}
sub remove_includes($$)
{
my $obj=shift;
my $arg=shift;
my $arg2="";
$arg=$arg." ";
while ($arg ne "") {
if (!$arg =~ m|^(-I\s*[^ ]+) |) {
$arg2 = $arg2.$1;
$arg =~ s|^[^ ] ||;
} else {
$arg =~ s|^(-I\s*[^ ]+) ||;
}
}
if ($arg2 ne "") {
print OUT "$obj$arg2\n";
}
}
sub open_makefile($) {
my $file= shift;
my $in = new FileHandle;
my $dir= "";
my $count=0;
$file=~ m|^(.*)/[^/]*$|;
$dir=$1;
#print "opening $file (dir=$dir)\n";
open $in,"$file";
while (<$in>) {
if (m|\s*#|) {
print OUT $_;
next;
}
if (m|^\s*include|) {
next;
}
if (count==1 || m|(^\s*EXTRA_CFLAGS.*=\s*)(.*/.*)\n|) {
remove_includes($1,$2);
if (m|[\\]\n|) {
$count=1;
} else {
$count=0;
}
next;
}
# if (m|(^\s*obj.*=\s*)(.*/.*)\n|) {
if (count==2 || m|(^\s*obj.*=\s*)(.*)\n|) {
check_line($dir,$1,$2);
if (m|\\\n|) {
$count=1;
} else {
$count=0;
}
next;
}
print OUT $_;
}
close $in;
}
open OUT,">Makefile.media";
open_makefile ("../linux/drivers/media/Makefile");
close OUT;
while ( my ($key, $value) = each(%config) ) {
delete $depend{$key};
}
open OUT,">Kconfig.kern";
while ( my ($key, $value) = each(%depend) ) {
print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault m\n\n";
}
close OUT;
|