Index: /trunk/src/VBox/Installer/linux/Makefile.include.header
===================================================================
--- /trunk/src/VBox/Installer/linux/Makefile.include.header	(revision 66502)
+++ /trunk/src/VBox/Installer/linux/Makefile.include.header	(revision 66503)
@@ -14,4 +14,10 @@
 # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 #
+
+# Testing:
+# * Building with KERN_VER set to an installed but non-current kernel works and
+#   installs to the right location.
+# * Building with KERN_DIR and/or MODULE_DIR set uses the value specified and
+#   the default value for the unspecified one if any.
 
 #
@@ -89,7 +95,16 @@
  #
 
+ # target kernel version
+ ifndef KERN_VER
+  KERN_VER := $(shell uname -r)
+ else
+  ifneq ($(shell if test -d /lib/modules/$(KERN_VER)/build; then echo yes; fi),yes)
+   KERN_VER := $(shell uname -r)
+  endif
+ endif
+
  # kernel base directory
  ifndef KERN_DIR
-  KERN_DIR := /lib/modules/$(shell uname -r)/build
+  KERN_DIR := /lib/modules/$(KERN_VER)/build
   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    KERN_DIR := /usr/src/linux
@@ -120,5 +135,5 @@
  ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
   ifndef MODULE_DIR
-   MODULE_DIR_TST := /lib/modules/$(shell uname -r)
+   MODULE_DIR_TST := /lib/modules/$(KERN_VER)
    ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
     MODULE_DIR := $(MODULE_DIR_TST)/misc
