1 | #
|
---|
2 | # VirtualBox Guest Additions kernel module Makefile, common parts.
|
---|
3 | #
|
---|
4 | # (For 2.6.x, the main file must be called 'Makefile'!)
|
---|
5 | #
|
---|
6 | # Copyright (C) 2006-2011 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 | #
|
---|
18 | # These file should be included by the Makefiles for any kernel modules we
|
---|
19 | # build as part of the Guest Additions. The intended way of doing this is as
|
---|
20 | # follows:
|
---|
21 | #
|
---|
22 | # include Makefile.include
|
---|
23 | # MOD_NAME = <name of the module to be built, without extension>
|
---|
24 | # MOD_OBJS = <list of object files which should be included>
|
---|
25 | # MOD_DEFS = <any additional defines which this module needs>
|
---|
26 | # MOD_INCL = <any additional include paths which this module needs>
|
---|
27 | # MOD_CFLAGS = <any additional CFLAGS which this module needs>
|
---|
28 | # MOD_CLEAN = <list of directories that the clean target should look at>
|
---|
29 | #
|
---|
30 | # The kmk kBuild define KBUILD_TARGET_ARCH is available.
|
---|
31 | #
|
---|
32 | # @todo the shared folders module Makefile also includes the following bits.
|
---|
33 | # Integrate them if necessary.
|
---|
34 | # MOD_CFLAGS += -DEXPORT_SYMTAB -DVBGL_VBOXGUEST -DRT_WITH_VBOX
|
---|
35 | #
|
---|
36 | # # special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
|
---|
37 | # # ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
|
---|
38 | # ifeq ($(KERNELRELEASE),)
|
---|
39 | # KFLAGS += $(foreach inc,$(KERN_INCL),\
|
---|
40 | # $(if $(wildcard $(inc)/linux/utsrelease.h),\
|
---|
41 | # $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
|
---|
42 | # grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
|
---|
43 | # grep '"2.6.18.*v5.*"' $(inc)/linux/utsrelease.h; \
|
---|
44 | # grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
|
---|
45 | # -DKERNEL_FC6,),))
|
---|
46 | # else
|
---|
47 | # KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
|
---|
48 | # echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
|
---|
49 | # echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
|
---|
50 | # echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
|
---|
51 | # -DKERNEL_FC6,)
|
---|
52 | # endif
|
---|
53 | #
|
---|
54 | ## important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
|
---|
55 | # rm -rf .vboxsf* .tmp_ver* vboxsf.* Modules.symvers modules.order
|
---|
56 | #
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 | # override is required by the Debian guys
|
---|
61 | override MODULE = $(MOD_NAME)
|
---|
62 | OBJS = $(MOD_OBJS)
|
---|
63 |
|
---|
64 | ifneq ($(MAKECMDGOALS),clean)
|
---|
65 |
|
---|
66 | KBUILD_VERBOSE ?= 1
|
---|
67 |
|
---|
68 | #
|
---|
69 | # Compiler options
|
---|
70 | #
|
---|
71 | ifndef INCL
|
---|
72 | INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
|
---|
73 | ifndef KBUILD_EXTMOD
|
---|
74 | KBUILD_EXTMOD := $(shell pwd)
|
---|
75 | endif
|
---|
76 | INCL += $(MOD_INCL)
|
---|
77 | export INCL
|
---|
78 | endif
|
---|
79 | KFLAGS := -D__KERNEL__ -DMODULE \
|
---|
80 | -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 $(MOD_DEFS)
|
---|
81 | ifeq ($(BUILD_TYPE),debug)
|
---|
82 | KFLAGS += -DDEBUG
|
---|
83 | endif
|
---|
84 |
|
---|
85 | ifeq ($(KERN_VERSION), 24)
|
---|
86 | #
|
---|
87 | # 2.4
|
---|
88 | #
|
---|
89 |
|
---|
90 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
91 | KFLAGS += -mcmodel=kernel
|
---|
92 | endif
|
---|
93 |
|
---|
94 | CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG) \
|
---|
95 | $(MOD_CFLAGS)
|
---|
96 | MODULE_EXT := o
|
---|
97 |
|
---|
98 | # 2.4 Module linking
|
---|
99 | $(MODULE).o: $(OBJS)
|
---|
100 | $(LD) -o $@ -r $(OBJS)
|
---|
101 |
|
---|
102 | .PHONY: $(MODULE)
|
---|
103 | all: $(MODULE)
|
---|
104 | $(MODULE): $(MODULE).o
|
---|
105 |
|
---|
106 | else
|
---|
107 | #
|
---|
108 | # 2.6 and later
|
---|
109 | #
|
---|
110 |
|
---|
111 | MODULE_EXT := ko
|
---|
112 |
|
---|
113 | $(MODULE)-y := $(OBJS)
|
---|
114 |
|
---|
115 | # build defs
|
---|
116 | EXTRA_CFLAGS += $(MOD_CFLAGS) $(INCL) $(KFLAGS) $(KDEBUG)
|
---|
117 |
|
---|
118 | all: $(MODULE)
|
---|
119 |
|
---|
120 | obj-m += $(MODULE).o
|
---|
121 |
|
---|
122 | $(MODULE):
|
---|
123 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
|
---|
124 |
|
---|
125 | endif
|
---|
126 |
|
---|
127 | install: $(MODULE)
|
---|
128 | @mkdir -p $(MODULE_DIR); \
|
---|
129 | install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
|
---|
130 | PATH="$(PATH):/bin:/sbin" depmod -a;
|
---|
131 |
|
---|
132 | endif # eq($(MAKECMDGOALS),clean)
|
---|
133 |
|
---|
134 | clean:
|
---|
135 | for f in $(MOD_CLEAN); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
|
---|
136 | rm -rf .$(MOD_NAME)* .tmp_ver* $(MOD_NAME).* Module.symvers Modules.symvers modules.order
|
---|