compile fix for parallels worksation and newer linux kernels

When you try to use parallels-config with a newer Linux kernel like 2.6.17-rc5, it ends up in a recursive endless-loop like the following example shows:
(mini) [/usr/lib/parallels] make
Making all in drivers
make[1]: Entering directory `/usr/lib/parallels/drivers'
Making all in .
make[2]: Entering directory `/usr/lib/parallels/drivers'
=> Patching modules makefiles for 2.6.x kernel ...
for i in hypervisor/Makefile drv_main/Makefile drv_net/linux/Makefile drv_virtualnic/Makefile; do \
                sed s/CFLAGS\ =/CFLAGS\ :=\ \$\(CFLAGS\)/ $i | \
                sed s/obj_m/obj-m/ | \
                sed s/hypervisor_objs/hypervisor-objs/ | \
                sed s/vm_main_objs/vm-main-objs/ | \
                sed s/vm_bridge_objs/vm-bridge-objs/ | \
                sed s/vmvirtualnic_objs/vmvirtualnic-objs/ | \
                sed s/_extra_ldflags\ =/EXTRA_LDFLAGS+=/ | \
                sed s/_extra_cflags\ =/EXTRA_CFLAGS+=/ | \
                sed s/include\ .\\/\$\(DEPDIR\)/#/ > $i.t; mv -f $i.t $i;\
        done
cp -f drv_main/common/md5.c hypervisor/;
cp -f drv_main/common/utils.c hypervisor/;
make[2]: Leaving directory `/usr/lib/parallels/drivers'
Making all in hypervisor
make[2]: Entering directory `/usr/lib/parallels/drivers/hypervisor'
make -C /lib/modules/2.6.17-rc5/build SUBDIRS=/usr/lib/parallels/drivers/hypervisor SRCROOT=/usr/lib/parallels/drivers/hypervisor modules && mv -f hypervisor.ko hypervisor.o
make[3]: Entering directory `/home/sithglan/work/linux-2.6'
make -C /lib/modules/2.6.17-rc5/build SUBDIRS=/home/sithglan/work/linux-2.6 SRCROOT=/home/sithglan/work/linux-2.6 modules && mv -f hypervisor.ko hypervisor.o
make -C /lib/modules/2.6.17-rc5/build SUBDIRS=/home/sithglan/work/linux-2.6 SRCROOT=/home/sithglan/work/linux-2.6 modules && mv -f hypervisor.ko hypervisor.o
...
So I used git-bisect to find the offending patch (20a468b51325b3636785a8ca0047ae514b39cbd5) in the linux kernel tree. I tracked it down to the following delta within the patch:
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index acd3b96..e48e60d 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -10,11 +10,12 @@ __build:
 # Read .config if it exist, otherwise ignore
 -include .config

+include scripts/Kbuild.include
+
 # The filename Kbuild has precedence over Makefile
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
 include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)

-include scripts/Kbuild.include
 include scripts/Makefile.lib

 ifdef host-progs
So if you reverse apply this delta or apply this patch parallels-config won't endless loop anylonger. I don't think that this is a problem of the linux kernel build system but of the way parallels is abusing it. I contacted the original author of the patch to get sure and keep you posted. Here is the thread on LKML related to this topic.
Last modified: Mon Jun 5 18:23:10 CEST 2006Thomas Glanzmann