VirtualBox

Ignore:
Timestamp:
Apr 1, 2011 3:37:35 PM (14 years ago)
Author:
vboxsync
Message:

Additions/linux: make vboxguest.ko makefile use generic header and footer

Location:
trunk/src/VBox/Additions/common/VBoxGuest/linux
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/linux/Makefile

    r36408 r36510  
    55
    66#
    7 # Copyright (C) 2006-2010 Oracle Corporation
     7# Copyright (C) 2006-2011 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616#
    1717
    18 #
    19 # First, figure out which architecture we're targeting and the build type.
    20 # (We have to support basic cross building (ARCH=i386|x86_64).)
    21 # While at it, warn about BUILD_* vars found to help with user problems.
    22 #
    23 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
    24  BUILD_TARGET_ARCH_DEF := amd64
    25 else
    26  BUILD_TARGET_ARCH_DEF := x86
    27 endif
    28 ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
    29  $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
    30  BUILD_TARGET_ARCH :=
    31 endif
    32 ifeq ($(BUILD_TARGET_ARCH),)
    33  ifeq ($(ARCH),x86_64)
    34   BUILD_TARGET_ARCH := amd64
    35  else
    36   ifeq ($(ARCH),i386)
    37    BUILD_TARGET_ARCH := x86
    38   else
    39    BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
    40   endif
    41  endif
    42 else
    43  ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
    44   $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
    45  endif
    46 endif
     18# Linux kbuild sets this to our source directory if we are called from there
     19obj ?= $(CURDIR)
     20include $(obj)/Makefile.include.header
    4721
    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  ifneq ($(BUILD_TYPE),release)
    56   $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
    57  endif
    58 endif
     22MOD_NAME = vboxguest
    5923
    60 
    61 # override is required by the Debian guys
    62 override MODULE = vboxguest
    63 OBJS   = \
     24MOD_OBJS   = \
    6425        VBoxGuest-linux.o \
    6526        VBoxGuest.o \
     
    13091        VBox/logbackdoor.o
    13192ifeq ($(BUILD_TARGET_ARCH),x86)
    132 OBJS += \
     93MOD_OBJS += \
    13394        common/math/gcc/divdi3.o \
    13495        common/math/gcc/moddi3.o \
     
    13899endif
    139100ifeq ($(BUILD_TARGET_ARCH),amd64)
    140 OBJS += common/alloc/heapsimple.o
     101MOD_OBJS +=     common/alloc/heapsimple.o
    141102endif
    142103
    143 ifneq ($(MAKECMDGOALS),clean)
     104MOD_DEFS = -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM
     105ifeq ($(BUILD_TARGET_ARCH),amd64)
     106 MOD_DEFS  += -DRT_ARCH_AMD64
     107else
     108 MOD_DEFS  += -DRT_ARCH_X86
     109endif
     110ifeq ($(BUILD_TARGET_ARCH),amd64)
     111 MOD_DEFS += -DVBOX_WITH_64_BITS_GUESTS
     112endif
     113MOD_INCL  = $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
     114MOD_INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxguest,/ /include /r0drv/linux)
    144115
    145 ifeq ($(KERNELRELEASE),)
    146 
    147  #
    148  # building from this directory
    149  #
    150 
    151  # kernel base directory
    152  ifndef KERN_DIR
    153   KERN_DIR := /lib/modules/$(shell uname -r)/build
    154   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    155    KERN_DIR := /usr/src/linux
    156    ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    157     $(error Error: unable to find the sources of your current Linux kernel. \
    158                    Specify KERN_DIR=<directory> and run Make again)
    159    endif
    160    $(warning Warning: using /usr/src/linux as the source directory of your \
    161                       Linux kernel. If this is not correct, specify \
    162                       KERN_DIR=<directory> and run Make again.)
    163   endif
    164  else
    165   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    166    $(error Error: KERN_DIR does not point to a directory)
    167   endif
    168  endif
    169 
    170  # includes
    171  ifndef KERN_INCL
    172   KERN_INCL = $(KERN_DIR)/include
    173  endif
    174  ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    175   $(error Error: unable to find the include directory for your current Linux \
    176                  kernel. Specify KERN_INCL=<directory> and run Make again)
    177  endif
    178 
    179  # module install dir, only for current kernel
    180  ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    181   ifndef MODULE_DIR
    182    MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    183    ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    184     MODULE_DIR := $(MODULE_DIR_TST)/misc
    185    else
    186     $(error Unable to find the folder to install the additions driver to)
    187    endif
    188   endif # MODULE_DIR unspecified
    189  endif
    190 
    191  # guess kernel version (24 or 26)
    192  ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
    193   KERN_VERSION := 24
    194  else
    195   KERN_VERSION := 26
    196  endif
    197 
    198 else # neq($(KERNELRELEASE),)
    199 
    200  #
    201  # building from kbuild (make -C <kernel_directory> M=`pwd`)
    202  #
    203 
    204  # guess kernel version (24 or 26)
    205  ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
    206   KERN_VERSION := 24
    207  else
    208   KERN_VERSION := 26
    209  endif
    210 
    211 endif # neq($(KERNELRELEASE),)
    212 
    213 # debug - show guesses.
    214 ifdef DEBUG
    215 $(warning dbg: KERN_DIR     = $(KERN_DIR))
    216 $(warning dbg: KERN_INCL    = $(KERN_INCL))
    217 $(warning dbg: MODULE_DIR   = $(MODULE_DIR))
    218 $(warning dbg: KERN_VERSION = $(KERN_VERSION))
    219 endif
    220 
    221 KBUILD_VERBOSE ?= 1
    222 
    223 #
    224 # Compiler options
    225 #
    226 ifndef INCL
    227  INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
    228  ifndef KBUILD_EXTMOD
    229   KBUILD_EXTMOD := $(shell pwd)
    230  endif
    231  INCL    += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
    232  INCL    += $(addprefix -I$(KBUILD_EXTMOD)/vboxguest,/ /include /r0drv/linux)
    233  export INCL
    234 endif
    235116ifneq ($(wildcard $(KBUILD_EXTMOD)/vboxguest),)
    236117 MANGLING := $(KBUILD_EXTMOD)/vboxguest/include/VBox/VBoxGuestMangling.h
     
    238119 MANGLING := $(KBUILD_EXTMOD)/include/VBox/VBoxGuestMangling.h
    239120endif
    240 KFLAGS   := -D__KERNEL__ -DMODULE \
    241         -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 \
    242         -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM
    243 ifeq ($(BUILD_TARGET_ARCH),amd64)
    244  KFLAGS  += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
     121ifeq ($(KERN_VERSION),24)
     122 MOD_CFLAGS =
    245123else
    246  KFLAGS  += -DRT_ARCH_X86
    247 endif
    248 ifeq ($(BUILD_TYPE),debug)
    249 KFLAGS   += -DDEBUG
     124 MOD_CFLAGS = -include $(MANGLING)
    250125endif
    251126
    252 ifeq ($(KERN_VERSION), 24)
    253 #
    254 # 2.4
    255 #
     127MOD_CLEAN = . linux r0drv generic r0drv/linux r0drv/generic VBox \
     128                common/alloc common/err common/log common/math/gcc common/misc \
     129                common/string common/time
    256130
    257 ifeq ($(BUILD_TARGET_ARCH),amd64)
    258  KFLAGS  += -mcmodel=kernel
    259 endif
     131include $(obj)/Makefile.include.footer
    260132
    261 CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
    262 MODULE_EXT := o
    263 
    264 # 2.4 Module linking
    265 $(MODULE).o: $(OBJS)
    266         $(LD) -o $@ -r $(OBJS)
    267 
    268 .PHONY: $(MODULE)
    269 all: $(MODULE)
    270 $(MODULE): $(MODULE).o
    271 
    272 else
    273 #
    274 # 2.6 and later
    275 #
    276 
    277 MODULE_EXT := ko
    278 
    279 $(MODULE)-y  := $(OBJS)
    280 
    281 # build defs
    282 EXTRA_CFLAGS += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG)
    283 
    284 all: $(MODULE)
    285 
    286 obj-m += $(MODULE).o
    287 
    288 $(MODULE):
    289         $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
    290 
    291 endif
    292 
    293 install: $(MODULE)
    294         @mkdir -p $(MODULE_DIR); \
    295         install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
    296         PATH="$(PATH):/bin:/sbin" depmod -a;
    297 
    298 endif # eq($(MAKECMDGOALS),clean)
    299 
    300 check: $(MODULE)
     133check: $(MOD_NAME)
    301134        @if ! readelf -p __ksymtab_strings vboxguest.ko | grep -E "\[.*\]  *(RT|g_..*RT.*)"; then \
    302135            echo "All exported IPRT symbols are properly renamed!"; \
     
    305138            false; \
    306139         fi
    307 
    308 clean:
    309         for f in . linux r0drv generic r0drv/linux r0drv/generic VBox \
    310             common/alloc common/err common/log common/math/gcc common/misc common/string common/time; \
    311             do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
    312         rm -rf .vboxguest* .tmp_ver* vboxguest.* Module.symvers Modules.symvers modules.order
  • trunk/src/VBox/Additions/common/VBoxGuest/linux/files_vboxguest

    r36408 r36510  
    8282    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestLog.h=>VBoxGuestLog.h \
    8383    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VMMDev.cpp=>VMMDev.c \
     84    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.header \
     85    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.footer \
    8486    ${PATH_ROOT}/src/VBox/Runtime/include/internal/assert.h=>include/internal/assert.h \
    8587    ${PATH_ROOT}/src/VBox/Runtime/include/internal/initterm.h=>include/internal/initterm.h \
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