VirtualBox

Changeset 6571 in vbox for trunk


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

Location:
trunk/src/VBox
Files:
3 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)
  • trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module

    r6159 r6571  
    4444ifneq ($(MAKECMDGOALS),clean)
    4545
    46 ifdef KDIR
    47 # Debian kernel module build system
    48 KERN_DIR := $(KDIR)
    49 endif
     46ifeq ($(KERNELRELEASE),)
    5047
    51 # kernel base directory
    52 ifndef KERN_DIR
    53  KERN_DIR := /lib/modules/$(shell uname -r)/build
    54  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    55   KERN_DIR := /usr/src/linux
     48 #
     49 # building from this directory
     50 #
     51
     52 # kernel base directory
     53 ifndef KERN_DIR
     54  KERN_DIR := /lib/modules/$(shell uname -r)/build
    5655  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    57    $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
     56   KERN_DIR := /usr/src/linux
     57   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
     58    $(error Error: unable to find the sources of your current Linux kernel. \
     59                   Specify KERN_DIR=<directory> and run Make again)
     60   endif
     61   $(warning Warning: using /usr/src/linux as the source directory of your \
     62                      Linux kernel. If this is not correct, specify \
     63                      KERN_DIR=<directory> and run Make again.)
    5864  endif
    59   $(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.)
     65 else
     66  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
     67   $(error Error: KERN_DIR does not point to a directory)
     68  endif
    6069 endif
    61 else
    62  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    63   $(error Error: KERN_DIR does not point to a directory.)
     70
     71 # includes
     72 ifndef KERN_INCL
     73  KERN_INCL = $(KERN_DIR)/include
    6474 endif
    65 endif
     75 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
     76  $(error Error: unable to find the include directory for your current Linux \
     77                 kernel. Specify KERN_INCL=<directory> and run Make again)
     78 endif
    6679
    67 # includes
    68 ifndef KERN_INCL
    69  KERN_INCL = $(KERN_DIR)/include
    70 endif
    71 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    72  $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
    73 endif
     80 # module install dir.
     81 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
     82  ifndef MODULE_DIR
     83   MODULE_DIR_TST := /lib/modules/$(shell uname -r)
     84   ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
     85    MODULE_DIR := $(MODULE_DIR_TST)/misc
     86   else
     87    $(error Unable to find the folder to install the shared folders driver to)
     88   endif
     89  endif # MODULE_DIR unspecified
     90 endif
    7491
    75 # module install dir.
    76 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    77  ifndef MODULE_DIR
    78   MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    79   ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    80    MODULE_DIR := $(MODULE_DIR_TST)/misc
    81   else
    82    $(error Unable to find the folder to install the shared folders driver to)
    83   endif
    84  endif # MODULE_DIR unspecified
    85 endif
     92 # guess kernel version (24 or 26)
     93 ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
     94 KERN_VERSION := 24
     95 else
     96 KERN_VERSION := 26
     97 endif
     98 # KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
    8699
    87 # guess kernel version (24 or 26)
    88 ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
    89 KERN_VERSION := 24
    90 else
    91 KERN_VERSION := 26
    92 endif
    93 # KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
     100else # neq($(KERNELRELEASE),)
     101
     102 #
     103 # building from Linux-2.6-kbuild (make -C <kernel_directory> M=`pwd`)
     104 #
     105
     106 KERN_VERSION := 26
     107
     108endif # neq($(KERNELRELEASE),)
    94109
    95110# debug - show guesses.
     
    106121#
    107122ifndef INCL
    108  INCL    := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
     123 INCL    := $(addprefix -I, $(KERN_INCL) $(EXTRA_INCL))
    109124 ifndef KBUILD_EXTMOD
    110125  KBUILD_EXTMOD := $(shell pwd)
  • trunk/src/VBox/HostDrivers/Support/linux/Makefile

    r6530 r6571  
    105105ifneq ($(MAKECMDGOALS),clean)
    106106
    107 ifdef KDIR
    108 # Debian kernel module build system
    109 KERN_DIR := $(KDIR)
    110 endif
    111 
    112 # kernel base directory
    113 ifndef KERN_DIR
    114  # build for the current kernel, version check
    115  KERN_DIR := /lib/modules/$(shell uname -r)/build
    116  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    117   KERN_DIR := /usr/src/linux
     107ifeq ($(KERNELRELEASE),)
     108
     109 #
     110 # building from this directory
     111 #
     112
     113 # kernel base directory
     114 ifndef KERN_DIR
     115  # build for the current kernel, version check
     116  KERN_DIR := /lib/modules/$(shell uname -r)/build
    118117  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    119    $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
    120   endif
    121   $(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.)
    122  endif
    123  # check if versions match -- works only for later 2.6 kernels
    124  VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) kernelrelease 2> /dev/null || true)
    125  ifneq ($(VBOX_KERN_VER),)
    126   ifneq ($(VBOX_KERN_VER),$(shell uname -r))
    127    $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match the current kernel (version $(shell uname -r)))
    128   endif
    129  endif
    130 else
    131  # build for a dedicated kernel, no version check
    132  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    133   $(error Error: KERN_DIR does not point to a directory.)
    134  endif
    135 endif
    136 
    137 # includes
    138 ifndef KERN_INCL
    139  KERN_INCL = $(KERN_DIR)/include
    140 endif
    141 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    142  $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
    143 endif
    144 
    145 # module install dir, only for current kernel
    146 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    147  ifndef MODULE_DIR
    148   MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    149   ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    150    MODULE_DIR := $(MODULE_DIR_TST)/misc
    151   else
    152    $(error Unable to find the folder to install the support driver to)
    153   endif
    154  endif # MODULE_DIR unspecified
    155 endif
    156 
    157 # guess kernel version (24 or 26)
    158 KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
     118   KERN_DIR := /usr/src/linux
     119   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
     120    $(error Error: unable to find the sources of your current Linux kernel. \
     121                   Specify KERN_DIR=<directory> and run Make again)
     122   endif
     123   $(warning Warning: using /usr/src/linux as the source directory of your \
     124                      Linux kernel. If this is not correct, specify \
     125                      KERN_DIR=<directory> and run Make again.)
     126  endif
     127  # check if versions match -- works only for later 2.6 kernels
     128  VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) kernelrelease 2> /dev/null || true)
     129  ifneq ($(VBOX_KERN_VER),)
     130   ifneq ($(VBOX_KERN_VER),$(shell uname -r))
     131    $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
     132                   the current kernel (version $(shell uname -r)))
     133   endif
     134  endif
     135 else
     136  # build for a dedicated kernel, no version check
     137  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
     138   $(error Error: KERN_DIR does not point to a directory)
     139  endif
     140 endif
     141
     142 # includes
     143 ifndef KERN_INCL
     144  KERN_INCL = $(KERN_DIR)/include
     145 endif
     146 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
     147  $(error Error: unable to find the include directory for your current Linux \
     148                 kernel. Specify KERN_INCL=<directory> and run Make again)
     149 endif
     150
     151 # module install dir, only for current kernel
     152 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
     153  ifndef MODULE_DIR
     154   MODULE_DIR_TST := /lib/modules/$(shell uname -r)
     155   ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
     156    MODULE_DIR := $(MODULE_DIR_TST)/misc
     157   else
     158    $(error Unable to find the folder to install the support driver to)
     159   endif
     160  endif # MODULE_DIR unspecified
     161 endif
     162
     163 # guess kernel version (24 or 26)
     164 KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
     165
     166else # neq($(KERNELRELEASE),)
     167
     168 #
     169 # building from Linux-2.6-kbuild (make -C <kernel_directory> M=`pwd`)
     170 #
     171
     172 KERN_VERSION := 26
     173
     174endif # neq($(KERNELRELEASE),)
    159175
    160176# debug - show guesses.
     
    170186#
    171187ifndef INCL
    172  INCL    := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
     188 INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
    173189 ifndef KBUILD_EXTMOD
    174190  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