Skip to contentSkip to conversation

Set a useful default for kerneldir

PATCH In review Andi Kleen 3 participants 5 messages Jul 1, 2009 – Jul 9, 2009

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Set a useful default for kerneldir

When no explicit kerneldir is specified use the standard /lib/modules/$(uname -r)/build
convention to find the kernel includes. This should work out of the box on a large number of distributions.

Also support separate objdirs.

configure +7 -0
index eb9d73a..8c2491d 100755
@@ -1148,6 +1148,13 @@ if test "$kvm" = "yes" ; then
 #endif
 int main(void) { return 0; }
 EOF
+  if test "$kerneldir" = "" ; then
+      kerneldir="/lib/modules/`uname -r`/build"
+      if test -d "$kerneldir/source" ; then
+          kerneldir="$kerneldir/source"
+      fi
+  fi
+  echo "Kerneldir         $kerneldir"
   if test "$kerneldir" != "" ; then
       kvm_cflags=-I"$kerneldir"/include
       if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
Signature · 1 line
[email protected] -- Speaking for myself only.
#1 lore raw
Quoted 8 lines · Andi Kleen

When no explicit kerneldir is specified use the standard
/lib/modules/$(uname -r)/build
convention to find the kernel includes. This should work out of the box on a large number of distributions.

Also support separate objdirs.

The reason we don't specify an explicit include is that it makes it possible to have a cross compiler with headers installed in the cross compilers root. If you default to /lib/modules, you have to explicitly override it when cross compiling.

Another option would be to just include the KVM headers in QEMU.

Regards,

Anthony Liguori

author
#2 lore raw
Quoted 4 lines · Anthony Liguori

The reason we don't specify an explicit include is that it makes it possible to have a cross compiler with headers installed in the cross compilers root. If you default to /lib/modules, you have to explicitly override it when cross compiling.

You can still override it for special cases. This is just a better default than /usr/include which is near always wrong.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#3 lore raw
In reply to Anthony Liguori
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Andi Kleen

When no explicit kerneldir is specified use the standard
/lib/modules/$(uname -r)/build
convention to find the kernel includes. This should work out of the box on a large number of distributions.

Quoted 7 lines
Quoted 3 lines

Also support separate objdirs.

The reason we don't specify an explicit include is that it makes it possible to have a cross compiler with headers installed in the cross compilers root. If you default to /lib/modules, you have to explicitly override it when cross compiling.

Another option would be to just include the KVM headers in QEMU.

Or to have kvm-kmod install the headers in /usr/local/include. I'm wary about that though, it makes qemu features depend on the installation order of qemu and kvm-kmod.

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw
In reply to Andi Kleen
Quoted 14 lines · Andi Kleen

When no explicit kerneldir is specified use the standard
/lib/modules/$(uname -r)/build
convention to find the kernel includes. This should work out of the box on a large number of distributions.

Also support separate objdirs.

configure +0 -0
index eb9d73a..8c2491d 100755
@@ -1148,6 +1148,13 @@ if test "$kvm" = "yes" ; then
 #endif

configure if test "$kvm" = "yes" ; then · line 1158

Quoted 10 lines
configure +7 -0
 int main(void) { return 0; }
 EOF
+  if test "$kerneldir" = "" ; then
+      kerneldir="/lib/modules/`uname -r`/build"
+      if test -d "$kerneldir/source" ; then
+          kerneldir="$kerneldir/source"
+      fi
+  fi
+  echo "Kerneldir         $kerneldir"
 

This is the wrong place for this echo. They're all unified in a block further down in the code.

Regards,

Anthony Liguori