Hello,
I made a diff -u -p for configure, I added use warnings and my kernel_version
function to the configure script.
I hope you will like it and most of all I hope I didn't braked anything :)
Best regards
Marian
--- configure 2007-10-26 22:18:55.000000000 +0300
+++ /home/hackman/configure 2007-11-23 21:39:20.000000000 +0200
@@ -13,16 +13,22 @@
###############################################################################
###############################################################################
+use warnings;
use Getopt::Long;
use POSIX qw(uname);
+
print "\nConfiguring Makefiles for your system...\n";
# Set a bunch of variables
-$ret = 0;
+my $ret = 0;
+
+# this should be only the major version without the extra version
+# eg. only the first 3 digits
+my $required_kernelversion = '2.6.24';
-%options = (
+my %options = (
help => \$help,
cc => \$cc,
debug => \$debug,
@@ -80,7 +86,7 @@ $ret = 0;
without_rgmanager => \$without_rgmanager,
);
-$err = &GetOptions (\%options,
+my $err = &GetOptions (\%options,
'help',
'cc=s',
'debug',
@@ -202,6 +208,65 @@ if ($help || !$err) {
exit $ret;
}
+sub kernel_version {
+ my $autoconf_path = shift;
+ my $required_version = shift;
+ my $build_version = 0;
+ my $build_patchlevel = 0;
+ my $build_sublevel = 0;
+ my $build_extraversion = 0;
+
+ # add autoconf to the path
+ $autoconf_path .= '/include/linux/autoconf.h';
+ my @version = split /\./, $required_version;
+ my $current_version = 0;
+ if ( -f $autoconf_path ) {
+ # open the autoconf.h to feth VERSION, PATCHLEVEL and SUBLEVEL, if needed I can add EXTRAVERSION too
+ open AUTOCONF, '<', $autoconf_path;
+ while (<AUTOCONF>) {
+ if ($_ =~ /CONFIG_KERNELVERSION/) {
+ $current_version = $_;
+ # we don't need to check any thing else in this file so we are stopping the read
+ last;
+ }
+ }
+ close AUTOCONF;
+ # leaving only the numbers from the lines
+ # this is faster then split and doesn't alocate useless arrays
+ $current_version =~ s/.*"(.*)"\n/$1/;
+ # parse the kernel version into the variables
+ if ($current_version =~ /\-/) {
+ my @line = split /\-/, $current_version;
+ my @ver = split /\./, $line[0];
+ $build_version = $ver[0];
+ $build_patchlevel = $ver[1];
+ $build_sublevel = $ver[2];
+ $build_extraversion = $line[1];
+ print "Note: You are using unstable kernel version!\n";
+ } else {
+ my @kernel = split /\./, $current_version;
+ $build_version = $kernel[0];
+ $build_patchlevel = $kernel[1];
+ $build_sublevel = $kernel[2];
+ $build_extraversion = $kernel[3];
+ }
+ # checking VERSION, PATCHLEVEL and SUBLEVEL for the supplied kernel
+ # if needed I can add also EXTRAVERSION to the check
+ if ($build_version >= $version[0] &&
+ $build_patchlevel >= $version[1] &&
+ $build_sublevel >= $version[2]) {
+ print 'Current kernel version is OK',"\n";
+ return 1;
+ } else {
+ print 'Current kernel version: ',$current_version,"\nMinimum version: ",$version[0].'.'.$version[1].'.'.$version[2],"\n";
+ return 0;
+ }
+ } else {
+ print "Unable to find ($autoconf_path)!\n";
+ return 0;
+ }
+}
+
$pwd = `pwd`;
chomp($pwd);
@@ -245,6 +310,9 @@ if (!$kernel_src) {
$kernel_src=$kernel_build;
}
}
+if (!kernel_version($kernel_src,$required_kernelversion)) {
+ exit 1;
+}
if (!$module_dir) {
$module_dir="/lib/modules/$un[2]/kernel";
}
@@ -374,10 +442,10 @@ if (!$without_gnbd) {
if (!$without_rgmanager) {
$without_rgmanager="";
}
-if (not length $release_major) {
+if (defined($release_major) && not length $release_major) {
$release_major="";
}
-if (not length $release_minor) {
+if (defined($release_minor) && not length $release_minor) {
$release_minor="";
}