VirtualBox

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

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

*: The rest of the %V* format specifiers are history.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
Line 
1# $Revision: 26180 $
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 r0drv/generic/semspinmutex-r0drv-generic.o \
97 common/err/RTErrConvertFromErrno.o \
98 common/err/RTErrConvertToErrno.o \
99 common/log/log.o \
100 common/log/logellipsis.o \
101 common/log/logrel.o \
102 common/log/logrelellipsis.o \
103 common/log/logcom.o \
104 common/log/logformat.o \
105 common/misc/RTAssertMsg1Weak.o \
106 common/misc/RTAssertMsg2.o \
107 common/misc/RTAssertMsg2Add.o \
108 common/misc/RTAssertMsg2AddWeak.o \
109 common/misc/RTAssertMsg2AddWeakV.o \
110 common/misc/RTAssertMsg2Weak.o \
111 common/misc/RTAssertMsg2WeakV.o \
112 common/misc/assert.o \
113 common/string/strformat.o \
114 common/string/strformatrt.o \
115 common/string/strformattype.o \
116 common/string/strprintf.o \
117 common/string/strtonum.o \
118 generic/RTAssertShouldPanic-generic.o \
119 generic/RTLogWriteStdErr-stub-generic.o \
120 generic/RTLogWriteStdOut-stub-generic.o \
121 VBox/log-vbox.o \
122 VBox/logbackdoor.o
123ifeq ($(BUILD_TARGET_ARCH),x86)
124OBJS += \
125 common/math/gcc/divdi3.o \
126 common/math/gcc/moddi3.o \
127 common/math/gcc/udivdi3.o \
128 common/math/gcc/umoddi3.o \
129 common/math/gcc/qdivrem.o
130endif
131ifeq ($(BUILD_TARGET_ARCH),amd64)
132OBJS += common/alloc/heapsimple.o
133endif
134
135ifneq ($(MAKECMDGOALS),clean)
136
137ifeq ($(KERNELRELEASE),)
138
139 #
140 # building from this directory
141 #
142
143 # kernel base directory
144 ifndef KERN_DIR
145 KERN_DIR := /lib/modules/$(shell uname -r)/build
146 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
147 KERN_DIR := /usr/src/linux
148 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
149 $(error Error: unable to find the sources of your current Linux kernel. \
150 Specify KERN_DIR=<directory> and run Make again)
151 endif
152 $(warning Warning: using /usr/src/linux as the source directory of your \
153 Linux kernel. If this is not correct, specify \
154 KERN_DIR=<directory> and run Make again.)
155 endif
156 else
157 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
158 $(error Error: KERN_DIR does not point to a directory)
159 endif
160 endif
161
162 # includes
163 ifndef KERN_INCL
164 KERN_INCL = $(KERN_DIR)/include
165 endif
166 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
167 $(error Error: unable to find the include directory for your current Linux \
168 kernel. Specify KERN_INCL=<directory> and run Make again)
169 endif
170
171 # module install dir, only for current kernel
172 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
173 ifndef MODULE_DIR
174 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
175 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
176 MODULE_DIR := $(MODULE_DIR_TST)/misc
177 else
178 $(error Unable to find the folder to install the additions driver to)
179 endif
180 endif # MODULE_DIR unspecified
181 endif
182
183 # guess kernel version (24 or 26)
184 ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
185 KERN_VERSION := 24
186 else
187 KERN_VERSION := 26
188 endif
189
190else # neq($(KERNELRELEASE),)
191
192 #
193 # building from kbuild (make -C <kernel_directory> M=`pwd`)
194 #
195
196 # guess kernel version (24 or 26)
197 ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
198 KERN_VERSION := 24
199 else
200 KERN_VERSION := 26
201 endif
202
203endif # neq($(KERNELRELEASE),)
204
205# debug - show guesses.
206ifdef DEBUG
207$(warning dbg: KERN_DIR = $(KERN_DIR))
208$(warning dbg: KERN_INCL = $(KERN_INCL))
209$(warning dbg: MODULE_DIR = $(MODULE_DIR))
210$(warning dbg: KERN_VERSION = $(KERN_VERSION))
211endif
212
213KBUILD_VERBOSE ?= 1
214
215#
216# Compiler options
217#
218ifndef INCL
219 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
220 ifndef KBUILD_EXTMOD
221 KBUILD_EXTMOD := $(shell pwd)
222 endif
223 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
224 export INCL
225endif
226KFLAGS := -D__KERNEL__ -DMODULE \
227 -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 \
228 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM
229ifeq ($(BUILD_TARGET_ARCH),amd64)
230 KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
231else
232 KFLAGS += -DRT_ARCH_X86
233endif
234ifeq ($(BUILD_TYPE),debug)
235KFLAGS += -DDEBUG
236endif
237
238ifeq ($(KERN_VERSION), 24)
239#
240# 2.4
241#
242
243ifeq ($(BUILD_TARGET_ARCH),amd64)
244 KFLAGS += -mcmodel=kernel
245endif
246
247CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
248MODULE_EXT := o
249
250# 2.4 Module linking
251$(MODULE).o: $(OBJS)
252 $(LD) -o $@ -r $(OBJS)
253
254.PHONY: $(MODULE)
255all: $(MODULE)
256$(MODULE): $(MODULE).o
257
258else
259#
260# 2.6 and later
261#
262
263MODULE_EXT := ko
264
265$(MODULE)-y := $(OBJS)
266
267# build defs
268EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
269
270all: $(MODULE)
271
272obj-m += $(MODULE).o
273
274$(MODULE):
275 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
276
277endif
278
279install: $(MODULE)
280 @mkdir -p $(MODULE_DIR); \
281 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
282 PATH="$(PATH):/bin:/sbin" depmod -a;
283
284endif # eq($(MAKECMDGOALS),clean)
285
286clean:
287 for f in . linux r0drv r0drv/linux r0drv/generic VBox common/err common/string common/log generic common/math/gcc; \
288 do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
289 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