VirtualBox

Ignore:
Timestamp:
Sep 6, 2017 2:54:29 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117913
Message:

Drivers/Linux: make host kernel modules use make file templates.
bugref:4567: Linux kernel driver maintenance

Rework the make files from the host kernel drivers to use the
Makefile.include.header and Makefile.include.footer templates, and clean up
some obsolete scripting in the make files.

Location:
trunk/src/VBox/HostDrivers/VBoxNetAdp/linux
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/Makefile

    r67293 r68682  
    11#
    22# Makefile for the VirtualBox Linux Host Virtual Network Adapter Driver.
    3 # (For 2.6.x this file must be called 'Makefile'!)
    43#
    54
    65#
    76#
    8 # Copyright (C) 2006-2015 Oracle Corporation
     7# Copyright (C) 2006-2017 Oracle Corporation
    98#
    109# This file is part of VirtualBox Open Source Edition (OSE), as
     
    1716#
    1817
    19 ## @todo If you make non-trivial changes to this make file, please consider
    20 #        rewriting it to use Makefile.include.header and
    21 #        Makefile.include.footer.
    22 
    23 #
    24 # First, figure out which architecture we're targeting and the build type.
    25 # (We have to support basic cross building (ARCH=i386|x86_64).)
    26 # While at it, warn about BUILD_* vars found to help with user problems.
    27 #
    28 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
    29  BUILD_TARGET_ARCH_DEF := amd64
    30 else
    31  BUILD_TARGET_ARCH_DEF := x86
    32 endif
    33 ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
    34  $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
    35  BUILD_TARGET_ARCH :=
    36 endif
    37 ifeq ($(BUILD_TARGET_ARCH),)
    38  ifeq ($(ARCH),x86_64)
    39   BUILD_TARGET_ARCH := amd64
    40  else
    41   ifeq ($(ARCH),i386)
    42    BUILD_TARGET_ARCH := x86
    43   else
    44    BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
    45   endif
    46  endif
    47 else
    48  ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
    49   $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
    50  endif
    51 endif
    52 
    53 ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
    54  $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
    55  BUILD_TYPE :=
    56 endif
    57 ifeq ($(BUILD_TYPE),)
    58  BUILD_TYPE := release
    59 else
    60  ifneq ($(BUILD_TYPE),release)
    61   $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
    62  endif
    63 endif
     18# Linux kbuild sets this to our source directory if we are called from there
     19obj ?= $(CURDIR)
     20include $(obj)/Makefile.include.header
    6421
    6522# override is required by the Debian guys
    66 override MODULE = vboxnetadp
    67 OBJS  = \
     23MOD_NAME = vboxnetadp
     24MOD_OBJS = \
    6825        linux/VBoxNetAdp-linux.o \
    6926        VBoxNetAdp.o
    7027ifeq ($(BUILD_TARGET_ARCH),x86)
    71 OBJS += math/gcc/divdi3.o \
     28MOD_OBJS += math/gcc/divdi3.o \
    7229        math/gcc/moddi3.o \
    7330        math/gcc/qdivrem.o \
     
    7835endif
    7936
    80 ifneq ($(MAKECMDGOALS),clean)
    81 
    82 ifeq ($(KERNELRELEASE),)
    83 
    84  #
    85  # building from this directory
    86  #
    87 
    88  # kernel base directory
    89  ifndef KERN_DIR
    90   # build for the current kernel, version check
    91   KERN_DIR := /lib/modules/$(shell uname -r)/build
    92   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    93    KERN_DIR := /usr/src/linux
    94    ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    95     $(error Error: unable to find the sources of your current Linux kernel. \
    96                    Specify KERN_DIR=<directory> and run Make again)
    97    endif
    98    $(warning Warning: using /usr/src/linux as the source directory of your \
    99                       Linux kernel. If this is not correct, specify \
    100                       KERN_DIR=<directory> and run Make again.)
    101   endif
    102  else
    103   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    104    $(error Error: KERN_DIR does not point to a directory)
    105   endif
    106  endif
    107 
    108  # includes
    109  ifndef KERN_INCL
    110   KERN_INCL = $(KERN_DIR)/include
    111  endif
    112  ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
    113   $(error Error: unable to find the include directory for your current Linux \
    114                  kernel. Specify KERN_INCL=<directory> and run Make again)
    115  endif
    116 
    117  # module install dir, only for current kernel
    118  ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
    119   ifndef MODULE_DIR
    120    MODULE_DIR_TST := /lib/modules/$(shell uname -r)
    121    ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
    122     MODULE_DIR := $(MODULE_DIR_TST)/misc
    123    else
    124     $(error Unable to find the folder to install the support driver to)
    125    endif
    126   endif # MODULE_DIR unspecified
    127  endif
    128 
    129 else # neq($(KERNELRELEASE),)
    130 
    131  #
    132  # building from kbuild (make -C <kernel_directory> M=`pwd`)
    133  #
    134 
    135 endif # neq($(KERNELRELEASE),)
    136 
    137 # debug - show guesses.
    138 ifdef DEBUG
    139 $(warning dbg: KERN_DIR     = $(KERN_DIR))
    140 $(warning dbg: KERN_INCL    = $(KERN_INCL))
    141 $(warning dbg: MODULE_DIR   = $(MODULE_DIR))
    142 endif
    143 
    144 KBUILD_VERBOSE ?= 1
    145 
    146 #
    147 # Compiler options
    148 #
    149 ifndef INCL
    150  INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
    151  ifndef KBUILD_EXTMOD
    152   KBUILD_EXTMOD := $(shell pwd)
    153  endif
    154  INCL    += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
    155  INCL    += $(addprefix -I$(KBUILD_EXTMOD)/vboxnetadp,/ /include /r0drv/linux)
    156  export INCL
    157 endif
    158 ifneq ($(wildcard $(KBUILD_EXTMOD)/vboxnetadp),)
    159  MANGLING := $(KBUILD_EXTMOD)/vboxnetadp/include/VBox/SUPDrvMangling.h
     37MOD_INCL = $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
     38MOD_DEFS = -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX \
     39            -DRT_WITH_VBOX -DVBOX_WITH_HARDENING \
     40            -Wno-declaration-after-statement
     41ifeq ($(BUILD_TARGET_ARCH),amd64)
     42 MOD_DEFS += -DRT_ARCH_AMD64
    16043else
    161  MANGLING := $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h
    162 endif
    163 KFLAGS   := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
    164             -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING \
    165             -Wno-declaration-after-statement
    166 ifdef VBOX_REDHAT_KABI
    167  KFLAGS  += -DVBOX_REDHAT_KABI
    168 endif
    169 ifeq ($(BUILD_TARGET_ARCH),amd64)
    170  KFLAGS  += -DRT_ARCH_AMD64
    171 else
    172  KFLAGS  += -DRT_ARCH_X86
     44 MOD_DEFS += -DRT_ARCH_X86
    17345endif
    17446# must be consistent with Config.kmk!
    175 KFLAGS  += -DVBOX_WITH_64_BITS_GUESTS
    176 ifeq ($(BUILD_TYPE),debug)
    177  KFLAGS  += -DDEBUG -DDEBUG_$(USER) -g
    178  # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
    179  #KFLAGS  += -DIPRT_DEBUG_SEMS
    180 endif
     47MOD_DEFS += -DVBOX_WITH_64_BITS_GUESTS
    18148
    18249# By default we use remap_pfn_range() kernel API to make kernel pages
     
    19259endif
    19360
    194 MODULE_EXT    := ko
    195 $(MODULE)-y   := $(OBJS)
     61# build defs
     62MOD_CFLAGS = -include $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h -fno-pie
    19663
    197 # build defs
    198 EXTRA_CFLAGS  += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG) -fno-pie
    199 
    200 all: $(MODULE)
    201 
    202 obj-m += $(MODULE).o
    203 
    204 JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
    205 ifeq ($(JOBS),0)
    206   JOBS := 1
    207 endif
    208 
    209 # OL/UEK: disable module signing for external modules -- we don't have any private key
    210 $(MODULE):
    211         $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) CONFIG_MODULE_SIG= -C $(KERN_DIR) -j$(JOBS) modules
    212 
    213 install: $(MODULE)
    214         @mkdir -p $(MODULE_DIR); \
    215         install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
    216         PATH="$(PATH):/bin:/sbin" depmod -a; \
    217         rm -f /etc/vbox/module_not_compiled
    218 
    219 install_rpm: $(MODULE)
    220         @mkdir -p $(MODULE_DIR); \
    221         install -m 0644 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
    222 
    223 else # eq ($(MAKECMDGOALS),clean)
    224 
    225  ifndef KERN_DIR
    226   KERN_DIR := /lib/modules/$(shell uname -r)/build
    227   ifeq ($(wildcard $(KERN_DIR)/Makefile),)
    228    KERN_DIR := /usr/src/linux
    229   endif
    230  endif
    231  ifeq ($(wildcard $(KERN_DIR)/Makefile),)
    232 
    233 clean:
    234         find . \( -name \*.o -o -name \*.cmd \) -print0 | xargs -0 rm -f
    235         rm -rf .tmp_ver* $(MODULE).* Module.symvers Modules.symvers modules.order
    236 
    237  else
    238 
    239 clean:
    240         $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) clean
    241 
    242  endif
    243 
    244 endif # eq($(MAKECMDGOALS),clean)
     64include $(obj)/Makefile.include.footer
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/files_vboxnetadp

    r67295 r68682  
    6767    ${PATH_ROOT}/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c=>VBoxNetAdp.c \
    6868    ${PATH_ROOT}/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h=>VBoxNetAdpInternal.h \
     69    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.footer=>Makefile.include.footer \
     70    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.header=>Makefile.include.header \
    6971    ${PATH_ROOT}/src/VBox/Runtime/common/math/gcc/divdi3.c=>math/gcc/divdi3.c \
    7072    ${PATH_ROOT}/src/VBox/Runtime/common/math/gcc/moddi3.c=>math/gcc/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