blob: 116df3394a04390f7ac0dbcd2967f0f6803ef0f8 (
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#!/usr/bin/perl
use FileHandle;
my $instdir = ();
sub check_line($$$)
{
my $dir=shift;
my $obj=shift;
my $arg=shift;
my $arg2="";
my $idir = $dir;
$idir =~ s|^../linux/drivers/media/||;
$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/^([^ ]+ )//;
my $cur=$1;
$arg2 = $arg2.$cur;
$cur =~ s/\s+$//;
$cur =~ s/\\$//;
$cur =~ s/\s+$//;
$cur =~ s/\.o$/.ko/;
if ( ($cur ne "") && (! ($instdir { $idir } =~ m/($cur) /))) {
$instdir { $idir } = $instdir { $idir }.$cur." ";
}
}
}
$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");
# Creating Install rule
printf OUT "install::\n";
#printf OUT "\t@strip --strip-debug \$(inst-m)\n\n";
while ( my ($key, $value) = each(%instdir) ) {
printf OUT "\t\@echo -e \"\\nInstalling \$(KDIR26)/$key files:\"\n";
printf OUT "\t\@install -d \$(KDIR26)/$key\n";
printf OUT "\t\@files='$value'; ";
printf OUT "for i in \$\$files;do if [ -e \$\$i ]; then echo -n \"\$\$i \";";
printf OUT " install -m 644 -c \$\$i \$(KDIR26)/$key; fi; done; echo;\n\n";
}
# Creating Remove rule
printf OUT "remove rminstall::\n";
printf OUT "\t\@echo -e \"\\nRemoving old \$(DEST) files\\n\"\n";
while ( my ($key, $value) = each(%instdir) ) {
printf OUT "\t\@echo -e \"\\nRemoving old \$(KDIR26)/$key files:\"\n";
printf OUT "\t\@files='$value'; ";
printf OUT "for i in \$\$files;do if [ -e \$(KDIR26)/$key/\$\$i ]; then ";
printf OUT "echo -n \"\$\$i \";";
printf OUT " rm \$(KDIR26)/$key/\$\$i; fi; done; ";
printf OUT "for i in \$\$files;do if [ -e \$(KDIR26)/$key/\$\$i.gz ]; then ";
printf OUT "echo -n \"\$\$i.gz \";";
printf OUT " rm \$(KDIR26)/$key/\$\$i.gz; fi; done; echo;\n\n";
}
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;
if (open OUT,".myconfig") {
close IN;
} else {
system "make allmodconfig";
}
|