VirtualBox

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

Last change on this file since 21511 was 21511, checked in by vboxsync, 15 years ago

vboxvfs/linux: playing with using physical page lists for writing. Tiny speed up.

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