diff options
Diffstat (limited to 'v4l/scripts')
-rwxr-xr-x | v4l/scripts/make_kconfig.pl | 73 | ||||
-rw-r--r-- | v4l/scripts/make_makefile.pl | 109 | ||||
-rw-r--r-- | v4l/scripts/make_noconfig.pl | 60 |
3 files changed, 239 insertions, 3 deletions
diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index 91c37693f..b1d6f5d53 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -1,10 +1,10 @@ #!/usr/bin/perl use FileHandle; -my $ARCH=shift; - my %depend = (); +my %minver = (); my %config = (); +my $version, $level, $sublevel; sub add_config($) { @@ -33,6 +33,7 @@ sub check_deps($) sub open_kconfig($$) { my ($dir,$file)=@_; my $in = new FileHandle; + my $skip=0; #print "opening $file\n"; open $in,"$file"; @@ -51,15 +52,78 @@ sub open_kconfig($$) { 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!/; - print OUT $_; + 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 (<IN>) { + 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"; @@ -73,6 +137,9 @@ while ( my ($key, $value) = each(%config) ) { } 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"; } diff --git a/v4l/scripts/make_makefile.pl b/v4l/scripts/make_makefile.pl new file mode 100644 index 000000000..135b8bdb1 --- /dev/null +++ b/v4l/scripts/make_makefile.pl @@ -0,0 +1,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; + diff --git a/v4l/scripts/make_noconfig.pl b/v4l/scripts/make_noconfig.pl new file mode 100644 index 000000000..503653a4f --- /dev/null +++ b/v4l/scripts/make_noconfig.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +my $config = (); + +open IN,".config"; +while (<IN>) { + if (m/\s*([\d\w_]+)[=](.*)\n/) { +#printf "%s=%s\n",$1,$2; + $config { $1 } = $2; + } +} +close IN; + +open IN,".version"; +while (<IN>) { + if (m/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) { + $version=$1; + $level=$2; + $sublevel=$3; + } +} +close IN; + +open IN,"versions.txt"; +while (<IN>) { + if (m/\[(\d+)\.(\d+)\.(\d+)\]/) { + $minversion=$1; + $minlevel=$2; + $minsublevel=$3; + next; + } + s/\n//; + + if (m/DVB_AV7110_FIRMWARE/) { + next; + } + if (m/DVB_AV7110_FIRMWARE_FILE/) { + next; + } + if (m/^\s*([\w\d_]+)/) { + if ( ($version < $minversion) | + ($level < $minlevel) | + ($sublevel < $minsublevel) ) { + $config { "CONFIG_$1" } = 'n'; +#print "CONFIG_$1 version is not supported\n"; + next; + } + if (!($config { "CONFIG_$1" } ) ) { +print "CONFIG_$1 is unset\n"; + $config { "CONFIG_$1" } = 'n'; + } + } +} +close IN; + +open OUT,">.myconfig"; +while ( my ($key, $value) = each(%config) ) { + printf OUT "%-44s := %s\n",$key,$value; +} +close OUT; |