#!/usr/bin/perl use FileHandle; my %depend = (); my %minver = (); my %config = (); my $version, $level, $sublevel; sub add_config($) { my $arg=shift; if ($arg =~ m/^([A-Z0-9_]+)/) { $config{$1} = 1; } } sub check_deps($) { my $arg=shift; $arg=$arg." "; while ($arg ne "") { if ($arg =~ m/^([A-Z0-9_]+) /) { my $val=$1; my $prev=$depend{$val}; $depend { $val } = 1+$prev; } $arg =~ s/^[^ ]+ //; } } sub open_kconfig($$) { my ($dir,$file)=@_; my $in = new FileHandle; my $skip=0; #print "opening $file\n"; open $in,"$file"; while (<$in>) { # if (m;^\s*source[\s\"]+drivers/media/(video|dvb)/Kconfig;) { # next; # } if (m|^\s*source[\s\"]+([^\n\s\"]+)[\n\s\"]|) { open_kconfig($dir,"$dir/$1"); next; } if (m|^\s+depends on (.*)\n|) { check_deps ($1); } if (m|^\s+select (.*)\n|) { check_deps ($1); } if (m|^\s*config (.*)\n|) { my $key=$1; add_config ($1); my $min=$minver { $key }; my $minversion, $minlevel, $minsublevel; if ($min =~ m/(\d+)\.(\d+)\.(\d+)/) { $minversion=$1; $minlevel=$2; $minsublevel=$3; } else { die "Minimum version for $key not found at versions.txt"; } if ( ($version < $minversion) | ($level < $minlevel) | ($sublevel < $minsublevel) ) { $skip=1; printf "$key requires version $minversion.$minlevel.$minsublevel\n"; print OUT "# $key disabled due to incorrect version\nconfig $key\n\ttristate\n\tdefault n\n\n"; next; } else { # printf "OK: $key requires version $minversion.$minlevel.$minsublevel\n"; $skip=0; } } s/^main(menu\s\"[^\"]+)/\1 - DON'T CHANGE IT!/; if (m/^[\w]/) { $skip=0; } if (!$skip) { print OUT $_; } } close $in; } sub parse_versions () { my $in = new FileHandle; my $ver; open $in,"versions.txt"; while (<$in>) { if (m/\[([\d.]*)\]/) { $ver=$1; next; } s/\n//; if (m/^\s*([\w\d_]+)/) { $minver { $1 } = $ver; # printf ("%s=%s\n",$1,$ver); } } close $in; } parse_versions; open IN,".version"; while () { if (m/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) { $version=$1; $level=$2; $sublevel=$3; } } close IN; printf "Preparing to compile for kernel version %d.%d.%d\n",$version,$level,$sublevel; open OUT,">Kconfig"; print OUT "mainmenu \"V4L/DVB menu\"\n"; print OUT "source Kconfig.kern\n"; open_kconfig ("../linux","../linux/drivers/media/Kconfig"); close OUT; while ( my ($key, $value) = each(%config) ) { delete $depend{$key}; } open OUT,">Kconfig.kern"; print OUT "config MODULES\n\tboolean\n\tdefault y\n\n"; while ( my ($key, $value) = each(%depend) ) { print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault m\n\n"; } close OUT;