Pre-build the kernel module in up/smp and i386/i586/i686/athlon architectures.
authorshort <>
Thu, 21 Aug 2003 15:19:28 +0000 (15:19 +0000)
committershort <>
Thu, 21 Aug 2003 15:19:28 +0000 (15:19 +0000)
kernel/Linux/prepmod.in

index 6e87842..d74c8af 100755 (executable)
@@ -38,7 +38,8 @@ my $tmp_dir="prepmod-tmp-dir";
 my $quiet;
 my $kernel;
 my $prebuild;
-my $kernel_gcc_args="";
+use vars qw($kernel_gcc_args);
+$kernel_gcc_args="";
 
 my $lufsmnt_bin;
 if ($0 eq "lufsmnt" || $0=~m#/lufsmnt$#) {
@@ -71,6 +72,16 @@ my($filename,$optional)=@_;
        return $r;
 }
 
+sub _writefile
+{
+my($filename,@content)=@_;
+
+       local *F;
+       open F,($filename=~/^[|]/ ? "" : ">").$filename or confess "rewrite \"$filename\": $!";
+       print F @content;
+       close F or confess "close \"$filename\": $!";   # Do not &cluck as it may be pipe result
+}
+
 sub _system
 {
 my(@args)=@_;
@@ -134,7 +145,7 @@ else {
        }
 
 local $_;
-for (<$modbindir/*-$uname_r/*.o>,<$modbindir/*-${uname_r_base}/*.o>,<$modbindir/*/*.o>) {
+for (<$modbindir/*-$uname_r*/*.o>,<$modbindir/*-${uname_r_base}*/*.o>,<$modbindir/*/*.o>) {
        next if _system "rmmod lufs 2>/dev/null; insmod -o lufs -p $_ 2>/dev/null";
        do { cluck "Failed to symlink $_"; next; } if _system "rm -rf $moduledir; mkdir -p $moduledir; ln -s $_ $moduledir/lufs.o";
        _pass 1;
@@ -153,7 +164,9 @@ my($kernel,$uname_r,$destmodule)=@_;
        do { $kdebug=$_ if !/^@/; } for ('@KDEBUG_FLAGS@');
        my $cmdline="gcc"
                        .($quiet ? " 2>/dev/null" : "")
-                       ." -O2 -pipe -fomit-frame-pointer -fno-strict-aliasing -mpreferred-stack-boundary=2 -Wall"
+                       ." -Wall -Wstrict-prototypes -Wno-trigraphs"
+                       ." -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2"
+                       #." -march=i586"
                        ." -D__KERNEL__ -DMODULE -DLINUX -DKBUILD_MODNAME=lufs"
                        ." ".$kdebug
                        ." ".$kernel_gcc_args
@@ -205,7 +218,37 @@ my($rpm)=@_;
        do { $dir||=$_ if -d $_; } for ($tmp_dir."/usr/src/linux-$uname_r");
        do { $dir||=$_ if -d $_; } for ($tmp_dir."/usr/src/linux-$uname_r_base");       # older RedHat kernels
        $dir or confess "Kernel source tree not found in: $rpm";
-       prebuild_kernel $dir,$vendor,$uname_r;
+       _writefile "| patch $dir/include/linux/rhconfig.h",<<'RHCONFIG_H_NOBOOT_EOF';
+--- ./include/linux/rhconfig.h-orig    Thu Aug 21 14:50:16 2003
++++ ./include/linux/rhconfig.h Thu Aug 21 14:59:22 2003
+@@ -10,7 +10,7 @@
+  * /boot/kernel.h - initscripts should create it for us
+  */
+-#include "/boot/kernel.h"
++/* lufs: #include "/boot/kernel.h" */
+ #if defined(__BOOT_KERNEL_SMP) && (__BOOT_KERNEL_SMP == 1)
+ #define __module__smp
+RHCONFIG_H_NOBOOT_EOF
+       for my $smp ("","smp") {
+               my @archs=qw(i386 i586 i686 athlon);
+               for my $arch (@archs) {
+                       my %boot=(
+                                       "__BOOT_KERNEL_SMP"=>$smp,
+                                       map({ ("__MODULE_KERNEL_$_"=>($arch eq $_)); } @archs),
+                                       "__BOOT_KERNEL_BOOT"=>0,
+                                       "__BOOT_KERNEL_BOOTSMP"=>0,
+                                       "__BOOT_KERNEL_ENTERPRISE"=>0,
+                                       "__BOOT_KERNEL_BIGMEM"=>0,
+                                       "__BOOT_KERNEL_DEBUG"=>0,
+                                       );
+                       local $kernel_gcc_args=join(" ",map({ " -D$_=".($boot{$_} ? 1 : 0); } keys(%boot)))
+                                       ." -march=$arch"
+                                       ." ".$kernel_gcc_args;
+                       prebuild_kernel $dir,$vendor,$uname_r.$smp.".".$arch;
+                       }
+               }
        _system "rm -rf $tmp_dir" and confess "Deletion of: $tmp_dir";
 }