VirtualBox

Changeset 36584 in vbox


Ignore:
Timestamp:
Apr 6, 2011 2:41:38 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71024
Message:

Additions/linux/installer: modularise the vboxsf.ko kernel makefile

Location:
trunk/src/VBox/Additions/linux/sharedfolders
Files:
2 edited

Legend:

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

    r36293 r36584  
    44# (For 2.6.x this file must be 'Makefile'!)
    55#
    6 # Copyright (C) 2006-2010 Oracle Corporation
     6# Copyright (C) 2006-2011 Oracle Corporation
    77#
    88# This file is part of VirtualBox Open Source Edition (OSE), as
     
    1515#
    1616
    17 #
    18 # First, figure out which architecture we're targeting and the build type.
    19 # (We have to support basic cross building (ARCH=i386|x86_64).)
    20 # While at it, warn about BUILD_* vars found to help with user problems.
    21 #
    22 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
    23  BUILD_TARGET_ARCH_DEF := amd64
    24 else
    25  BUILD_TARGET_ARCH_DEF := x86
    26 endif
    27 ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
    28  $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
    29  BUILD_TARGET_ARCH :=
    30 endif
    31 ifeq ($(BUILD_TARGET_ARCH),)
    32  ifeq ($(ARCH),x86_64)
    33   BUILD_TARGET_ARCH := amd64
    34  else
    35   ifeq ($(ARCH),i386)
    36    BUILD_TARGET_ARCH := x86
    37   else
    38    BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
    39   endif
    40  endif
    41 else
    42  ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
    43   $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
    44  endif
    45 endif
     17# Linux kbuild sets this to our source directory if we are called from there
     18obj ?= $(CURDIR)
     19include $(obj)/Makefile.include.header
    4620
    47 ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
    48  $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
    49  BUILD_TYPE :=
    50 endif
    51 ifeq ($(BUILD_TYPE),)
    52  BUILD_TYPE := release
    53 else
    54  ifneq ($(BUILD_TYPE),release)
    55   $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
    56  endif
    57 endif
    58 
    59 
    60 # override is required by the Debian guys
    61 override MODULE = vboxsf
    62 OBJS   = \
     21MOD_NAME = vboxsf
     22MOD_OBJS   = \
    6323        vfsmod.o \
    6424        dirops.o \
     
    7535        VbglR0CanUsePhysPageList.o
    7636ifeq ($(BUILD_TARGET_ARCH),x86)
    77 OBJS  += \
     37MOD_OBJS  += \
    7838        divdi3.o \
    7939        moddi3.o \
     
    8343endif
    8444
    85 EXTRA_CFLAGS = -fshort-wchar
     45MOD_INCL = \
     46    $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux) \
     47    $(addprefix -I$(KBUILD_EXTMOD)/vboxsf,/ /include /r0drv/linux)
    8648
    87 ifneq ($(MAKECMDGOALS),clean)
    88 
    89 ifeq ($(KERNELRELEASE),)
    90 
    91  #
    92  # building from this directory
    93  #
    94 
    95  # kernel base directory
    96  ifndef KERN_DIR
    97   KERN_DIR := /lib/modules/$(shell uname -r)/build
    98   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    99    KERN_DIR := /usr/src/linux
    100    ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    101     $(error Error: unable to find the sources of your current Linux kernel. \
    102                    Specify KERN_DIR=<directory> and run Make again)
    103    endif
    104    $(warning Warning: using /usr/src/linux as the source directory of your \
    105                       Linux kernel. If this is not correct, specify \
    106                       KERN_DIR=<directory> and run Make again.)
    107   endif
    108  else
    109   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    110    $(error Error: KERN_DIR does not point to a directory)
    111   endif
    112  endif
    113 
    114  # includes
    115  ifndef KERN_INCL
    116   KERN_INCL = $(KERN_DIR)/include
    117  endif
    118  ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    119   $(error Error: unable to find the include directory for your current Linux \
    120                  kernel. Specify KERN_INCL=<directory> and run Make again)
    121  endif
    122 
    123  # module install dir.
    124  ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    125   ifndef MODULE_DIR
    126    MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    127    ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    128     MODULE_DIR := $(MODULE_DIR_TST)/misc
    129    else
    130     $(error Unable to find the folder to install the shared folders driver to)
    131    endif
    132   endif # MODULE_DIR unspecified
    133  endif
    134 
    135  # guess kernel version (24 or 26)
    136  ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
    137   KERN_VERSION := 24
    138  else
    139   KERN_VERSION := 26
    140  endif
    141 
    142 else # neq($(KERNELRELEASE),)
    143 
    144  #
    145  # building from kbuild (make -C <kernel_directory> M=`pwd`)
    146  #
    147 
    148  # guess kernel version (24 or 26)
    149  ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
    150   KERN_VERSION := 24
    151  else
    152   KERN_VERSION := 26
    153  endif
    154 
    155 endif # neq($(KERNELRELEASE),)
    156 
    157 # debug - show guesses.
    158 ifdef DEBUG
    159 $(warning dbg: KERN_DIR     = $(KERN_DIR))
    160 $(warning dbg: KERN_INCL    = $(KERN_INCL))
    161 $(warning dbg: MODULE_DIR   = $(MODULE_DIR))
    162 $(warning dbg: KERN_VERSION = $(KERN_VERSION))
    163 endif
    164 
    165 KBUILD_VERBOSE ?= 1
    166 
    167 #
    168 # Compiler options
    169 #
    170 ifndef INCL
    171  INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
    172  ifndef KBUILD_EXTMOD
    173   KBUILD_EXTMOD := $(shell pwd)
    174  endif
    175  INCL    += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
    176  INCL    += $(addprefix -I$(KBUILD_EXTMOD)/vboxsf,/ /include /r0drv/linux)
    177  export INCL
    178 endif
    17949ifneq ($(wildcard $(KBUILD_EXTMOD)/vboxsf),)
    18050 MANGLING := $(KBUILD_EXTMOD)/vboxsf/include/VBox/VBoxGuestMangling.h
     
    18252 MANGLING := $(KBUILD_EXTMOD)/include/VBox/VBoxGuestMangling.h
    18353endif
    184 KFLAGS   := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
     54
     55MOD_DEFS   = -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
    18556            -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DIN_MODULE -DIN_GUEST_R0
    18657# our module does not export any symbol
    187 KFLAGS   += -DRT_NO_EXPORT_SYMBOL
     58MOD_DEFS  += -DRT_NO_EXPORT_SYMBOL
    18859ifeq ($(BUILD_TARGET_ARCH),amd64)
    189  KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
     60 MOD_DEFS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
    19061else
    191  KFLAGS  += -DRT_ARCH_X86
    192 endif
    193 ifeq ($(BUILD_TYPE),debug)
    194  KFLAGS  += -DDEBUG
     62 MOD_DEFS += -DRT_ARCH_X86
    19563endif
    19664
    19765ifeq ($(KERN_VERSION), 24)
    198 #
    199 # 2.4
    200 #
    201 
    202 ifeq ($(BUILD_TARGET_ARCH),amd64)
    203  KFLAGS  += -mcmodel=kernel
    204 endif
    205 
    206 CFLAGS := -O2 -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
    207 MODULE_EXT := o
    208 
    209 # 2.4 Module linking
    210 $(MODULE).o: $(OBJS)
    211         $(LD) -o $@ -r $(OBJS)
    212 
    213 .PHONY: $(MODULE)
    214 all: $(MODULE)
    215 $(MODULE): $(MODULE).o
    216 
     66 MOD_CFLAGS =
    21767else
    218 #
    219 # 2.6 and later
    220 #
    221 
    222 MODULE_EXT := ko
    223 
    224 $(MODULE)-y  := $(OBJS)
     68 MOD_CFLAGS = -fshort-wchar -include $(MANGLING)
    22569
    22670# special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
    22771# ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
    228 ifeq ($(KERNELRELEASE),)
    229  KFLAGS += $(foreach inc,$(KERN_INCL),\
    230              $(if $(wildcard $(inc)/linux/utsrelease.h),\
    231                $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
     72 ifeq ($(KERNELRELEASE),)
     73  MOD_EXTRA += $(foreach inc,$(KERN_INCL),\
     74              $(if $(wildcard $(inc)/linux/utsrelease.h),\
     75                $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
    23276                            grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
    23377                            grep '"2.6.18.*v5.*"'  $(inc)/linux/utsrelease.h; \
    23478                            grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
    23579                -DKERNEL_FC6,),))
    236 else
    237  KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
     80 else
     81  MOD_EXTRA += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
    23882                        echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
    23983                        echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
    24084                        echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
    24185                -DKERNEL_FC6,)
     86 endif
    24287endif
    24388
    244 # build defs
    245 EXTRA_CFLAGS += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG)
     89MOD_CLEAN = . linux r0drv r0drv/linux
    24690
    247 all: $(MODULE)
    248 
    249 obj-m += $(MODULE).o
    250 
    251 $(MODULE):
    252         $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
    253 
    254 endif
    255 
    256 install: $(MODULE)
    257         @mkdir -p $(MODULE_DIR); \
    258         install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
    259         PATH="$(PATH):/bin:/sbin" depmod -a;
    260 
    261 endif # eq($(MAKECMDGOALS),clean)
    262 
    263 # important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
    264 clean:
    265         for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
    266         rm -rf .vboxsf* .tmp_ver* vboxsf.* Modules.symvers modules.order
     91include $(obj)/Makefile.include.footer
  • trunk/src/VBox/Additions/linux/sharedfolders/files_vboxsf

    r36190 r36584  
    6565    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VMMDev.cpp=>VMMDev.c \
    6666    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VbglR0CanUsePhysPageList.cpp=>VbglR0CanUsePhysPageList.c \
     67    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.header \
     68    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.footer \
    6769    ${PATH_ROOT}/src/VBox/Runtime/common/math/gcc/divdi3.c=>divdi3.c \
    6870    ${PATH_ROOT}/src/VBox/Runtime/common/math/gcc/moddi3.c=>moddi3.c \
Note: See TracChangeset for help on using the changeset viewer.

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