1 | # $Id: Makefile-footer.gmk 81760 2019-11-11 14:29:16Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # VirtualBox Guest Additions kernel module Makefile, common parts.
|
---|
4 | #
|
---|
5 | # See Makefile-header.gmk for details of how to use this.
|
---|
6 | #
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Copyright (C) 2006-2019 Oracle Corporation
|
---|
10 | #
|
---|
11 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | # available from http://www.virtualbox.org. This file is free software;
|
---|
13 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | # General Public License (GPL) as published by the Free Software
|
---|
15 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | #
|
---|
19 |
|
---|
20 | VBOXMOD_0_TARGET = $(VBOXMOD_NAME)
|
---|
21 |
|
---|
22 | KBUILD_VERBOSE ?= 1 # Variable belongs to our kBuild, not the linux one.
|
---|
23 | VBOX_LNX_VERBOSE = $(if $(KBUILD_VERBOSE),1,)
|
---|
24 |
|
---|
25 | #
|
---|
26 | # Compiler options
|
---|
27 | #
|
---|
28 | VBOXMOD_0_KFLAGS := -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE $(addprefix -D,$(VBOXMOD_DEFS))
|
---|
29 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
30 | VBOXMOD_0_KFLAGS += -DRT_ARCH_AMD64
|
---|
31 | else
|
---|
32 | VBOXMOD_0_KFLAGS += -DRT_ARCH_X86
|
---|
33 | endif
|
---|
34 |
|
---|
35 | ifeq ($(BUILD_TYPE),debug)
|
---|
36 | # The -Wno-array-bounds is because of a bug in gcc 4.something, see
|
---|
37 | # https://sourceware.org/bugzilla/show_bug.cgi?id=10001
|
---|
38 | VBOXMOD_0_KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
|
---|
39 | ifeq ($(shell expr $(KERN_VER) : '[23]\.'),0)
|
---|
40 | VBOXMOD_0_KFLAGS += -Werror -Wall -Wno-array-bounds
|
---|
41 | endif
|
---|
42 | endif
|
---|
43 |
|
---|
44 | ifeq ($(VBOX_KERN_GROKS_EXTMOD),)
|
---|
45 | #
|
---|
46 | # Pre 2.6.6
|
---|
47 | #
|
---|
48 | # Note: While pre 2.6.6 kernels could also do "proper" builds from kbuild, the
|
---|
49 | # make script needed to support it was somewhat different from 2.6. Since this
|
---|
50 | # script works and pre-2.6.6 is not a moving target we will not try do do things
|
---|
51 | # the "proper" way.
|
---|
52 | #
|
---|
53 | VBOXMOD_EXT := o
|
---|
54 |
|
---|
55 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
56 | VBOXMOD_0_KFLAGS += -mcmodel=kernel
|
---|
57 | endif
|
---|
58 | ifeq ($(KERN_VERSION),24)
|
---|
59 | VBOXMOD_0_KFLAGS += -DVBOX_LINUX_2_4
|
---|
60 | endif
|
---|
61 |
|
---|
62 | CFLAGS := -O2 $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
|
---|
63 |
|
---|
64 | # 2.4 Module linking
|
---|
65 | $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT): $(VBOXMOD_OBJS)
|
---|
66 | $(LD) -o $@ -r $(VBOXMOD_OBJS)
|
---|
67 |
|
---|
68 | all: $(VBOXMOD_0_TARGET)
|
---|
69 | $(VBOXMOD_0_TARGET): $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT)
|
---|
70 |
|
---|
71 | install: $(VBOXMOD_0_TARGET)
|
---|
72 | @mkdir -p $(MODULE_DIR); \
|
---|
73 | install -m 0644 -o root -g root $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT) $(MODULE_DIR); \
|
---|
74 | PATH="$(PATH):/bin:/sbin" depmod -a; sync
|
---|
75 |
|
---|
76 | clean:
|
---|
77 | for f in $(sort $(dir $(VBOXMOD_OBJS))); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
|
---|
78 | rm -rf .$(VBOXMOD_NAME)* .tmp_ver* $(VBOXMOD_NAME).* Modules.symvers modules.order
|
---|
79 |
|
---|
80 | .PHONY: all $(VBOXMOD_0_TARGET) install clean
|
---|
81 |
|
---|
82 | else # VBOX_KERN_GROKS_EXTMOD
|
---|
83 | #
|
---|
84 | # 2.6.6 and later
|
---|
85 | #
|
---|
86 | VBOXMOD_EXT := ko
|
---|
87 |
|
---|
88 | # build defs
|
---|
89 | EXTRA_CFLAGS += $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
|
---|
90 | $(VBOXMOD_0_TARGET)-y := $(VBOXMOD_OBJS)
|
---|
91 | obj-m += $(VBOXMOD_0_TARGET).o
|
---|
92 |
|
---|
93 | # Trigger parallel make job.
|
---|
94 | ifndef VBOX_NOJOBS
|
---|
95 | JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
|
---|
96 | ifeq ($(JOBS),0)
|
---|
97 | override JOBS := 1
|
---|
98 | endif
|
---|
99 | else
|
---|
100 | JOBS :=
|
---|
101 | endif
|
---|
102 |
|
---|
103 | # rules:
|
---|
104 | all: $(VBOXMOD_0_TARGET)
|
---|
105 |
|
---|
106 | # OL/UEK: CONFIG_MODULE_SIG= disables module signing for external modules.
|
---|
107 | # Ubuntu 18.04.3: CONFIG_MODULE_SIG_ALL= disables signing of all modules.
|
---|
108 | # We disable signing because we don't have any private key and want to leave
|
---|
109 | # the key handling and secure boot config to the user.
|
---|
110 | $(VBOXMOD_0_TARGET):
|
---|
111 | ifneq ($(VBOX_KERN_GROKS_SUBDIRS),)
|
---|
112 | $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules
|
---|
113 | else
|
---|
114 | $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C $(KERN_DIR) M=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules
|
---|
115 | endif
|
---|
116 |
|
---|
117 | install: $(VBOXMOD_0_TARGET)
|
---|
118 | ifneq ($(VBOX_KERN_GROKS_SUBDIRS),)
|
---|
119 | $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install
|
---|
120 | else
|
---|
121 | $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C $(KERN_DIR) M=$(CURDIR) SRCROOT=$(CURDIR) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install
|
---|
122 | endif
|
---|
123 |
|
---|
124 | modules_install: install
|
---|
125 |
|
---|
126 | clean:
|
---|
127 | ifneq ($(VBOX_KERN_GROKS_SUBDIRS),)
|
---|
128 | $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) clean
|
---|
129 | else
|
---|
130 | $(MAKE) V=$(VBOX_LNX_VERBOSE) CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C $(KERN_DIR) M=$(CURDIR) SRCROOT=$(CURDIR) clean
|
---|
131 | endif
|
---|
132 |
|
---|
133 | .PHONY: all $(VBOXMOD_0_TARGET) install modules_install clean
|
---|
134 | endif # VBOX_KERN_GROKS_EXTMOD
|
---|
135 |
|
---|