[OpenAFS-devel] Kernel module recompilation

Kuba Ober kuba@mareimbrium.org
Fri, 25 May 2001 10:22:39 +0200


(complaint 2 - RedHat 7.0 kernel module recompilation)

My machine is dual-boot windows/redhat 7.0 smp (2xPIII)
and here's the problem as well: I can't get kernel module to recompile. 
I'm using 2.2.17 kernel (that's the only one supported by win4lin at the 
moment [see www.win4lin.com]), so precompiled modules for 2.2.19 won't fit.

I'm using hand-compiled kernel, with sources in usual /usr/src/linux 
tree, and I've installed all openafs-1.0.4.rpm as well as openafs-client a
nd openafs-kernel-source.

Make build-it fails, complaining it can't find Makefile.extradefs:

cd src; make all LINUX_SRCDIR=/usr/src/linux-`uname -r` LINUX_VERS=`uname -r`
make[1]: Entering directory `/usr/src/openafs-kernel-1.0.4/src'
Makefile:52: Makefile.extradefs: No such file or directory
Makefile:167: warning: overriding commands for target `xdr_int64.o'
Makefile.common:234: warning: ignoring old commands for target `xdr_int64.o'
make[1]: *** No rule to make target `Makefile.extradefs'.  Stop.

So I remove the include Makefile.extradefs 

cat Makefile | grep -v extradefs > Makefile.2
mv Makefile.2 Makefile
cat src/Makefile | grep -v extradefs > Makefile.2
mv Makefile.2 src/Makefile

and this happens:

[root@kuba openafs-kernel-1.0.4]# make build-it
cd src; make all LINUX_SRCDIR=/usr/src/linux-`uname -r` LINUX_VERS=`uname -r`
make[1]: Entering directory `/usr/src/openafs-kernel-1.0.4/src'
Makefile:165: warning: overriding commands for target `xdr_int64.o'
Makefile.common:234: warning: ignoring old commands for target `xdr_int64.o'
rm -f h net netinet sys rpc
ln -s rx rpc
for v in 2.2.17-14 ; do \
        for m in MP SP ; do \
                KDIR=MODLOAD-$v-$m; \
                mkdir -p ${KDIR}; \
                ln -fs ../Makefile ${KDIR}/Makefile ; \
                ln -fs ../Makefile.common ${KDIR}/Makefile.common; \
        done \
done
for v in 2.2.17-14 ; do \
[snip]
Building in directory: MODLOAD-2.2.17-14-MP
make[2]: Entering directory `/usr/src/openafs-kernel-1.0.4/src/MODLOAD-2.2.17-14-MP'
Makefile:165: warning: overriding commands for target `xdr_int64.o'
Makefile.common:234: warning: ignoring old commands for target `xdr_int64.o'
gcc  -O2 -fomit-frame-pointer -fno-strength-reduce -pipe -march=i486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -D__KERNEL__  -DCPU=586 -DKERNEL -D_KERNEL -DMODULE -DAFS_SMP -D__BOOT_KERNEL_SMP=1 -D__BOOT_KERNEL_UP=0 -D__SMP__  -I. -I../ -c ../afs/afs_atomlist.c;
gcc  -O2 -fomit-frame-pointer -fno-strength-reduce -pipe -march=i486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -D__KERNEL__  -DCPU=586 -DKERNEL -D_KERNEL -DMODULE -DAFS_SMP -D__BOOT_KERNEL_SMP=1 -D__BOOT_KERNEL_UP=0 -D__SMP__  -I. -I../ -c ../afs/afs_lhash.c;
gcc  -O2 -fomit-frame-pointer -fno-strength-reduce -pipe -march=i486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -D__KERNEL__  -DCPU=586 -DKERNEL -D_KERNEL -DMODULE -DAFS_SMP -D__BOOT_KERNEL_SMP=1 -D__BOOT_KERNEL_UP=0 -D__SMP__  -I. -I../ -c ../afs/afs_analyze.c;
In file included from ../afs/afs_sysnames.h:23,
                 from ../afs/param.h:30,
                 from ../afs/afs_analyze.c:13:
