diff options
author | Trent Piepho <xyzzy@speakeasy.org> | 2006-08-31 16:35:22 -0700 |
---|---|---|
committer | Trent Piepho <xyzzy@speakeasy.org> | 2006-08-31 16:35:22 -0700 |
commit | 60afcd8be0160ea0420df3b93a07f258952cb135 (patch) | |
tree | f5d9f8bea69d3c0d5800ab8cd09dcbe817587fe8 /v4l/scripts/make_kconfig.pl | |
parent | 5a3de175c8db2821c8ed908310db372c249ca18f (diff) | |
download | mediapointer-dvb-s2-60afcd8be0160ea0420df3b93a07f258952cb135.tar.gz mediapointer-dvb-s2-60afcd8be0160ea0420df3b93a07f258952cb135.tar.bz2 |
New code to read kernel config in make_kconfig.pl
From: Trent Piepho <xyzzy@speakeasy.org>
New code to read the Kernel's (or v4l-dvb's) '.config' file. This
replaces the code that used to read the config.h/autoconf.h file. In
2.6.18 the autoconf.h file no longer mentions options set to 'n' at all,
while .config has a comment line for each disabled option. Reading
.config is easier and gives us a list of the disabled options.
Restructure the code for reading '.version' too.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Diffstat (limited to 'v4l/scripts/make_kconfig.pl')
-rwxr-xr-x | v4l/scripts/make_kconfig.pl | 87 |
1 files changed, 36 insertions, 51 deletions
diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index 950e620d4..066df6a0e 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -14,58 +14,34 @@ my $version, $level, $sublevel, $kernver; my $kernel=shift; my $force_kconfig=shift; -#my $debug=1; - -#!/usr/bin/perl -use FileHandle; +my $debug=0; ########################################################### -# Checks config.h and autoconf.h for current kernel defines +# Read a .config file (first argument) and put the resulting options in a +# hash which is returned. This subroutine should be called in a hash +# context or it will not be very useful. sub process_config ($) { my $filename = shift; + my %conf; my $in = new FileHandle; - open $in,"$kernel/include/$filename" or die "File not found: $kernel/include/$filename"; + open $in, $filename or die "File not found: $filename"; while (<$in>) { - if (m/\#define\s+CONFIG_([^ ]*)_ON_SMP\s+(.*)\n/) { - my $key=$1; - my $value=$2; - printf "defined $key as $value\n" if $debug; - if ( $value == 1 ) { - $value='y'; - } - $kernopts{$key}=$value; + if (/^CONFIG_(\w+)\s*=\s*(\S.*?)\s*$/) { + $conf{$1} = $2; next; } - if (m/\#define\s+CONFIG_([^ ]*)_MODULE\s+(.*)\n/) { - my $key=$1; - my $value=$2; - printf "defined $key as $value\n" if $debug; - if ( $value == 1 ) { - $value='m'; - } - $kernopts{$key}=$value; + if (/^# CONFIG_(\w+) is not set$/) { + $conf{$1} = 'n'; next; } - if (m/\#define\s+CONFIG_([^ ]*)\s+(.*)\n/) { - my $key=$1; - my $value=$2; - printf "defined $key as $value\n" if $debug; - if ( $value == 1 ) { - $value='y'; - } - $kernopts{$key}=$value; - next; - } - if (m/\#undef\s+CONFIG_([^ ]*)\n/) { - printf "undefined $1\n" if $debug; - $kernopts{$1}='n'; - next; + unless (/^#|$/) { + print "Confused by this line in $filename:\n$_"; } } - close $in; + return %conf; } sub add_bool($) @@ -301,12 +277,12 @@ EOF close $in; } -sub parse_versions () +sub parse_versions() { my $in = new FileHandle; my $ver; - open $in,"versions.txt" or die "File not found: versions.txt"; + open $in, "versions.txt" or die "File not found: versions.txt"; while (<$in>) { if (/\[(\d+\.\d+\.\d+)\]/) { $ver = $1; @@ -318,6 +294,21 @@ sub parse_versions () close $in; } +# Read in the .version file to get the kernel version +sub get_version() +{ + open IN, '<.version' or die 'File not found: .version'; + while (<IN>) { + if (/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) { + $version=$1; + $level=$2; + $sublevel=$3; + return $kernver="$version.$level.$sublevel"; + } + } + close IN; +} + # Like ver1 <=> ver2, but understands X.Y.Z version strings sub cmp_ver($$) { @@ -333,20 +324,14 @@ sub cmp_ver($$) return $v1_sublevel <=> $v2_sublevel; } -process_config("linux/autoconf.h"); +# Get kernel's config settings +%kernopts = process_config("$kernel/.config"); -parse_versions; +# Get minimum kernel version for our variables +parse_versions(); -open IN,".version" or die "File not found: .version"; -while (<IN>) { - if (m/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) { - $version=$1; - $level=$2; - $sublevel=$3; - $kernver="$version.$level.$sublevel"; - } -} -close IN; +# Get kernel version +get_version(); print "Preparing to compile for kernel version $kernver\n"; |