VirtualBox

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

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

Add,++: Switch to common addition kernel module.

  • 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
78ifeq ($(BUILD_TARGET_ARCH),x86)
79OBJS += \
80 divdi3.o \
81 moddi3.o \
82 udivdi3.o \
83 umoddi3.o \
84 qdivrem.o
85endif
86
87EXTRA_CFLAGS = -fshort-wchar
88
89ifneq ($(MAKECMDGOALS),clean)
90
91ifeq ($(KERNELRELEASE),)
92
93 #
94 # building from this directory
95 #
96
97 # kernel base directory
98 ifndef KERN_DIR
99 KERN_DIR := /lib/modules/$(shell uname -r)/build
100 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
101 KERN_DIR := /usr/src/linux
102 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
103 $(error Error: unable to find the sources of your current Linux kernel. \
104 Specify KERN_DIR=<directory> and run Make again)
105 endif
106 $(warning Warning: using /usr/src/linux as the source directory of your \
107 Linux kernel. If this is not correct, specify \
108 KERN_DIR=<directory> and run Make again.)
109 endif
110 else
111 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
112 $(error Error: KERN_DIR does not point to a directory)
113 endif
114 endif
115
116 # includes
117 ifndef KERN_INCL
118 KERN_INCL = $(KERN_DIR)/include
119 endif
120 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
121 $(error Error: unable to find the include directory for your current Linux \
122 kernel. Specify KERN_INCL=<directory> and run Make again)
123 endif
124
125 # module install dir.
126 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
127 ifndef MODULE_DIR
128 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
129 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
130 MODULE_DIR := $(MODULE_DIR_TST)/misc
131 else
132 $(error Unable to find the folder to install the shared folders driver to)
133 endif
134 endif # MODULE_DIR unspecified
135 endif
136
137 # guess kernel version (24 or 26)
138 ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
139 KERN_VERSION := 24
140 else
141 KERN_VERSION := 26
142 endif
143
144else # neq($(KERNELRELEASE),)
145
146 #
147 # building from kbuild (make -C <kernel_directory> M=`pwd`)
148 #
149
150 # guess kernel version (24 or 26)
151 ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
152 KERN_VERSION := 24
153 else
154 KERN_VERSION := 26
155 endif
156
157endif # neq($(KERNELRELEASE),)
158
159# debug - show guesses.
160ifdef DEBUG
161$(warning dbg: KERN_DIR = $(KERN_DIR))
162$(warning dbg: KERN_INCL = $(KERN_INCL))
163$(warning dbg: MODULE_DIR = $(MODULE_DIR))
164$(warning dbg: KERN_VERSION = $(KERN_VERSION))
165endif
166
167KBUILD_VERBOSE ?= 1
168
169#
170# Compiler options
171#
172ifndef INCL
173 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
174 ifndef KBUILD_EXTMOD
175 KBUILD_EXTMOD := $(shell pwd)
176 endif
177 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
178 export INCL
179endif
180KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
181 -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DLOG_TO_BACKDOOR -DIN_MODULE \
182 -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