+use warnings;
use Getopt::Long;
use POSIX qw(uname);
+
print "
Configuring Makefiles for your system...
";
# 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.23';
+sub kernel_version {
+ my $autoconf_path = shift;
+ my $required_version = shift;
+ my $build_version = 0;
+ my $build_patchlevel = 0;
+ my $build_sublevel = 0;
+
+ print "
Checking kernel:
";
+
+ # 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/.*"(.*)"
/$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];
+ } else {
+ my @kernel = split /./, $current_version;
+ $build_version = $kernel[0];
+ $build_patchlevel = $kernel[1];
+ $build_sublevel = $kernel[2];
+ }
+ # 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 appears to be OK
";
+ return 1;
+ } else {
+ print " Current kernel version: ",$current_version,"
Minimum kernel version: ",$required_version,"
";
+ print " FAILED!
";
+ return 0;
+ }
+ } else {
+ print " Unable to find ($autoconf_path)!
";
+ print " Make sure that:
- the above path is correct
";
+ print " - your kernel is properly configured and prepared.
";
+ print " - kernel_build and kernel_src options to configure are set properly.
";
+ return 0;
+ }
+}
+
$pwd = `pwd`;
chomp($pwd);
From Soren Hansen:
"It's handy to be able to
disable the new kernel version check if we don't actually have the
kernel headers around, but know that the proper stuff is around when
it's needed."