diff options
Diffstat (limited to 'v4l/scripts/make_kconfig.pl')
-rwxr-xr-x | v4l/scripts/make_kconfig.pl | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index d5b34b36c..771efa63d 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -9,7 +9,7 @@ my %hexopt = (); my %tristate = (); my %kernopts = (); my %depmods = (); -my $version, $level, $sublevel; +my $version, $level, $sublevel, $kernver; my $kernel=shift; my $force_kconfig=shift; @@ -282,24 +282,14 @@ EOF $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) ) { + if (exists $minver{$key} && + cmp_ver($minver{$key}, $kernver) > 0) { $disabled=1; disable_config ($key); - print "$key requires version $minversion.$minlevel.$minsublevel\n"; + print "$key requires version $minver{$key}\n"; print OUT "# $key disabled for insufficient kernel version\n"; } else { -# print "OK: $key requires version $minversion.$minlevel.$minsublevel\n"; +# printf "OK: $key requires version %s\n", exists $minver{$key}?$minver{$key}:"any"; $disabled=0; } } @@ -318,19 +308,31 @@ sub parse_versions () open $in,"versions.txt" or die "File not found: 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); + if (/\[(\d+\.\d+\.\d+)\]/) { + $ver = $1; + } elsif (/^\s*(\w+)/) { + $minver{$1} = $ver; +# print "$1=$ver\n"; } } close $in; } +# Like ver1 <=> ver2, but understands X.Y.Z version strings +sub cmp_ver($$) +{ + shift =~ /(\d+)\.(\d+)\.(\d+)/; + my ($v1_ver,$v1_level,$v1_sublevel) = ($1,$2,$3); + shift =~ /(\d+)\.(\d+)\.(\d+)/; + my ($v2_ver,$v2_level,$v2_sublevel) = ($1,$2,$3); + + my $cmp = $v1_ver <=> $v2_ver; + return $cmp unless($cmp == 0); + $cmp = $v1_level <=> $v2_level; + return $cmp unless($cmp == 0); + return $v1_sublevel <=> $v2_sublevel; +} + process_config("linux/config.h"); parse_versions; @@ -341,11 +343,12 @@ while (<IN>) { $version=$1; $level=$2; $sublevel=$3; + $kernver="$version.$level.$sublevel"; } } close IN; -printf "Preparing to compile for kernel version %d.%d.%d\n",$version,$level,$sublevel; +print "Preparing to compile for kernel version $kernver\n"; open OUT,">Kconfig" or die "Cannot write Kconfig file"; |