VirtualBox

Changeset 18796 in vbox for trunk/src/VBox/Additions/linux


Ignore:
Timestamp:
Apr 7, 2009 6:55:31 AM (16 years ago)
Author:
vboxsync
Message:

Additions/Linux/installer: better test for whether the kernel supports direct rendering

Location:
trunk/src/VBox/Additions/linux
Files:
1 edited
3 copied

Legend:

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

    r18377 r18796  
    9898                $(VBOX_PATH_X11_ADDITION_INSTALLER)/x11config15.pl \
    9999                $(VBOX_PATH_X11_ADDITION_INSTALLER)/x11config15suse.pl \
     100                $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/Makefile.include.header \
     101                $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/Makefile.include.footer \
    100102                $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/Makefile.test \
    101103                $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/test.c \
     104                $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/Makefile.test.drm \
     105                $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/test_drm.c \
    102106                $(PATH_BIN)/additions/vboxmouse_drv.o \
    103107                $(PATH_BIN)/additions/vboxmouse_drv_70.so \
     
    136140        $(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/Makefile.test  $(VBOX_LNX_ADD_INS_OUT_DIR)/module/test/Makefile
    137141        $(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/test.c         $(VBOX_LNX_ADD_INS_OUT_DIR)/module/test/
     142        $(QUIET)$(MKDIR) -p $(VBOX_LNX_ADD_INS_OUT_DIR)/module/test_drm
     143        $(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/Makefile.include.header  $(VBOX_LNX_ADD_INS_OUT_DIR)/module/test_drm
     144        $(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/Makefile.include.footer  $(VBOX_LNX_ADD_INS_OUT_DIR)/module/test_drm
     145        $(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/Makefile.test.drm  $(VBOX_LNX_ADD_INS_OUT_DIR)/module/test_drm/Makefile
     146        $(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_LINUX_ADDITION_INSTALLER)/test_drm.c     $(VBOX_LNX_ADD_INS_OUT_DIR)/module/test_drm/
    138147        $(QUIET)$(VBOX_LNX_ADD_BIN_COPY) $(PATH_BIN)/additions/vboxadd-timesync           $(VBOX_LNX_ADD_INS_OUT_DIR)/vboxadd-timesync
    139148        $(QUIET)$(VBOX_LNX_ADD_BIN_COPY) $(PATH_BIN)/additions/VBoxClient                 $(VBOX_LNX_ADD_INS_OUT_DIR)/VBoxClient
  • trunk/src/VBox/Additions/linux/installer/Makefile.include.footer

    r18716 r18796  
    11#
    2 # VirtualBox Guest Additions Module Makefile.
    3 #
    4 # (For 2.6.x this file must be 'Makefile'!)
     2# VirtualBox Guest Additions kernel module Makefile, common parts.
     3#
     4# (For 2.6.x, the main file must be called 'Makefile'!)
    55#
    66# Copyright (C) 2006-2007 Sun Microsystems, Inc.
     
    2020
    2121#
    22 # First, figure out which architecture we're targeting and the build type.
    23 # (We have to support basic cross building (ARCH=i386|x86_64).)
    24 # While at it, warn about BUILD_* vars found to help with user problems.
    25 #
    26 ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
    27  $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
    28  BUILD_TARGET_ARCH :=
    29 endif
    30 ifeq ($(BUILD_TARGET_ARCH),)
    31  ifeq ($(ARCH),x86_64)
    32   BUILD_TARGET_ARCH := amd64
    33  else
    34   ifeq ($(ARCH),i386)
    35    BUILD_TARGET_ARCH := x86
    36   else
    37    ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
    38     BUILD_TARGET_ARCH := amd64
    39    else
    40     BUILD_TARGET_ARCH := x86
    41    endif
    42   endif
    43  endif
    44 else
    45  $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
    46 endif
    47 
    48 ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
    49  $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
    50  BUILD_TYPE :=
    51 endif
    52 ifeq ($(BUILD_TYPE),)
    53  BUILD_TYPE := release
    54 else
    55  $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
    56 endif
     22# These file should be included by the Makefiles for any kernel modules we
     23# build as part of the Guest Additions.  The intended way of doing this is as
     24# follows:
     25#
     26# include Makefile.include
     27# MOD_NAME = <name of the module to be built, without extension>
     28# MOD_OBJS = <list of object files which should be included>
     29# MOD_FLAGS = <any additional CFLAGS which this module needs>
     30#
     31# The kmk kBuild define KBUILD_TARGET_ARCH is available.
     32#
     33# @todo the shared folders module Makefile also includes the following bits.
     34# Integrate them if necessary.
     35# MOD_FLAGS += -DEXPORT_SYMTAB -DVBGL_VBOXGUEST -DRT_WITH_VBOX
     36#
     37# # special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
     38# # ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
     39# ifeq ($(KERNELRELEASE),)
     40#  KFLAGS += $(foreach inc,$(KERN_INCL),\
     41#              $(if $(wildcard $(inc)/linux/utsrelease.h),\
     42#                $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
     43#                           grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
     44#                           grep '"2.6.18.*v5.*"'  $(inc)/linux/utsrelease.h; \
     45#                           grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
     46#               -DKERNEL_FC6,),))
     47# else
     48#  KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
     49#                       echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
     50#                       echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
     51#                       echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
     52#               -DKERNEL_FC6,)
     53# endif
     54#
     55## important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
     56#       rm -rf .vboxvfs* .tmp_ver* vboxvfs.* Modules.symvers modules.order
     57#
     58
    5759
    5860
    5961# override is required by the Debian guys
    60 override MODULE = vboxadd
    61 OBJS   = \
    62         cmc.o \
    63         vboxmod.o \
    64         GenericRequest.o \
    65         HGCMInternal.o \
    66         Init.o \
    67         PhysHeap.o \
    68         SysHlp.o \
    69         VMMDev.o \
    70         r0drv/alloc-r0drv.o \
    71         r0drv/memobj-r0drv.o \
    72         r0drv/linux/alloc-r0drv-linux.o \
    73         r0drv/linux/assert-r0drv-linux.o \
    74         r0drv/linux/memobj-r0drv-linux.o \
    75         r0drv/linux/process-r0drv-linux.o \
    76         r0drv/linux/semevent-r0drv-linux.o \
    77         r0drv/linux/semfastmutex-r0drv-linux.o \
    78         RTErrConvertToErrno.o \
    79         divdi3.o \
    80         moddi3.o \
    81         udivdi3.o \
    82         umoddi3.o \
    83         qdivrem.o \
    84         logbackdoor.o \
    85         logformat.o \
    86         strformat.o \
    87         strformatrt.o \
    88         strformattype.o \
    89         strprintf.o \
    90         strformat-vbox.o \
    91     RTAssertShouldPanic-generic.o
    92 ifeq ($(BUILD_TARGET_ARCH),amd64)
    93 OBJS += \
    94         alloc/heapsimple.o \
    95         r0drv/linux/spinlock-r0drv-linux.o
    96 endif
     62override MODULE = $(MOD_NAME)
     63OBJS   = $(MOD_OBJS)
    9764
    9865ifneq ($(MAKECMDGOALS),clean)
     
    139106    MODULE_DIR := $(MODULE_DIR_TST)/misc
    140107   else
    141     $(error Unable to find the folder to install the additions driver to)
     108    $(error Unable to find the folder to install the driver ($(MOD_NAME)) to)
    142109   endif
    143110  endif # MODULE_DIR unspecified
     
    245212clean:
    246213        for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
    247         rm -rf .vboxadd* .tmp_ver* vboxadd.* Module.symvers Modules.symvers modules.order
     214        rm -rf .$(MOD_NAME)* .tmp_ver* $(MOD_NAME).* Module.symvers Modules.symvers modules.order
  • trunk/src/VBox/Additions/linux/installer/Makefile.include.header

    r18716 r18796  
    11#
    2 # VirtualBox Guest Additions Module Makefile.
     2# VirtualBox Guest Additions kernel module Makefile, common parts.
    33#
    4 # (For 2.6.x this file must be 'Makefile'!)
     4# (For 2.6.x, the main file must be called 'Makefile'!)
    55#
    66# Copyright (C) 2006-2007 Sun Microsystems, Inc.
     
    1818# additional information or have any questions.
    1919#
     20
     21#
     22# These file should be included by the Makefiles for any kernel modules we
     23# build as part of the Guest Additions.  The intended way of doing this is as
     24# follows:
     25#
     26# # Linux kbuild sets this to our source directory if we are called from
     27# # there
     28# obj ?= $(CURDIR)
     29# include $(obj)/Makefile.include.header
     30# MOD_NAME = <name of the module to be built, without extension>
     31# MOD_OBJS = <list of object files which should be included>
     32# MOD_FLAGS = <any additional CFLAGS which this module needs>
     33# include $(obj)/Makefile.include.footer
     34#
     35# The kmk kBuild define KBUILD_TARGET_ARCH is available.
     36#
     37# @todo the shared folders module Makefile also includes the following bits.
     38# Integrate them if necessary.
     39# MOD_FLAGS += -DEXPORT_SYMTAB -DVBGL_VBOXGUEST -DRT_WITH_VBOX
     40#
     41# # special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
     42# # ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
     43# ifeq ($(KERNELRELEASE),)
     44#  KFLAGS += $(foreach inc,$(KERN_INCL),\
     45#              $(if $(wildcard $(inc)/linux/utsrelease.h),\
     46#                $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
     47#                           grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
     48#                           grep '"2.6.18.*v5.*"'  $(inc)/linux/utsrelease.h; \
     49#                           grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
     50#               -DKERNEL_FC6,),))
     51# else
     52#  KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
     53#                       echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
     54#                       echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
     55#                       echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
     56#               -DKERNEL_FC6,)
     57# endif
     58#
     59## important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
     60#       rm -rf .vboxvfs* .tmp_ver* vboxvfs.* Modules.symvers modules.order
     61#
    2062
    2163#
     
    5597 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
    5698endif
    57 
    58 
    59 # override is required by the Debian guys
    60 override MODULE = vboxadd
    61 OBJS   = \
    62         cmc.o \
    63         vboxmod.o \
    64         GenericRequest.o \
    65         HGCMInternal.o \
    66         Init.o \
    67         PhysHeap.o \
    68         SysHlp.o \
    69         VMMDev.o \
    70         r0drv/alloc-r0drv.o \
    71         r0drv/memobj-r0drv.o \
    72         r0drv/linux/alloc-r0drv-linux.o \
    73         r0drv/linux/assert-r0drv-linux.o \
    74         r0drv/linux/memobj-r0drv-linux.o \
    75         r0drv/linux/process-r0drv-linux.o \
    76         r0drv/linux/semevent-r0drv-linux.o \
    77         r0drv/linux/semfastmutex-r0drv-linux.o \
    78         RTErrConvertToErrno.o \
    79         divdi3.o \
    80         moddi3.o \
    81         udivdi3.o \
    82         umoddi3.o \
    83         qdivrem.o \
    84         logbackdoor.o \
    85         logformat.o \
    86         strformat.o \
    87         strformatrt.o \
    88         strformattype.o \
    89         strprintf.o \
    90         strformat-vbox.o \
    91     RTAssertShouldPanic-generic.o
    92 ifeq ($(BUILD_TARGET_ARCH),amd64)
    93 OBJS += \
    94         alloc/heapsimple.o \
    95         r0drv/linux/spinlock-r0drv-linux.o
    96 endif
    97 
    98 ifneq ($(MAKECMDGOALS),clean)
    99 
    100 ifeq ($(KERNELRELEASE),)
    101 
    102  #
    103  # building from this directory
    104  #
    105 
    106  # kernel base directory
    107  ifndef KERN_DIR
    108   KERN_DIR := /lib/modules/$(shell uname -r)/build
    109   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    110    KERN_DIR := /usr/src/linux
    111    ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    112     $(error Error: unable to find the sources of your current Linux kernel. \
    113                    Specify KERN_DIR=<directory> and run Make again)
    114    endif
    115    $(warning Warning: using /usr/src/linux as the source directory of your \
    116                       Linux kernel. If this is not correct, specify \
    117                       KERN_DIR=<directory> and run Make again.)
    118   endif
    119  else
    120   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    121    $(error Error: KERN_DIR does not point to a directory)
    122   endif
    123  endif
    124 
    125  # includes
    126  ifndef KERN_INCL
    127   KERN_INCL = $(KERN_DIR)/include
    128  endif
    129  ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    130   $(error Error: unable to find the include directory for your current Linux \
    131                  kernel. Specify KERN_INCL=<directory> and run Make again)
    132  endif
    133 
    134  # module install dir, only for current kernel
    135  ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    136   ifndef MODULE_DIR
    137    MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    138    ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    139     MODULE_DIR := $(MODULE_DIR_TST)/misc
    140    else
    141     $(error Unable to find the folder to install the additions driver to)
    142    endif
    143   endif # MODULE_DIR unspecified
    144  endif
    145 
    146  # guess kernel version (24 or 26)
    147  ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
    148   KERN_VERSION := 24
    149  else
    150   KERN_VERSION := 26
    151  endif
    152 
    153 else # neq($(KERNELRELEASE),)
    154 
    155  #
    156  # building from kbuild (make -C <kernel_directory> M=`pwd`)
    157  #
    158 
    159  # guess kernel version (24 or 26)
    160  ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
    161   KERN_VERSION := 24
    162  else
    163   KERN_VERSION := 26
    164  endif
    165 
    166 endif # neq($(KERNELRELEASE),)
    167 
    168 # debug - show guesses.
    169 ifdef DEBUG
    170 $(warning dbg: KERN_DIR     = $(KERN_DIR))
    171 $(warning dbg: KERN_INCL    = $(KERN_INCL))
    172 $(warning dbg: MODULE_DIR   = $(MODULE_DIR))
    173 $(warning dbg: KERN_VERSION = $(KERN_VERSION))
    174 endif
    175 
    176 KBUILD_VERBOSE ?= 1
    177 
    178 #
    179 # Compiler options
    180 #
    181 ifndef INCL
    182  INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
    183  ifndef KBUILD_EXTMOD
    184   KBUILD_EXTMOD := $(shell pwd)
    185  endif
    186  INCL    += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
    187  export INCL
    188 endif
    189 KFLAGS   := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 \
    190             -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM \
    191             -DLOG_TO_BACKDOOR -DRT_WITH_VBOX -DIN_MODULE -DIN_GUEST_R0
    192 ifeq ($(BUILD_TARGET_ARCH),amd64)
    193  KFLAGS  += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
    194 else
    195  KFLAGS  += -DRT_ARCH_X86
    196 endif
    197 ifeq ($(BUILD_TYPE),debug)
    198 KFLAGS   += -DDEBUG
    199 endif
    200 
    201 ifeq ($(KERN_VERSION), 24)
    202 #
    203 # 2.4
    204 #
    205 
    206 CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(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 
    217 else
    218 #
    219 # 2.6 and later
    220 #
    221 
    222 MODULE_EXT := ko
    223 
    224 $(MODULE)-y  := $(OBJS)
    225 
    226 # build defs
    227 EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
    228 
    229 all: $(MODULE)
    230 
    231 obj-m += $(MODULE).o
    232 
    233 $(MODULE):
    234         $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
    235 
    236 endif
    237 
    238 install: $(MODULE)
    239         @mkdir -p $(MODULE_DIR); \
    240         install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
    241         PATH="$(PATH):/bin:/sbin" depmod -ae;
    242 
    243 endif # eq($(MAKECMDGOALS),clean)
    244 
    245 clean:
    246         for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
    247         rm -rf .vboxadd* .tmp_ver* vboxadd.* Module.symvers Modules.symvers modules.order
  • trunk/src/VBox/Additions/linux/installer/Makefile.test.drm

    r18716 r18796  
    66# Copyright (C) 2006-2007 Sun Microsystems, Inc.
    77#
    8 # This file is part of VirtualBox Open Source Edition (OSE), as
    9 # available from http://www.virtualbox.org. This file is free software;
    10 # you can redistribute it and/or modify it under the terms of the GNU
    11 # General Public License (GPL) as published by the Free Software
    12 # Foundation, in version 2 as it comes in the "COPYING" file of the
    13 # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
    14 # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    158#
    16 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
    17 # Clara, CA 95054 USA or visit http://www.sun.com if you need
    18 # additional information or have any questions.
     9# Use only with permission
    1910#
    2011
    21 #
    22 # First, figure out which architecture we're targeting and the build type.
    23 # (We have to support basic cross building (ARCH=i386|x86_64).)
    24 # While at it, warn about BUILD_* vars found to help with user problems.
    25 #
    26 ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
    27  $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
    28  BUILD_TARGET_ARCH :=
    29 endif
    30 ifeq ($(BUILD_TARGET_ARCH),)
    31  ifeq ($(ARCH),x86_64)
    32   BUILD_TARGET_ARCH := amd64
    33  else
    34   ifeq ($(ARCH),i386)
    35    BUILD_TARGET_ARCH := x86
    36   else
    37    ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
    38     BUILD_TARGET_ARCH := amd64
    39    else
    40     BUILD_TARGET_ARCH := x86
    41    endif
    42   endif
    43  endif
    44 else
    45  $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
    46 endif
     12# Linux kbuild sets this to our source directory if we are called from there
     13obj ?= $(CURDIR)
    4714
    48 ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
    49  $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
    50  BUILD_TYPE :=
    51 endif
    52 ifeq ($(BUILD_TYPE),)
    53  BUILD_TYPE := release
    54 else
    55  $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
    56 endif
     15include $(obj)/Makefile.include.header
    5716
     17MOD_NAME = vboxadd_test_drm
     18MOD_OBJS = test_drm.o
     19# These are present in the shared folders Makefile but not the main one.
     20# MOD_FLAGS = -DEXPORT_SYMTAB -DVBGL_VBOXGUEST -DRT_WITH_VBOX
    5821
    59 # override is required by the Debian guys
    60 override MODULE = vboxadd
    61 OBJS   = \
    62         cmc.o \
    63         vboxmod.o \
    64         GenericRequest.o \
    65         HGCMInternal.o \
    66         Init.o \
    67         PhysHeap.o \
    68         SysHlp.o \
    69         VMMDev.o \
    70         r0drv/alloc-r0drv.o \
    71         r0drv/memobj-r0drv.o \
    72         r0drv/linux/alloc-r0drv-linux.o \
    73         r0drv/linux/assert-r0drv-linux.o \
    74         r0drv/linux/memobj-r0drv-linux.o \
    75         r0drv/linux/process-r0drv-linux.o \
    76         r0drv/linux/semevent-r0drv-linux.o \
    77         r0drv/linux/semfastmutex-r0drv-linux.o \
    78         RTErrConvertToErrno.o \
    79         divdi3.o \
    80         moddi3.o \
    81         udivdi3.o \
    82         umoddi3.o \
    83         qdivrem.o \
    84         logbackdoor.o \
    85         logformat.o \
    86         strformat.o \
    87         strformatrt.o \
    88         strformattype.o \
    89         strprintf.o \
    90         strformat-vbox.o \
    91     RTAssertShouldPanic-generic.o
    92 ifeq ($(BUILD_TARGET_ARCH),amd64)
    93 OBJS += \
    94         alloc/heapsimple.o \
    95         r0drv/linux/spinlock-r0drv-linux.o
    96 endif
    97 
    98 ifneq ($(MAKECMDGOALS),clean)
    99 
    100 ifeq ($(KERNELRELEASE),)
    101 
    102  #
    103  # building from this directory
    104  #
    105 
    106  # kernel base directory
    107  ifndef KERN_DIR
    108   KERN_DIR := /lib/modules/$(shell uname -r)/build
    109   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    110    KERN_DIR := /usr/src/linux
    111    ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    112     $(error Error: unable to find the sources of your current Linux kernel. \
    113                    Specify KERN_DIR=<directory> and run Make again)
    114    endif
    115    $(warning Warning: using /usr/src/linux as the source directory of your \
    116                       Linux kernel. If this is not correct, specify \
    117                       KERN_DIR=<directory> and run Make again.)
    118   endif
    119  else
    120   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    121    $(error Error: KERN_DIR does not point to a directory)
    122   endif
    123  endif
    124 
    125  # includes
    126  ifndef KERN_INCL
    127   KERN_INCL = $(KERN_DIR)/include
    128  endif
    129  ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    130   $(error Error: unable to find the include directory for your current Linux \
    131                  kernel. Specify KERN_INCL=<directory> and run Make again)
    132  endif
    133 
    134  # module install dir, only for current kernel
    135  ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    136   ifndef MODULE_DIR
    137    MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    138    ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    139     MODULE_DIR := $(MODULE_DIR_TST)/misc
    140    else
    141     $(error Unable to find the folder to install the additions driver to)
    142    endif
    143   endif # MODULE_DIR unspecified
    144  endif
    145 
    146  # guess kernel version (24 or 26)
    147  ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
    148   KERN_VERSION := 24
    149  else
    150   KERN_VERSION := 26
    151  endif
    152 
    153 else # neq($(KERNELRELEASE),)
    154 
    155  #
    156  # building from kbuild (make -C <kernel_directory> M=`pwd`)
    157  #
    158 
    159  # guess kernel version (24 or 26)
    160  ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
    161   KERN_VERSION := 24
    162  else
    163   KERN_VERSION := 26
    164  endif
    165 
    166 endif # neq($(KERNELRELEASE),)
    167 
    168 # debug - show guesses.
    169 ifdef DEBUG
    170 $(warning dbg: KERN_DIR     = $(KERN_DIR))
    171 $(warning dbg: KERN_INCL    = $(KERN_INCL))
    172 $(warning dbg: MODULE_DIR   = $(MODULE_DIR))
    173 $(warning dbg: KERN_VERSION = $(KERN_VERSION))
    174 endif
    175 
    176 KBUILD_VERBOSE ?= 1
    177 
    178 #
    179 # Compiler options
    180 #
    181 ifndef INCL
    182  INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
    183  ifndef KBUILD_EXTMOD
    184   KBUILD_EXTMOD := $(shell pwd)
    185  endif
    186  INCL    += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
    187  export INCL
    188 endif
    189 KFLAGS   := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 \
    190             -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM \
    191             -DLOG_TO_BACKDOOR -DRT_WITH_VBOX -DIN_MODULE -DIN_GUEST_R0
    192 ifeq ($(BUILD_TARGET_ARCH),amd64)
    193  KFLAGS  += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
    194 else
    195  KFLAGS  += -DRT_ARCH_X86
    196 endif
    197 ifeq ($(BUILD_TYPE),debug)
    198 KFLAGS   += -DDEBUG
    199 endif
    200 
    201 ifeq ($(KERN_VERSION), 24)
    202 #
    203 # 2.4
    204 #
    205 
    206 CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(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 
    217 else
    218 #
    219 # 2.6 and later
    220 #
    221 
    222 MODULE_EXT := ko
    223 
    224 $(MODULE)-y  := $(OBJS)
    225 
    226 # build defs
    227 EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
    228 
    229 all: $(MODULE)
    230 
    231 obj-m += $(MODULE).o
    232 
    233 $(MODULE):
    234         $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
    235 
    236 endif
    237 
    238 install: $(MODULE)
    239         @mkdir -p $(MODULE_DIR); \
    240         install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
    241         PATH="$(PATH):/bin:/sbin" depmod -ae;
    242 
    243 endif # eq($(MAKECMDGOALS),clean)
    244 
    245 clean:
    246         for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
    247         rm -rf .vboxadd* .tmp_ver* vboxadd.* Module.symvers Modules.symvers modules.order
     22include $(obj)/Makefile.include.footer
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