VirtualBox

Ignore:
Timestamp:
Jan 29, 2008 4:03:17 PM (17 years ago)
Author:
vboxsync
Message:

Linux kernel modules: allow to build from kBuild (KERNELRELEASE set), cosmetical fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/module/Makefile.module

    r6159 r6571  
    4646ifneq ($(MAKECMDGOALS),clean)
    4747
    48 ifdef KDIR
    49 # Debian kernel module build system
    50 KERN_DIR := $(KDIR)
    51 endif
     48ifeq ($(KERNELRELEASE),)
    5249
    53 # kernel base directory
    54 ifndef KERN_DIR
    55  KERN_DIR := /lib/modules/$(shell uname -r)/build
    56  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    57   KERN_DIR := /usr/src/linux
     50 #
     51 # building from this directory
     52 #
     53
     54 # kernel base directory
     55 ifndef KERN_DIR
     56  KERN_DIR := /lib/modules/$(shell uname -r)/build
    5857  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    59    $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
     58   KERN_DIR := /usr/src/linux
     59   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
     60    $(error Error: unable to find the sources of your current Linux kernel. \
     61                   Specify KERN_DIR=<directory> and run Make again)
     62   endif
     63   $(warning Warning: using /usr/src/linux as the source directory of your \
     64                      Linux kernel. If this is not correct, specify \
     65                      KERN_DIR=<directory> and run Make again.)
    6066  endif
    61   $(warning Warning: using /usr/src/linux as the source directory of your Linux kernel. If this is not correct, specify KERN_DIR=<directory> and run Make again.)
     67 else
     68  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
     69   $(error Error: KERN_DIR does not point to a directory)
     70  endif
    6271 endif
    63 else
    64  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    65   $(error Error: KERN_DIR does not point to a directory.)
     72
     73 # includes
     74 ifndef KERN_INCL
     75  KERN_INCL = $(KERN_DIR)/include
    6676 endif
    67 endif
     77 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
     78  $(error Error: unable to find the include directory for your current Linux \
     79                 kernel. Specify KERN_INCL=<directory> and run Make again)
     80 endif
    6881
    69 # includes
    70 ifndef KERN_INCL
    71  KERN_INCL = $(KERN_DIR)/include
    72 endif
    73 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    74  $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
    75 endif
     82 # module install dir.
     83 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
     84  ifndef MODULE_DIR
     85   MODULE_DIR_TST := /lib/modules/$(shell uname -r)
     86   ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
     87    MODULE_DIR := $(MODULE_DIR_TST)/misc
     88   else
     89    $(error Unable to find the folder to install the additions driver to)
     90   endif
     91  endif # MODULE_DIR unspecified
     92 endif
    7693
    77 # module install dir.
    78 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    79  ifndef MODULE_DIR
    80   MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    81   ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    82    MODULE_DIR := $(MODULE_DIR_TST)/misc
    83   else
    84    $(error Unable to find the folder to install the additions driver to)
    85   endif
    86  endif # MODULE_DIR unspecified
    87 endif
     94 # guess kernel version (24 or 26)
     95 ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
     96 KERN_VERSION := 24
     97 else
     98 KERN_VERSION := 26
     99 endif
     100 # KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
     101 
     102else # neq($(KERNELRELEASE),)
    88103
    89 # guess kernel version (24 or 26)
    90 ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
    91 KERN_VERSION := 24
    92 else
    93 KERN_VERSION := 26
    94 endif
    95 # KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
     104 #
     105 # building from Linux-2.6-kbuild (make -C <kernel_directory> M=`pwd`)
     106 #
     107
     108 KERN_VERSION := 26
     109
     110endif # neq($(KERNELRELEASE),)
    96111
    97112# debug - show guesses.
     
    108123#
    109124ifndef INCL
    110  INCL    := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
     125 INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
    111126 ifndef KBUILD_EXTMOD
    112127  KBUILD_EXTMOD := $(shell pwd)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette