#!/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;