../afs/stds.h:197:25: ../h/string.h: No such file or directory
[snip...]
make[2]: *** [afs_analyze.o] Error 1
make[2]: Leaving directory `/usr/src/openafs-kernel-1.0.4/src/MODLOAD-2.2.17-14-MP'
make[1]: *** [linux_compdirs] Error 2
make[1]: Leaving directory `/usr/src/openafs-kernel-1.0.4/src'
make: *** [src/COMMON/libafs.o] Error 2

Ok, so now it looks like we have configuration mishap. Perhaps configure script would be handy? Anyway, 
it cannot find headers, so let's help it a little.

cd src
ls

And what's up? Well, all symlinks are decently screwed up. Here's a sample:
asm -> /usr/src/linux-2.2.17-142.2.17-14/include/asm-i386

So the first problem is that uname -r returns x.y.z-v version, but under redhat the dirs are named x.y.z without -v.

Another problem is that asm and asm-generic have $$v in their symlink command (double-insert) variables 
instead of $v, although this might be GNU-make peculiar (I'm using RedHat provided GNU Make version 3.79.1). 
Another thing is that CPU is wrongly defined as 586 (I have 686), but that's fixed in src/Makefile and can be
easily changed. Consider making configure script???

Anyway, the fixes are here. At least it compiles for RH 7.0, alhtough I have to tell yet whether it's stable or not. 
This is a `total' diff needed for successful RH 7.0 compile, probably RH 7.1 requires it as well.

[root@kuba openafs-kernel-1.0.4]# diff -u Makefile.old Makefile
--- Makefile.old        Wed Apr 25 20:21:34 2001
+++ Makefile    Fri May 25 10:12:26 2001
@@ -1,5 +1,5 @@
 # Where to find the kernel, by default
-SPEC=`uname -r`
+SPEC=`uname -r | sed -e s/-.*\$///`
 LNX22_SRCDIR=/usr/src/linux-$(SPEC)
 #ROOT_CLIENT=root.client

[root@kuba openafs-kernel-1.0.4]# diff -u src/Makefile.old src/Makefile
--- src/Makefile.old    Wed Apr 25 20:21:34 2001
+++ src/Makefile        Fri May 25 10:09:00 2001
@@ -49,7 +49,6 @@
 MPS = MP SP

 # To pick up anything we might have missed
-include Makefile.extradefs
 
 # COMPDIRS is called in Makefile.common to do the actual builds.
 COMPDIRS=linux_compdirs
@@ -66,7 +65,6 @@
                        mkdir -p $${KDIR}; \
                        ln -fs ../Makefile $${KDIR}/Makefile ; \
                        ln -fs ../Makefile.common $${KDIR}/Makefile.common; \
-                       sh ./redhat.sh ${LINUX_SRCDIR}$$v $${KDIR}/Makefile.extradefs; \
                done \
        done
 
@@ -88,9 +86,9 @@
                rm -f sys; \
                ln -s $${IDIR} sys; \
                rm -f asm-generic; \
-               ln -s ${LINUX_SRCDIR}$$v/include/asm-generic asm-generic; \
+               ln -s ${LINUX_SRCDIR}$v/include/asm-generic asm-generic; \
                rm -f asm; \
-               ln -s ${LINUX_SRCDIR}$$v/include/asm-i386 asm ; \
+               ln -s ${LINUX_SRCDIR}$v/include/asm-i386 asm ; \
                for m in ${MPS} ; do \
                        KDIR=${KOBJ}-$$v-$$m ; \
                        echo Building in directory: $${KDIR} ; \

Now it compiles fine.

On a lighter (?) note: are there any plans to put it into the kernel tree? It would make life simpler for some people

Please cc: me as I'm not on the list, thanks.

Cheerz,
Kuba