VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module@ 32183

Last change on this file since 32183 was 32183, checked in by vboxsync, 14 years ago

Linux Installer/Additions: attempt to properly register the host/guest kernel modules at DKMS and use the setup function of the service script to compile the modules instead of doing this separately in the installer scripts

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 KB
Line 
1#
2# VirtualBox Guest Additions Module Makefile.
3#
4# (For 2.6.x this file must be 'Makefile'!)
5#
6# Copyright (C) 2006-2010 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# First, figure out which architecture we're targeting and the build type.
19# (We have to support basic cross building (ARCH=i386|x86_64).)
20# While at it, warn about BUILD_* vars found to help with user problems.
21#
22ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
23 BUILD_TARGET_ARCH_DEF := amd64
24else
25 BUILD_TARGET_ARCH_DEF := x86
26endif
27ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
28 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
29 BUILD_TARGET_ARCH :=
30endif
31ifeq ($(BUILD_TARGET_ARCH),)
32 ifeq ($(ARCH),x86_64)
33 BUILD_TARGET_ARCH := amd64
34 else
35 ifeq ($(ARCH),i386)
36 BUILD_TARGET_ARCH := x86
37 else
38 BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
39 endif
40 endif
41else
42 ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
43 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
44 endif
45endif
46
47ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
48 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
49 BUILD_TYPE :=
50endif
51ifeq ($(BUILD_TYPE),)
52 BUILD_TYPE := release
53else
54 ifneq ($(BUILD_TYPE),release)
55 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
56 endif
57endif
58
59
60# override is required by the Debian guys
61override MODULE = vboxsf
62OBJS = \
63 vfsmod.o \
64 dirops.o \
65 regops.o \
66 utils.o \
67 GenericRequest.o \
68 SysHlp.o \
69 PhysHeap.o \
70 Init.o \
71 VMMDev.o \
72 HGCM.o \
73 VBoxGuestR0LibSharedFolders.o \
74 VbglR0CanUsePhysPageList.o
75ifeq ($(BUILD_TARGET_ARCH),x86)
76OBJS += \
77 divdi3.o \
78 moddi3.o \
79 udivdi3.o \
80 umoddi3.o \
81 qdivrem.o
82endif
83
84EXTRA_CFLAGS = -fshort-wchar
85
86ifneq ($(MAKECMDGOALS),clean)
87
88ifeq ($(KERNELRELEASE),)
89
90 #
91 # building from this directory
92 #
93
94 # kernel base directory
95 ifndef KERN_DIR
96 KERN_DIR := /lib/modules/$(shell uname -r)/build
97 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
98 KERN_DIR := /usr/src/linux
99 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
100 $(error Error: unable to find the sources of your current Linux kernel. \
101 Specify KERN_DIR=<directory> and run Make again)
102 endif
103 $(warning Warning: using /usr/src/linux as the source directory of your \
104 Linux kernel. If this is not correct, specify \
105 KERN_DIR=<directory> and run Make again.)
106 endif
107 else
108 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
109 $(error Error: KERN_DIR does not point to a directory)
110 endif
111 endif
112
113 # includes
114 ifndef KERN_INCL
115 KERN_INCL = $(KERN_DIR)/include
116 endif
117 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
118 $(error Error: unable to find the include directory for your current Linux \
119 kernel. Specify KERN_INCL=<directory> and run Make again)
120 endif
121
122 # module install dir.
123 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
124 ifndef MODULE_DIR
125 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
126 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
127 MODULE_DIR := $(MODULE_DIR_TST)/misc
128 else
129 $(error Unable to find the folder to install the shared folders driver to)
130 endif
131 endif # MODULE_DIR unspecified
132 endif
133
134 # guess kernel version (24 or 26)
135 ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
136 KERN_VERSION := 24
137 else
138 KERN_VERSION := 26
139 endif
140
141else # neq($(KERNELRELEASE),)
142
143 #
144 # building from kbuild (make -C <kernel_directory> M=`pwd`)
145 #
146
147 # guess kernel version (24 or 26)
148 ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
149 KERN_VERSION := 24
150 else
151 KERN_VERSION := 26
152 endif
153
154endif # neq($(KERNELRELEASE),)
155
156# debug - show guesses.
157ifdef DEBUG
158$(warning dbg: KERN_DIR = $(KERN_DIR))
159$(warning dbg: KERN_INCL = $(KERN_INCL))
160$(warning dbg: MODULE_DIR = $(MODULE_DIR))
161$(warning dbg: KERN_VERSION = $(KERN_VERSION))
162endif
163
164KBUILD_VERBOSE ?= 1
165
166#
167# Compiler options
168#
169ifndef INCL
170 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
171 ifndef KBUILD_EXTMOD
172 KBUILD_EXTMOD := $(shell pwd)
173 endif
174 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
175 INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxsf,/ /include /r0drv/linux)
176 export INCL
177endif
178KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
179 -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DIN_MODULE -DIN_GUEST_R0
180# our module does not export any symbol
181KFLAGS += -DRT_NO_EXPORT_SYMBOL
182ifeq ($(BUILD_TARGET_ARCH),amd64)
183 KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
184else
185 KFLAGS += -DRT_ARCH_X86
186endif
187ifeq ($(BUILD_TYPE),debug)
188 KFLAGS += -DDEBUG
189endif
190
191ifeq ($(KERN_VERSION), 24)
192#
193# 2.4
194#
195
196ifeq ($(BUILD_TARGET_ARCH),amd64)
197 KFLAGS += -mcmodel=kernel
198endif
199
200CFLAGS := -O2 -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
201MODULE_EXT := o
202
203# 2.4 Module linking
204$(MODULE).o: $(OBJS)
205 $(LD) -o $@ -r $(OBJS)
206
207.PHONY: $(MODULE)
208all: $(MODULE)
209$(MODULE): $(MODULE).o
210
211else
212#
213# 2.6 and later
214#
215
216MODULE_EXT := ko
217
218$(MODULE)-y := $(OBJS)
219
220# special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
221# ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
222ifeq ($(KERNELRELEASE),)
223 KFLAGS += $(foreach inc,$(KERN_INCL),\
224 $(if $(wildcard $(inc)/linux/utsrelease.h),\
225 $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
226 grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
227 grep '"2.6.18.*v5.*"' $(inc)/linux/utsrelease.h; \
228 grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
229 -DKERNEL_FC6,),))
230else
231 KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
232 echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
233 echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
234 echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
235 -DKERNEL_FC6,)
236endif
237
238# build defs
239EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
240
241all: $(MODULE)
242
243obj-m += $(MODULE).o
244
245$(MODULE):
246 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
247
248endif
249
250install: $(MODULE)
251 @mkdir -p $(MODULE_DIR); \
252 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
253 PATH="$(PATH):/bin:/sbin" depmod -a;
254
255endif # eq($(MAKECMDGOALS),clean)
256
257# important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
258clean:
259 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
260 rm -rf .vboxsf* .tmp_ver* vboxsf.* Modules.symvers modules.order
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette