VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/linux/Makefile@ 14436

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

deb/rpm: fixed vboxnetflt module compilation

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1#
2# Makefile for the VirtualBox Linux Host Driver.
3# (For 2.6.x this file must be called 'Makefile'!)
4#
5
6#
7#
8# Copyright (C) 2006-2007 Sun Microsystems, Inc.
9#
10# This file is part of VirtualBox Open Source Edition (OSE), as
11# available from http://www.virtualbox.org. This file is free software;
12# you can redistribute it and/or modify it under the terms of the GNU
13# General Public License (GPL) as published by the Free Software
14# Foundation, in version 2 as it comes in the "COPYING" file of the
15# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17#
18# The contents of this file may alternatively be used under the terms
19# of the Common Development and Distribution License Version 1.0
20# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21# VirtualBox OSE distribution, in which case the provisions of the
22# CDDL are applicable instead of those of the GPL.
23#
24# You may elect to license modified versions of this file under the
25# terms and conditions of either the GPL or the CDDL or both.
26#
27# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
28# Clara, CA 95054 USA or visit http://www.sun.com if you need
29# additional information or have any questions.
30#
31
32#
33# First, figure out which architecture we're targeting and the build type.
34# (We have to support basic cross building (ARCH=i386|x86_64).)
35# While at it, warn about BUILD_* vars found to help with user problems.
36#
37ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
38 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
39 BUILD_TARGET_ARCH :=
40endif
41ifeq ($(BUILD_TARGET_ARCH),)
42 ifeq ($(ARCH),x86_64)
43 BUILD_TARGET_ARCH := amd64
44 else
45 ifeq ($(ARCH),i386)
46 BUILD_TARGET_ARCH := x86
47 else
48 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
49 BUILD_TARGET_ARCH := amd64
50 else
51 BUILD_TARGET_ARCH := x86
52 endif
53 endif
54 endif
55else
56 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
57endif
58
59ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
60 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
61 BUILD_TYPE :=
62endif
63ifeq ($(BUILD_TYPE),)
64 BUILD_TYPE := release
65else
66 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
67endif
68
69# use vm_insert_page() API (if available) to map kernel pages to userland - better debugging
70# VBOX_USE_INSERT_PAGE = 1
71
72# override is required by the Debian guys
73override MODULE = vboxdrv
74OBJS = \
75 linux/SUPDrv-linux.o \
76 SUPDrv.o \
77 r0drv/alloc-r0drv.o \
78 r0drv/initterm-r0drv.o \
79 r0drv/memobj-r0drv.o \
80 r0drv/mpnotification-r0drv.o \
81 r0drv/powernotification-r0drv.o \
82 r0drv/linux/assert-r0drv-linux.o \
83 r0drv/linux/alloc-r0drv-linux.o \
84 r0drv/linux/initterm-r0drv-linux.o \
85 r0drv/linux/memobj-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/thread2-r0drv-linux.o \
95 r0drv/linux/time-r0drv-linux.o \
96 r0drv/linux/timer-r0drv-linux.o \
97 common/err/RTErrConvertFromErrno.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 r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
110 generic/RTAssertShouldPanic-generic.o \
111 generic/RTLogWriteStdErr-stub-generic.o \
112 generic/RTLogWriteStdOut-stub-generic.o \
113 generic/RTLogWriteUser-generic.o \
114 VBox/log-vbox.o \
115 VBox/strformat-vbox.o
116ifeq ($(BUILD_TARGET_ARCH),x86)
117OBJS += math/gcc/divdi3.o \
118 math/gcc/moddi3.o \
119 math/gcc/qdivrem.o \
120 math/gcc/udivdi3.o \
121 math/gcc/divdi3.o \
122 math/gcc/umoddi3.o
123endif
124ifeq ($(BUILD_TARGET_ARCH),amd64)
125OBJS += alloc/heapsimple.o
126endif
127
128ifneq ($(MAKECMDGOALS),clean)
129
130ifeq ($(KERNELRELEASE),)
131
132 #
133 # building from this directory
134 #
135
136 # kernel base directory
137 ifndef KERN_DIR
138 # build for the current kernel, version check
139 KERN_DIR := /lib/modules/$(shell uname -r)/build
140 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
141 KERN_DIR := /usr/src/linux
142 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
143 $(error Error: unable to find the sources of your current Linux kernel. \
144 Specify KERN_DIR=<directory> and run Make again)
145 endif
146 $(warning Warning: using /usr/src/linux as the source directory of your \
147 Linux kernel. If this is not correct, specify \
148 KERN_DIR=<directory> and run Make again.)
149 endif
150 # check if versions match -- works only for later 2.6 kernels
151 VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) kernelrelease 2> /dev/null || true)
152 ifneq ($(VBOX_KERN_VER),)
153 ifneq ($(VBOX_KERN_VER),$(shell uname -r))
154 $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
155 the current kernel (version $(shell uname -r)))
156 endif
157 endif
158 else
159 # build for a dedicated kernel, no version check
160 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
161 $(error Error: KERN_DIR does not point to a directory)
162 endif
163 endif
164
165 # includes
166 ifndef KERN_INCL
167 KERN_INCL = $(KERN_DIR)/include
168 endif
169 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
170 $(error Error: unable to find the include directory for your current Linux \
171 kernel. Specify KERN_INCL=<directory> and run Make again)
172 endif
173
174 # module install dir, only for current kernel
175 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
176 ifndef MODULE_DIR
177 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
178 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
179 MODULE_DIR := $(MODULE_DIR_TST)/misc
180 else
181 $(error Unable to find the folder to install the support driver to)
182 endif
183 endif # MODULE_DIR unspecified
184 endif
185
186 # guess kernel version (24 or 26)
187 KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
188
189else # neq($(KERNELRELEASE),)
190
191 #
192 # building from kbuild (make -C <kernel_directory> M=`pwd`)
193 #
194
195 # guess kernel version (24 or 26)
196 KERN_VERSION := $(if $(wildcard $(PWD)/Rules.make),24,26)
197
198endif # neq($(KERNELRELEASE),)
199
200# debug - show guesses.
201ifdef DEBUG
202$(warning dbg: KERN_DIR = $(KERN_DIR))
203$(warning dbg: KERN_INCL = $(KERN_INCL))
204$(warning dbg: MODULE_DIR = $(MODULE_DIR))
205$(warning dbg: KERN_VERSION = $(KERN_VERSION))
206endif
207
208KBUILD_VERBOSE ?= 1
209
210#
211# Compiler options
212#
213ifndef INCL
214 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
215 ifndef KBUILD_EXTMOD
216 KBUILD_EXTMOD := $(shell pwd)
217 endif
218 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
219 export INCL
220endif
221KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
222ifdef VBOX_REDHAT_KABI
223 KFLAGS += -DVBOX_REDHAT_KABI
224endif
225ifndef CONFIG_VBOXDRV_FIXEDMAJOR
226 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
227endif
228ifeq ($(BUILD_TARGET_ARCH),amd64)
229 KFLAGS += -DRT_ARCH_AMD64
230 # must be consistent with Config.kmk!
231 KFLAGS += -DVBOX_WITH_64_BITS_GUESTS
232else
233 KFLAGS += -DRT_ARCH_X86
234endif
235ifeq ($(BUILD_TYPE),debug)
236 KFLAGS += -DDEBUG -DDEBUG_$(USER) -g
237 # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
238 KFLAGS += -DIPRT_DEBUG_SEMS
239endif
240
241# By default we use remap_pfn_range() kernel API to make kernel pages
242# visible for userland. Unfortuately, it leads to situation that
243# during debug session all structures on that page (such as PVM pointer)
244# are not accessible to the debugger (see #3214).
245# This code enables experimental support
246# for vm_insert_page() kernel API, allowing to export kernel pages
247# to the userland in more debugger-friendly way. Due to stability
248# concerns, not enabled by default yet.
249ifdef VBOX_USE_INSERT_PAGE
250 KFLAGS += -DVBOX_USE_INSERT_PAGE
251endif
252
253ifeq ($(KERN_VERSION),24)
254# 2.4
255TOPDIR = $(KERN_DIR)
256MODULE_EXT := o
257EXTRA_CFLAGS := -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB
258$(MODULE)-objs = $(OBJS)
259else
260# 2.6 and later
261MODULE_EXT := ko
262$(MODULE)-y := $(OBJS)
263endif
264
265# build defs
266EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
267
268all: $(MODULE)
269
270obj-m += $(MODULE).o
271
272$(MODULE):
273 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
274
275ifeq ($(KERN_VERSION),24)
276#
277# 2.4 Module linking
278#
279$(MODULE).o: $(OBJS)
280 $(LD) -o $@ -r $(OBJS)
281
282include $(KERN_DIR)/Rules.make
283
284endif
285
286install: $(MODULE)
287 @mkdir -p $(MODULE_DIR); \
288 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
289 PATH="$(PATH):/bin:/sbin" depmod -ae; \
290 rm -f /etc/vbox/module_not_compiled
291
292install_rpm: $(MODULE)
293 @mkdir -p $(MODULE_DIR); \
294 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
295
296endif # eq($(MAKECMDGOALS),clean)
297
298clean:
299 for f in . linux r0drv r0drv/linux VBox common/err common/string common/log generic math/gcc; \
300 do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
301 rm -rf .vboxdrv* .tmp_ver* vboxdrv.* 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