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 -DIN_MODULE \
|
---|
81 | -DRT_WITH_VBOX $(MOD_DEFS)
|
---|
82 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
83 | KFLAGS += -DRT_ARCH_AMD64
|
---|
84 | else
|
---|
85 | KFLAGS += -DRT_ARCH_X86
|
---|
86 | endif
|
---|
87 | ifeq ($(BUILD_TYPE),debug)
|
---|
88 | KFLAGS += -DDEBUG
|
---|
89 | endif
|
---|
90 |
|
---|
91 | ifeq ($(KERN_VERSION), 24)
|
---|
92 | #
|
---|
93 | # 2.4
|
---|
94 | #
|
---|
95 |
|
---|
96 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
97 | KFLAGS += -mcmodel=kernel
|
---|
98 | endif
|
---|
99 |
|
---|
100 | CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG) \
|
---|
101 | $(MOD_CFLAGS)
|
---|
102 | MODULE_EXT := o
|
---|
103 |
|
---|
104 | # 2.4 Module linking
|
---|
105 | $(MODULE).o: $(OBJS)
|
---|
106 | $(LD) -o $@ -r $(OBJS)
|
---|
107 |
|
---|
108 | .PHONY: $(MODULE)
|
---|
109 | all: $(MODULE)
|
---|
110 | $(MODULE): $(MODULE).o
|
---|
111 |
|
---|
112 | else
|
---|
113 | #
|
---|
114 | # 2.6 and later
|
---|
115 | #
|
---|
116 |
|
---|
117 | MODULE_EXT := ko
|
---|
118 |
|
---|
119 | $(MODULE)-y := $(OBJS)
|
---|
120 |
|
---|
121 | # build defs
|
---|
122 | EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG) $(MOD_CFLAGS)
|
---|
123 |
|
---|
124 | all: $(MODULE)
|
---|
125 |
|
---|
126 | obj-m += $(MODULE).o
|
---|
127 |
|
---|
128 | $(MODULE):
|
---|
129 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
|
---|
130 |
|
---|
131 | endif
|
---|
132 |
|
---|
133 | install: $(MODULE)
|
---|
134 | @mkdir -p $(MODULE_DIR); \
|
---|
135 | install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
|
---|
136 | PATH="$(PATH):/bin:/sbin" depmod -a;
|
---|
137 |
|
---|
138 | endif # eq($(MAKECMDGOALS),clean)
|
---|
139 |
|
---|
140 | clean:
|
---|
141 | for f in $(MOD_CLEAN); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
|
---|
142 | rm -rf .$(MOD_NAME)* .tmp_ver* $(MOD_NAME).* Module.symvers Modules.symvers modules.order
|
---|