VirtualBox

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

Last change on this file since 36671 was 36671, checked in by vboxsync, 14 years ago

Trunk: forward ported r70873: Installer/linux: no "make kernelrelease" anymore when compiling the Linux host kernel modules because that does not work with Linux 2.6.38 anymore

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1# $Revision: 36671 $
2## @file
3# Makefile for the VirtualBox Linux Host Driver.
4#
5
6#
7#
8# Copyright (C) 2006-2010 Oracle Corporation
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
28#
29# First, figure out which architecture we're targeting and the build type.
30# (We have to support basic cross building (ARCH=i386|x86_64).)
31# While at it, warn about BUILD_* vars found to help with user problems.
32#
33ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
34 BUILD_TARGET_ARCH_DEF := amd64
35else
36 BUILD_TARGET_ARCH_DEF := x86
37endif
38ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
39 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
40 BUILD_TARGET_ARCH :=
41endif
42ifeq ($(BUILD_TARGET_ARCH),)
43 ifeq ($(ARCH),x86_64)
44 BUILD_TARGET_ARCH := amd64
45 else
46 ifeq ($(ARCH),i386)
47 BUILD_TARGET_ARCH := x86
48 else
49 BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
50 endif
51 endif
52else
53 ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
54 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
55 endif
56endif
57
58ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
59 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
60 BUILD_TYPE :=
61endif
62ifeq ($(BUILD_TYPE),)
63 BUILD_TYPE := release
64else
65 ifneq ($(BUILD_TYPE),release)
66 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
67 endif
68endif
69
70# override is required by the Debian guys
71override MODULE = vboxdrv
72OBJS = \
73 linux/SUPDrv-linux.o \
74 SUPDrv.o \
75 SUPDrvSem.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/assert-r0drv-linux.o \
82 r0drv/linux/alloc-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/semmutex-r0drv-linux.o \
93 r0drv/linux/spinlock-r0drv-linux.o \
94 r0drv/linux/thread-r0drv-linux.o \
95 r0drv/linux/thread2-r0drv-linux.o \
96 r0drv/linux/time-r0drv-linux.o \
97 r0drv/linux/timer-r0drv-linux.o \
98 r0drv/generic/semspinmutex-r0drv-generic.o \
99 common/alloc/alloc.o \
100 common/checksum/crc32.o \
101 common/checksum/ipv4.o \
102 common/checksum/ipv6.o \
103 common/err/RTErrConvertFromErrno.o \
104 common/err/RTErrConvertToErrno.o \
105 common/log/log.o \
106 common/log/logellipsis.o \
107 common/log/logrel.o \
108 common/log/logrelellipsis.o \
109 common/log/logcom.o \
110 common/log/logformat.o \
111 common/misc/RTAssertMsg1Weak.o \
112 common/misc/RTAssertMsg2.o \
113 common/misc/RTAssertMsg2Add.o \
114 common/misc/RTAssertMsg2AddWeak.o \
115 common/misc/RTAssertMsg2AddWeakV.o \
116 common/misc/RTAssertMsg2Weak.o \
117 common/misc/RTAssertMsg2WeakV.o \
118 common/misc/assert.o \
119 common/misc/handletable.o \
120 common/misc/handletablectx.o \
121 common/misc/thread.o \
122 common/string/RTStrCopyP.o \
123 common/string/strformat.o \
124 common/string/strformatrt.o \
125 common/string/strformattype.o \
126 common/string/strprintf.o \
127 common/string/strtonum.o \
128 common/table/avlpv.o \
129 common/time/time.o \
130 r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
131 generic/RTAssertShouldPanic-generic.o \
132 generic/RTLogWriteStdErr-stub-generic.o \
133 generic/RTLogWriteStdOut-stub-generic.o \
134 generic/RTLogWriteUser-generic.o \
135 generic/RTMpGetArraySize-generic.o \
136 generic/RTSemEventWait-2-ex-generic.o \
137 generic/RTSemEventWaitNoResume-2-ex-generic.o \
138 generic/RTSemEventMultiWait-2-ex-generic.o \
139 generic/RTSemEventMultiWaitNoResume-2-ex-generic.o \
140 generic/RTTimerCreate-generic.o \
141 generic/mppresent-generic.o \
142 generic/uuid-generic.o \
143 VBox/log-vbox.o
144ifeq ($(BUILD_TARGET_ARCH),x86)
145OBJS += math/gcc/divdi3.o \
146 math/gcc/moddi3.o \
147 math/gcc/qdivrem.o \
148 math/gcc/udivdi3.o \
149 math/gcc/divdi3.o \
150 math/gcc/umoddi3.o
151endif
152ifeq ($(BUILD_TARGET_ARCH),amd64)
153OBJS += common/alloc/heapsimple.o
154endif
155
156ifneq ($(MAKECMDGOALS),clean)
157
158ifeq ($(KERNELRELEASE),)
159
160 #
161 # building from this directory
162 #
163
164 # kernel base directory
165 ifndef KERN_DIR
166 # build for the current kernel, version check
167 KERN_DIR := /lib/modules/$(shell uname -r)/build
168 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
169 KERN_DIR := /usr/src/linux
170 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
171 $(error Error: unable to find the sources of your current Linux kernel. \
172 Specify KERN_DIR=<directory> and run Make again)
173 endif
174 $(warning Warning: using /usr/src/linux as the source directory of your \
175 Linux kernel. If this is not correct, specify \
176 KERN_DIR=<directory> and run Make again.)
177 endif
178 else
179 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
180 $(error Error: KERN_DIR does not point to a directory)
181 endif
182 endif
183
184 # includes
185 ifndef KERN_INCL
186 KERN_INCL = $(KERN_DIR)/include
187 endif
188 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
189 $(error Error: unable to find the include directory for your current Linux \
190 kernel. Specify KERN_INCL=<directory> and run Make again)
191 endif
192
193 # module install dir, only for current kernel
194 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
195 ifndef MODULE_DIR
196 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
197 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
198 MODULE_DIR := $(MODULE_DIR_TST)/misc
199 else
200 $(error Unable to find the folder to install the support driver to)
201 endif
202 endif # MODULE_DIR unspecified
203 endif
204
205else # neq($(KERNELRELEASE),)
206
207 #
208 # building from kbuild (make -C <kernel_directory> M=`pwd`)
209 #
210
211endif # neq($(KERNELRELEASE),)
212
213# debug - show guesses.
214ifdef DEBUG
215$(warning dbg: KERN_DIR = $(KERN_DIR))
216$(warning dbg: KERN_INCL = $(KERN_INCL))
217$(warning dbg: MODULE_DIR = $(MODULE_DIR))
218endif
219
220KBUILD_VERBOSE ?= 1
221
222#
223# Compiler options
224#
225ifndef INCL
226 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
227 ifndef KBUILD_EXTMOD
228 KBUILD_EXTMOD := $(shell pwd)
229 endif
230 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
231 INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxdrv,/ /include /r0drv/linux)
232 export INCL
233endif
234ifneq ($(wildcard $(KBUILD_EXTMOD)/vboxdrv),)
235 MANGLING := $(KBUILD_EXTMOD)/vboxdrv/include/VBox/SUPDrvMangling.h
236else
237 MANGLING := $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h
238endif
239KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
240 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
241ifdef VBOX_REDHAT_KABI
242 KFLAGS += -DVBOX_REDHAT_KABI
243endif
244ifndef CONFIG_VBOXDRV_FIXEDMAJOR
245 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
246endif
247ifeq ($(BUILD_TARGET_ARCH),amd64)
248 KFLAGS += -DRT_ARCH_AMD64
249else
250 KFLAGS += -DRT_ARCH_X86
251endif
252# must be consistent with Config.kmk!
253KFLAGS += -DVBOX_WITH_64_BITS_GUESTS
254ifeq ($(BUILD_TYPE),debug)
255 KFLAGS += -DDEBUG -DDEBUG_$(USER) -g
256 # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
257 #KFLAGS += -DIPRT_DEBUG_SEMS
258endif
259
260# 2.6 and later
261MODULE_EXT := ko
262$(MODULE)-y := $(OBJS)
263
264# build defs
265EXTRA_CFLAGS += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG)
266
267all: $(MODULE)
268
269obj-m += $(MODULE).o
270
271$(MODULE):
272 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) modules
273
274install: $(MODULE)
275 @mkdir -p $(MODULE_DIR); \
276 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
277 PATH="$(PATH):/bin:/sbin" depmod -a; \
278 rm -f /etc/vbox/module_not_compiled
279
280install_rpm: $(MODULE)
281 @mkdir -p $(MODULE_DIR); \
282 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
283
284else # eq ($(MAKECMDGOALS),clean)
285
286 ifndef KERN_DIR
287 KERN_DIR := /lib/modules/$(shell uname -r)/build
288 ifeq ($(wildcard $(KERN_DIR)/Makefile),)
289 KERN_DIR := /usr/src/linux
290 endif
291 endif
292 ifeq ($(wildcard $(KERN_DIR)/Makefile),)
293
294clean:
295 find . \( -name \*.o -o -name \*.cmd \) -print0 | xargs -0 rm -f
296 rm -rf .tmp_ver* $(MODULE).* Module.symvers Modules.symvers modules.order
297
298 else
299
300clean:
301 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) clean
302
303 endif
304
305endif # eq($(MAKECMDGOALS),clean)
306
307check: $(MODULE)
308 @if ! readelf -p __ksymtab_strings vboxdrv.ko | grep -E "\[.*\] *(RT|g_..*RT.*)"; then \
309 echo "All exported IPRT symbols are properly renamed!"; \
310 else \
311 echo "error: Some exported IPRT symbols was not properly renamed! See above." >&2; \
312 false; \
313 fi
314
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