VirtualBox

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

Additions/linux/installer: modularise vboxvideo.ko kernel makefile

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

Legend:

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

    r36293 r36602  
    1515#
    1616
    17 ## @todo We must make this into a common template *soon*.
     17# Linux kbuild sets this to our source directory if we are called from there
     18obj ?= $(CURDIR)
     19include $(obj)/Makefile.include.header
    1820
    19 #
    20 # First, figure out which architecture we're targeting and the build type.
    21 # (We have to support basic cross building (ARCH=i386|x86_64).)
    22 # While at it, warn about BUILD_* vars found to help with user problems.
    23 #
    24 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
    25  BUILD_TARGET_ARCH_DEF := amd64
    26 else
    27  BUILD_TARGET_ARCH_DEF := x86
    28 endif
    29 ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
    30  $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
    31  BUILD_TARGET_ARCH :=
    32 endif
    33 ifeq ($(BUILD_TARGET_ARCH),)
    34  ifeq ($(ARCH),x86_64)
    35   BUILD_TARGET_ARCH := amd64
    36  else
    37   ifeq ($(ARCH),i386)
    38    BUILD_TARGET_ARCH := x86
    39   else
    40    BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
    41   endif
    42  endif
    43 else
    44  ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
    45   $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
    46  endif
    47 endif
     21MOD_NAME   = vboxvideo
    4822
    49 ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
    50  $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
    51  BUILD_TYPE :=
    52 endif
    53 ifeq ($(BUILD_TYPE),)
    54  BUILD_TYPE := release
    55 else
    56  ifneq ($(BUILD_TYPE),release)
    57   $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
    58  endif
    59 endif
     23MOD_OBJS   = vboxvideo_drm.o
    6024
    61 EXTRA_CFLAGS = -fshort-wchar
    62 
    63 ifneq ($(MAKECMDGOALS),clean)
    64 
    65 ifeq ($(KERNELRELEASE),)
    66 
    67  #
    68  # building from this directory
    69  #
    70 
    71  # kernel base directory
    72  ifndef KERN_DIR
    73   KERN_DIR := /lib/modules/$(shell uname -r)/build
    74   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    75    KERN_DIR := /usr/src/linux
    76    ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    77     $(error Error: unable to find the sources of your current Linux kernel. \
    78                    Specify KERN_DIR=<directory> and run Make again)
    79    endif
    80    $(warning Warning: using /usr/src/linux as the source directory of your \
    81                       Linux kernel. If this is not correct, specify \
    82                       KERN_DIR=<directory> and run Make again.)
    83   endif
    84  else
    85   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    86    $(error Error: KERN_DIR does not point to a directory)
    87   endif
    88  endif
    89 
    90  # includes
    91  ifndef KERN_INCL
    92   KERN_INCL = $(KERN_DIR)/include
    93  endif
    94  ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    95   $(error Error: unable to find the include directory for your current Linux \
    96                  kernel. Specify KERN_INCL=<directory> and run Make again)
    97  endif
    98 
    99  # module install dir.
    100  ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    101   ifndef MODULE_DIR
    102    MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    103    ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    104     MODULE_DIR := $(MODULE_DIR_TST)/misc
    105    else
    106     $(error Unable to find the folder to install the DRM driver to)
    107    endif
    108   endif # MODULE_DIR unspecified
    109  endif
    110 
    111  # guess kernel version (24 or 26)
    112  ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
    113   KERN_VERSION := 24
    114  else
    115   KERN_VERSION := 26
    116  endif
    117 
    118 else # neq($(KERNELRELEASE),)
    119 
    120  #
    121  # building from kbuild (make -C <kernel_directory> M=`pwd`)
    122  #
    123 
    124  # guess kernel version (24 or 26)
    125  ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
    126   KERN_VERSION := 24
    127  else
    128   KERN_VERSION := 26
    129  endif
    130 
    131 endif # neq($(KERNELRELEASE),)
    132 
    133 # debug - show guesses.
    134 ifdef DEBUG
    135 $(warning dbg: KERN_DIR     = $(KERN_DIR))
    136 $(warning dbg: KERN_INCL    = $(KERN_INCL))
    137 $(warning dbg: MODULE_DIR   = $(MODULE_DIR))
    138 $(warning dbg: KERN_VERSION = $(KERN_VERSION))
    139 endif
    140 
    141 KBUILD_VERBOSE ?= 1
    142 
    143 #
    144 # Compiler options
    145 #
    146 ifndef INCL
    147  INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
    148  ifndef KBUILD_EXTMOD
    149   KBUILD_EXTMOD := $(shell pwd)
    150  endif
    151  INCL    += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
    152  INCL    += $(addprefix -I$(KBUILD_EXTMOD)/vboxvideo,/ /include /r0drv/linux)
    153  export INCL
    154 endif
    15525ifneq ($(wildcard $(KBUILD_EXTMOD)/vboxvideo),)
    15626 MANGLING := $(KBUILD_EXTMOD)/vboxvideo/include/VBox/VBoxGuestMangling.h
     
    15828 MANGLING := $(KBUILD_EXTMOD)/include/VBox/VBoxGuestMangling.h
    15929endif
    160 KFLAGS   := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
    161             -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DLOG_TO_BACKDOOR -DIN_MODULE \
    162             -DIN_GUEST_R0
     30MOD_CFLAGS = -fshort-wchar -include $(MANGLING)
     31MOD_INCL   = $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
     32# What on earth is this?
     33MOD_INCL  += $(addprefix -I$(KBUILD_EXTMOD)/vboxvideo,/ /include /r0drv/linux)
     34MOD_DEFS  := -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
     35             -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DLOG_TO_BACKDOOR -DIN_MODULE \
     36             -DIN_GUEST_R0
    16337# our module does not export any symbol
    164 KFLAGS   += -DRT_NO_EXPORT_SYMBOL
     38MOD_DEFS  += -DRT_NO_EXPORT_SYMBOL
    16539ifeq ($(BUILD_TARGET_ARCH),amd64)
    166  KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
     40 MOD_DEFS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
    16741else
    168  KFLAGS += -DRT_ARCH_X86
     42 MOD_DEFS += -DRT_ARCH_X86
    16943endif
    170 ifeq ($(BUILD_TYPE),debug)
    171 KFLAGS   += -DDEBUG
    172 endif
     44MOD_CLEAN  = . linux r0drv r0drv/linux
    17345
    174 # override is required by the Debian guys
    175 override MODULE = vboxvideo
    176 OBJS   = vboxvideo_drm.o
    177 
    178 ifeq ($(KERN_VERSION), 24)
    179 #
    180 # 2.4
    181 #
    182 
    183 CFLAGS := -O2 -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
    184 MODULE_EXT := o
    185 
    186 # 2.4 Module linking
    187 $(MODULE).o: $(OBJS)
    188         $(LD) -o $@ -r $(OBJS)
    189 
    190 .PHONY: $(MODULE)
    191 all: $(MODULE)
    192 $(MODULE): $(MODULE).o
    193 
    194 else
    195 #
    196 # 2.6 and later
    197 #
    198 
    199 MODULE_EXT := ko
    200 
    201 $(MODULE)-y  := $(OBJS)
    202 
    203 # special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
    204 # ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
    205 ifeq ($(KERNELRELEASE),)
    206  KFLAGS += $(foreach inc,$(KERN_INCL),\
    207              $(if $(wildcard $(inc)/linux/utsrelease.h),\
    208                $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
    209                             grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
    210                             grep '"2.6.18.*v5.*"'  $(inc)/linux/utsrelease.h; \
    211                             grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
    212                 -DKERNEL_FC6,),))
    213 else
    214  KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
    215                         echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
    216                         echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
    217                         echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
    218                 -DKERNEL_FC6,)
    219 endif
    220 
    221 # build defs
    222 EXTRA_CFLAGS += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG)
    223 
    224 all: $(MODULE)
    225 
    226 obj-m += $(MODULE).o
    227 
    228 $(MODULE):
    229         $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
    230 
    231 endif
    232 
    233 install: $(MODULE)
    234         @mkdir -p $(MODULE_DIR); \
    235         install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
    236         PATH="$(PATH):/bin:/sbin" depmod -a;
    237 
    238 endif # eq($(MAKECMDGOALS),clean)
    239 
    240 # important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
    241 clean:
    242         for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
    243         rm -rf .vboxvideo* .tmp_ver* vboxvideo.* Modules.symvers modules.order
    244 
     46include $(obj)/Makefile.include.footer
  • trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drm

    r36198 r36602  
    2222    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_drm.c=>vboxvideo_drm.c \
    2323    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_drm.h=>vboxvideo_drm.h \
     24    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.header \
     25    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.footer \
    2426    ${PATH_OUT}/version-generated.h=>version-generated.h \
    2527    ${PATH_OUT}/product-generated.h=>product-generated.h \
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