# $Id: Makefile-footer.gmk 78133 2019-04-16 00:30:26Z vboxsync $ ## @file # VirtualBox Guest Additions kernel module Makefile, common parts. # # See Makefile-header.gmk for details of how to use this. # # # Copyright (C) 2006-2019 Oracle Corporation # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # General Public License (GPL) as published by the Free Software # Foundation, in version 2 as it comes in the "COPYING" file of the # VirtualBox OSE distribution. VirtualBox OSE is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # VBOXMOD_0_TARGET = $(VBOXMOD_NAME) KBUILD_VERBOSE ?= 1 # Variable belongs to our kBuild, not the linux one. VBOX_LNX_VERBOSE = $(if $(KBUILD_VERBOSE),1,) # # Compiler options # VBOXMOD_0_KFLAGS := -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE $(addprefix -D,$(VBOXMOD_DEFS)) ifeq ($(BUILD_TARGET_ARCH),amd64) VBOXMOD_0_KFLAGS += -DRT_ARCH_AMD64 else VBOXMOD_0_KFLAGS += -DRT_ARCH_X86 endif ifeq ($(BUILD_TYPE),debug) # The -Wno-array-bounds is because of a bug in gcc 4.something, see # https://sourceware.org/bugzilla/show_bug.cgi?id=10001 VBOXMOD_0_KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME)) ifeq ($(shell expr $(KERN_VER) : '[23]\.'),0) VBOXMOD_0_KFLAGS += -Werror -Wall -Wno-array-bounds endif endif ifeq ($(VBOX_KERN_GROKS_EXTMOD),) # # Pre 2.6.6 # # Note: While pre 2.6.6 kernels could also do "proper" builds from kbuild, the # make script needed to support it was somewhat different from 2.6. Since this # script works and pre-2.6.6 is not a moving target we will not try do do things # the "proper" way. # VBOXMOD_EXT := o ifeq ($(BUILD_TARGET_ARCH),amd64) VBOXMOD_0_KFLAGS += -mcmodel=kernel endif ifeq ($(KERN_VERSION),24) VBOXMOD_0_KFLAGS += -DVBOX_LINUX_2_4 endif CFLAGS := -O2 $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG) # 2.4 Module linking $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT): $(VBOXMOD_OBJS) $(LD) -o $@ -r $(VBOXMOD_OBJS) all: $(VBOXMOD_0_TARGET) $(VBOXMOD_0_TARGET): $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT) install: $(VBOXMOD_0_TARGET) @mkdir -p $(MODULE_DIR); \ install -m 0644 -o root -g root $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT) $(MODULE_DIR); \ PATH="$(PATH):/bin:/sbin" depmod -a; sync clean: for f in $(sort $(dir $(VBOXMOD_OBJS))); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done rm -rf .$(VBOXMOD_NAME)* .tmp_ver* $(VBOXMOD_NAME).* Modules.symvers modules.order .PHONY: all $(VBOXMOD_0_TARGET) install clean else # VBOX_KERN_GROKS_EXTMOD # # 2.6.6 and later # VBOXMOD_EXT := ko # build defs EXTRA_CFLAGS += $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG) $(VBOXMOD_0_TARGET)-y := $(VBOXMOD_OBJS) obj-m += $(VBOXMOD_0_TARGET).o # Trigger parallel make job. ifndef VBOX_NOJOBS JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null) ifeq ($(JOBS),0) override JOBS := 1 endif else JOBS := endif # rules: all: $(VBOXMOD_0_TARGET) # OL/UEK: disable module signing for external modules -- we don't have any private key $(VBOXMOD_0_TARGET): ifneq ($(VBOX_KERN_GROKS_SUBDIRS),) $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules else $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) M=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules endif install: $(VBOXMOD_0_TARGET) ifneq ($(VBOX_KERN_GROKS_SUBDIRS),) $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install else $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) M=$(CURDIR) SRCROOT=$(CURDIR) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install endif modules_install: install clean: ifneq ($(VBOX_KERN_GROKS_SUBDIRS),) $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) clean else $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) M=$(CURDIR) SRCROOT=$(CURDIR) clean endif .PHONY: all $(VBOXMOD_0_TARGET) install modules_install clean endif # VBOX_KERN_GROKS_EXTMOD