]>
Commit | Line | Data |
---|---|---|
056a1eb7 SF |
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 | ||
056a1eb7 SF |
21 | KBUILD_VERBOSE ?= 1 |
22 | ||
23 | # | |
24 | # Compiler options | |
25 | # | |
26 | ifndef INCL | |
27 | INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL)) | |
28 | ifndef KBUILD_EXTMOD | |
29 | KBUILD_EXTMOD := $(shell pwd) | |
30 | endif | |
31 | INCL += $(MOD_INCL) | |
32 | export INCL | |
33 | endif | |
34 | KFLAGS := -D__KERNEL__ -DMODULE $(MOD_DEFS) | |
35 | ifeq ($(BUILD_TYPE),debug) | |
36 | KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME)) | |
37 | endif | |
38 | ||
39 | ifeq ($(KERN_VERSION), 24) | |
40 | # | |
41 | # 2.4 | |
42 | # | |
43 | ||
6d209b23 SF |
44 | # Note: while 2.4 kernels could also do "proper" builds from kbuild, the make |
45 | # script needed to support it was somewhat different from 2.6. Since this | |
46 | # script works and 2.4 is not a moving target we will not try do do things the | |
47 | # "proper" way. | |
48 | ||
056a1eb7 SF |
49 | ifeq ($(BUILD_TARGET_ARCH),amd64) |
50 | KFLAGS += -mcmodel=kernel | |
51 | endif | |
52 | ||
53 | CFLAGS := -O2 -DVBOX_LINUX_2_4 $(MOD_CFLAGS) $(INCL) $(KFLAGS) $(MOD_EXTRA) $(KDEBUG) | |
54 | MODULE_EXT := o | |
55 | ||
56 | # 2.4 Module linking | |
57 | $(MODULE).o: $(OBJS) | |
58 | $(LD) -o $@ -r $(OBJS) | |
59 | ||
60 | .PHONY: $(MODULE) | |
61 | all: $(MODULE) | |
62 | $(MODULE): $(MODULE).o | |
63 | ||
6d209b23 SF |
64 | install: $(MODULE) |
65 | @mkdir -p $(MODULE_DIR); \ | |
66 | install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ | |
67 | PATH="$(PATH):/bin:/sbin" depmod -a; | |
68 | ||
69 | clean: | |
70 | for f in $(sort $(dir $(OBJS))); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done | |
71 | rm -rf .$(MOD_NAME)* .tmp_ver* $(MOD_NAME).* Modules.symvers modules.order | |
72 | ||
73 | else # ! $(KERN_VERSION), 24 | |
056a1eb7 SF |
74 | # |
75 | # 2.6 and later | |
76 | # | |
77 | ||
78 | MODULE_EXT := ko | |
79 | ||
80 | $(MODULE)-y := $(OBJS) | |
81 | ||
82 | # build defs | |
83 | EXTRA_CFLAGS += $(MOD_CFLAGS) $(INCL) $(KFLAGS) $(MOD_EXTRA) $(KDEBUG) | |
84 | ||
85 | .PHONY: $(MODULE) | |
86 | all: $(MODULE) | |
87 | ||
88 | obj-m += $(MODULE).o | |
89 | ||
90 | JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null) | |
91 | ifeq ($(JOBS),0) | |
92 | JOBS := 1 | |
93 | endif | |
94 | ||
95 | # OL/UEK: disable module signing for external modules -- we don't have any private key | |
96 | $(MODULE): | |
97 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -j$(JOBS) modules | |
98 | ||
056a1eb7 | 99 | install: $(MODULE) |
6d209b23 | 100 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_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 |
056a1eb7 | 101 | |
6d209b23 | 102 | modules_install: install |
056a1eb7 SF |
103 | |
104 | clean: | |
6d209b23 SF |
105 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) clean |
106 | ||
107 | .PHONY: $(MODULE) install modules_install clean | |
108 | endif |