1 | #
|
---|
2 | # VirtualBox Guest Additions kernel module Makefile, common parts.
|
---|
3 | #
|
---|
4 | # See Makefile.include.header for details of how to use this.
|
---|
5 | #
|
---|
6 | # Copyright (C) 2006-2015 Oracle Corporation
|
---|
7 | #
|
---|
8 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | # available from http://www.virtualbox.org. This file is free software;
|
---|
10 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | # General Public License (GPL) as published by the Free Software
|
---|
12 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | #
|
---|
16 |
|
---|
17 | # override is required by the Debian guys
|
---|
18 | override MODULE = $(MOD_NAME)
|
---|
19 | OBJS = $(MOD_OBJS)
|
---|
20 |
|
---|
21 | ifneq ($(MAKECMDGOALS),clean)
|
---|
22 |
|
---|
23 | KBUILD_VERBOSE ?= 1
|
---|
24 |
|
---|
25 | #
|
---|
26 | # Compiler options
|
---|
27 | #
|
---|
28 | ifndef INCL
|
---|
29 | INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
|
---|
30 | ifndef KBUILD_EXTMOD
|
---|
31 | KBUILD_EXTMOD := $(shell pwd)
|
---|
32 | endif
|
---|
33 | INCL += $(MOD_INCL)
|
---|
34 | export INCL
|
---|
35 | endif
|
---|
36 | KFLAGS := -D__KERNEL__ -DMODULE $(MOD_DEFS)
|
---|
37 | ifeq ($(BUILD_TYPE),debug)
|
---|
38 | KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
|
---|
39 | endif
|
---|
40 |
|
---|
41 | ifeq ($(KERN_VERSION), 24)
|
---|
42 | #
|
---|
43 | # 2.4
|
---|
44 | #
|
---|
45 |
|
---|
46 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
47 | KFLAGS += -mcmodel=kernel
|
---|
48 | endif
|
---|
49 |
|
---|
50 | CFLAGS := -O2 -DVBOX_LINUX_2_4 $(MOD_CFLAGS) $(INCL) $(KFLAGS) $(MOD_EXTRA) $(KDEBUG)
|
---|
51 | MODULE_EXT := o
|
---|
52 |
|
---|
53 | # 2.4 Module linking
|
---|
54 | $(MODULE).o: $(OBJS)
|
---|
55 | $(LD) -o $@ -r $(OBJS)
|
---|
56 |
|
---|
57 | .PHONY: $(MODULE)
|
---|
58 | all: $(MODULE)
|
---|
59 | $(MODULE): $(MODULE).o
|
---|
60 |
|
---|
61 | else
|
---|
62 | #
|
---|
63 | # 2.6 and later
|
---|
64 | #
|
---|
65 |
|
---|
66 | MODULE_EXT := ko
|
---|
67 |
|
---|
68 | $(MODULE)-y := $(OBJS)
|
---|
69 |
|
---|
70 | # build defs
|
---|
71 | EXTRA_CFLAGS += $(MOD_CFLAGS) $(INCL) $(KFLAGS) $(MOD_EXTRA) $(KDEBUG)
|
---|
72 |
|
---|
73 | .PHONY: $(MODULE)
|
---|
74 | all: $(MODULE)
|
---|
75 |
|
---|
76 | obj-m += $(MODULE).o
|
---|
77 |
|
---|
78 | JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
|
---|
79 | ifeq ($(JOBS),0)
|
---|
80 | JOBS := 1
|
---|
81 | endif
|
---|
82 |
|
---|
83 | # OL/UEK: disable module signing for external modules -- we don't have any private key
|
---|
84 | $(MODULE):
|
---|
85 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -j$(JOBS) modules
|
---|
86 |
|
---|
87 | modules_install:
|
---|
88 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules_install
|
---|
89 |
|
---|
90 | endif
|
---|
91 |
|
---|
92 | install: $(MODULE)
|
---|
93 | @mkdir -p $(MODULE_DIR); \
|
---|
94 | install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
|
---|
95 | PATH="$(PATH):/bin:/sbin" depmod -a;
|
---|
96 |
|
---|
97 | endif # eq($(MAKECMDGOALS),clean)
|
---|
98 |
|
---|
99 | clean:
|
---|
100 | for f in $(MOD_CLEAN); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
|
---|
101 | rm -rf .$(MOD_NAME)* .tmp_ver* $(MOD_NAME).* Modules.symvers modules.order
|
---|