1 | # $Id: Makefile-footer.gmk 77399 2019-02-20 18:23:31Z 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 | # override is required by the Debian guys
|
---|
21 | override MODULE = $(VBOXMOD_NAME)
|
---|
22 | OBJS = $(VBOXMOD_OBJS)
|
---|
23 |
|
---|
24 | KBUILD_VERBOSE ?= 1
|
---|
25 | LINUX_VERBOSE = $(if $(KBUILD_VERBOSE),1,)
|
---|
26 |
|
---|
27 | #
|
---|
28 | # Compiler options
|
---|
29 | #
|
---|
30 | VBOX_INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL)) $(VBOXMOD_INCL)
|
---|
31 |
|
---|
32 | KFLAGS := -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE $(addprefix -D,$(VBOXMOD_DEFS))
|
---|
33 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
34 | KFLAGS += -DRT_ARCH_AMD64
|
---|
35 | else
|
---|
36 | KFLAGS += -DRT_ARCH_X86
|
---|
37 | endif
|
---|
38 |
|
---|
39 | ifeq ($(BUILD_TYPE),debug)
|
---|
40 | # The -Wno-array-bounds is because of a bug in gcc 4.something, see
|
---|
41 | # https://sourceware.org/bugzilla/show_bug.cgi?id=10001
|
---|
42 | KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
|
---|
43 | ifeq ($(shell expr $(KERN_VER) : '[23]\.'),0)
|
---|
44 | KFLAGS += -Werror -Wall -Wno-array-bounds
|
---|
45 | endif
|
---|
46 | endif
|
---|
47 |
|
---|
48 | ifeq ($(KERN_VERSION),24)
|
---|
49 | #
|
---|
50 | # 2.4
|
---|
51 | #
|
---|
52 |
|
---|
53 | # Note: while 2.4 kernels could also do "proper" builds from kbuild, the make
|
---|
54 | # script needed to support it was somewhat different from 2.6. Since this
|
---|
55 | # script works and 2.4 is not a moving target we will not try do do things the
|
---|
56 | # "proper" way.
|
---|
57 |
|
---|
58 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
59 | KFLAGS += -mcmodel=kernel
|
---|
60 | endif
|
---|
61 |
|
---|
62 | CFLAGS := -O2 -DVBOX_LINUX_2_4 $(VBOXMOD_CFLAGS) $(VBOX_INCL) $(KFLAGS) $(KDEBUG)
|
---|
63 | MODULE_EXT := o
|
---|
64 |
|
---|
65 | # 2.4 Module linking
|
---|
66 | $(MODULE).$(MODULE_EXT): $(OBJS)
|
---|
67 | $(LD) -o $@ -r $(OBJS)
|
---|
68 |
|
---|
69 | .PHONY: $(MODULE)
|
---|
70 | all: $(MODULE)
|
---|
71 | $(MODULE): $(MODULE).$(MODULE_EXT)
|
---|
72 |
|
---|
73 | install: $(MODULE)
|
---|
74 | @mkdir -p $(MODULE_DIR); \
|
---|
75 | install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
|
---|
76 | PATH="$(PATH):/bin:/sbin" depmod -a; sync
|
---|
77 |
|
---|
78 | clean:
|
---|
79 | for f in $(sort $(dir $(OBJS))); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
|
---|
80 | rm -rf .$(VBOXMOD_NAME)* .tmp_ver* $(VBOXMOD_NAME).* Modules.symvers modules.order
|
---|
81 |
|
---|
82 | else # ! $(KERN_VERSION), 24
|
---|
83 | #
|
---|
84 | # 2.6 and later
|
---|
85 | ## @todo XXX does not work for 2.6.5 and earlier (see KBUILD_EXTMOD in header).
|
---|
86 | #
|
---|
87 |
|
---|
88 | MODULE_EXT := ko
|
---|
89 |
|
---|
90 | $(MODULE)-y := $(OBJS)
|
---|
91 |
|
---|
92 | # build defs
|
---|
93 | EXTRA_CFLAGS += $(VBOXMOD_CFLAGS) $(VBOX_INCL) $(KFLAGS) $(KDEBUG)
|
---|
94 |
|
---|
95 | .PHONY: $(MODULE)
|
---|
96 | all: $(MODULE)
|
---|
97 |
|
---|
98 | obj-m += $(MODULE).o
|
---|
99 |
|
---|
100 | JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
|
---|
101 | ifeq ($(JOBS),0)
|
---|
102 | override JOBS := 1
|
---|
103 | endif
|
---|
104 |
|
---|
105 | # OL/UEK: disable module signing for external modules -- we don't have any private key
|
---|
106 | $(MODULE):
|
---|
107 | $(MAKE) V=$(LINUX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules
|
---|
108 |
|
---|
109 | install: $(MODULE)
|
---|
110 | $(MAKE) V=$(LINUX_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
|
---|
111 |
|
---|
112 | modules_install: install
|
---|
113 |
|
---|
114 | clean:
|
---|
115 | $(MAKE) V=$(LINUX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) clean
|
---|
116 |
|
---|
117 | .PHONY: $(MODULE) install modules_install clean
|
---|
118 | endif
|
---|