VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/linux/Makefile@ 21506

Last change on this file since 21506 was 21506, checked in by vboxsync, 16 years ago

VBoxGuest,VMMDev: New HGCM cancellation request.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1# $Revision: 21506 $
2## @file
3# VirtualBox Guest Additions Module Makefile.
4#
5
6#
7# Copyright (C) 2006-2009 Sun Microsystems, Inc.
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18# Clara, CA 95054 USA or visit http://www.sun.com if you need
19# additional information or have any questions.
20#
21
22#
23# First, figure out which architecture we're targeting and the build type.
24# (We have to support basic cross building (ARCH=i386|x86_64).)
25# While at it, warn about BUILD_* vars found to help with user problems.
26#
27ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
28 BUILD_TARGET_ARCH_DEF := amd64
29else
30 BUILD_TARGET_ARCH_DEF := x86
31endif
32ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
33 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
34 BUILD_TARGET_ARCH :=
35endif
36ifeq ($(BUILD_TARGET_ARCH),)
37 ifeq ($(ARCH),x86_64)
38 BUILD_TARGET_ARCH := amd64
39 else
40 ifeq ($(ARCH),i386)
41 BUILD_TARGET_ARCH := x86
42 else
43 BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
44 endif
45 endif
46else
47 ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
48 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
49 endif
50endif
51
52ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
53 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
54 BUILD_TYPE :=
55endif
56ifeq ($(BUILD_TYPE),)
57 BUILD_TYPE := release
58else
59 ifneq ($(BUILD_TYPE),release)
60 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
61 endif
62endif
63
64
65# override is required by the Debian guys
66override MODULE = vboxguest
67OBJS = \
68 VBoxGuest-linux.o \
69 VBoxGuest.o \
70 GenericRequest.o \
71 HGCMInternal.o \
72 Init.o \
73 PhysHeap.o \
74 SysHlp.o \
75 VMMDev.o \
76 r0drv/alloc-r0drv.o \
77 r0drv/initterm-r0drv.o \
78 r0drv/memobj-r0drv.o \
79 r0drv/mpnotification-r0drv.o \
80 r0drv/powernotification-r0drv.o \
81 r0drv/linux/alloc-r0drv-linux.o \
82 r0drv/linux/assert-r0drv-linux.o \
83 r0drv/linux/initterm-r0drv-linux.o \
84 r0drv/linux/memobj-r0drv-linux.o \
85 r0drv/linux/memuserkernel-r0drv-linux.o \
86 r0drv/linux/mp-r0drv-linux.o \
87 r0drv/linux/mpnotification-r0drv-linux.o \
88 r0drv/linux/process-r0drv-linux.o \
89 r0drv/linux/semevent-r0drv-linux.o \
90 r0drv/linux/semeventmulti-r0drv-linux.o \
91 r0drv/linux/semfastmutex-r0drv-linux.o \
92 r0drv/linux/spinlock-r0drv-linux.o \
93 r0drv/linux/thread-r0drv-linux.o \
94 r0drv/linux/time-r0drv-linux.o \
95 r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
96 common/err/RTErrConvertFromErrno.o \
97 common/err/RTErrConvertToErrno.o \
98 common/log/log.o \
99 common/log/logellipsis.o \
100 common/log/logrel.o \
101 common/log/logrelellipsis.o \
102 common/log/logcom.o \
103 common/log/logformat.o \
104 common/string/strformat.o \
105 common/string/strformatrt.o \
106 common/string/strformattype.o \
107 common/string/strprintf.o \
108 common/string/strtonum.o \
109 generic/RTAssertShouldPanic-generic.o \
110 generic/RTLogWriteStdErr-stub-generic.o \
111 generic/RTLogWriteStdOut-stub-generic.o \
112 VBox/log-vbox.o \
113 VBox/logbackdoor.o \
114 VBox/strformat-vbox.o
115ifeq ($(BUILD_TARGET_ARCH),x86)
116OBJS += \
117 common/math/gcc/divdi3.o \
118 common/math/gcc/moddi3.o \
119 common/math/gcc/udivdi3.o \
120 common/math/gcc/umoddi3.o \
121 common/math/gcc/qdivrem.o
122endif
123ifeq ($(BUILD_TARGET_ARCH),amd64)
124OBJS += common/alloc/heapsimple.o
125endif
126
127ifneq ($(MAKECMDGOALS),clean)
128
129ifeq ($(KERNELRELEASE),)
130
131 #
132 # building from this directory
133 #
134
135 # kernel base directory
136 ifndef KERN_DIR
137 KERN_DIR := /lib/modules/$(shell uname -r)/build
138 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
139 KERN_DIR := /usr/src/linux
140 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
141 $(error Error: unable to find the sources of your current Linux kernel. \
142 Specify KERN_DIR=<directory> and run Make again)
143 endif
144 $(warning Warning: using /usr/src/linux as the source directory of your \
145 Linux kernel. If this is not correct, specify \
146 KERN_DIR=<directory> and run Make again.)
147 endif
148 else
149 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
150 $(error Error: KERN_DIR does not point to a directory)
151 endif
152 endif
153
154 # includes
155 ifndef KERN_INCL
156 KERN_INCL = $(KERN_DIR)/include
157 endif
158 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
159 $(error Error: unable to find the include directory for your current Linux \
160 kernel. Specify KERN_INCL=<directory> and run Make again)
161 endif
162
163 # module install dir, only for current kernel
164 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
165 ifndef MODULE_DIR
166 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
167 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
168 MODULE_DIR := $(MODULE_DIR_TST)/misc
169 else
170 $(error Unable to find the folder to install the additions driver to)
171 endif
172 endif # MODULE_DIR unspecified
173 endif
174
175 # guess kernel version (24 or 26)
176 ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
177 KERN_VERSION := 24
178 else
179 KERN_VERSION := 26
180 endif
181
182else # neq($(KERNELRELEASE),)
183
184 #
185 # building from kbuild (make -C <kernel_directory> M=`pwd`)
186 #
187
188 # guess kernel version (24 or 26)
189 ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
190 KERN_VERSION := 24
191 else
192 KERN_VERSION := 26
193 endif
194
195endif # neq($(KERNELRELEASE),)
196
197# debug - show guesses.
198ifdef DEBUG
199$(warning dbg: KERN_DIR = $(KERN_DIR))
200$(warning dbg: KERN_INCL = $(KERN_INCL))
201$(warning dbg: MODULE_DIR = $(MODULE_DIR))
202$(warning dbg: KERN_VERSION = $(KERN_VERSION))
203endif
204
205KBUILD_VERBOSE ?= 1
206
207#
208# Compiler options
209#
210ifndef INCL
211 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
212 ifndef KBUILD_EXTMOD
213 KBUILD_EXTMOD := $(shell pwd)
214 endif
215 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
216 export INCL
217endif
218KFLAGS := -D__KERNEL__ -DMODULE \
219 -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 \
220 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM
221ifeq ($(BUILD_TARGET_ARCH),amd64)
222 KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
223else
224 KFLAGS += -DRT_ARCH_X86
225endif
226ifeq ($(BUILD_TYPE),debug)
227KFLAGS += -DDEBUG
228endif
229
230ifeq ($(KERN_VERSION), 24)
231#
232# 2.4
233#
234
235CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
236MODULE_EXT := o
237
238# 2.4 Module linking
239$(MODULE).o: $(OBJS)
240 $(LD) -o $@ -r $(OBJS)
241
242.PHONY: $(MODULE)
243all: $(MODULE)
244$(MODULE): $(MODULE).o
245
246else
247#
248# 2.6 and later
249#
250
251MODULE_EXT := ko
252
253$(MODULE)-y := $(OBJS)
254
255# build defs
256EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
257
258all: $(MODULE)
259
260obj-m += $(MODULE).o
261
262$(MODULE):
263 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
264
265endif
266
267install: $(MODULE)
268 @mkdir -p $(MODULE_DIR); \
269 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
270 PATH="$(PATH):/bin:/sbin" depmod -ae;
271
272endif # eq($(MAKECMDGOALS),clean)
273
274clean:
275 for f in . linux r0drv r0drv/linux VBox common/err common/string common/log generic common/math/gcc; \
276 do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
277 rm -rf .vboxguest* .tmp_ver* vboxguest.* Module.symvers 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