VirtualBox

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

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

HostDrivers/*/linux/Makefile: Added --no-print-directory to the $(MAKE) kernelrelease invocation to prevent it from being messed up when doing "make -C out/linux.amd64/debug/bin/src". MAKEFLAGS+MFLAGS passes -m which seems to overrule the -s.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.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#
37ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
38 BUILD_TARGET_ARCH_DEF := amd64
39else
40 BUILD_TARGET_ARCH_DEF := x86
41endif
42ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
43 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
44 BUILD_TARGET_ARCH :=
45endif
46ifeq ($(BUILD_TARGET_ARCH),)
47 ifeq ($(ARCH),x86_64)
48 BUILD_TARGET_ARCH := amd64
49 else
50 ifeq ($(ARCH),i386)
51 BUILD_TARGET_ARCH := x86
52 else
53 BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
54 endif
55 endif
56else
57 ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
58 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
59 endif
60endif
61
62ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
63 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
64 BUILD_TYPE :=
65endif
66ifeq ($(BUILD_TYPE),)
67 BUILD_TYPE := release
68else
69 ifneq ($(BUILD_TYPE),release)
70 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
71 endif
72endif
73
74# override is required by the Debian guys
75override MODULE = vboxdrv
76OBJS = \
77 linux/SUPDrv-linux.o \
78 SUPDrv.o \
79 r0drv/alloc-r0drv.o \
80 r0drv/initterm-r0drv.o \
81 r0drv/memobj-r0drv.o \
82 r0drv/mpnotification-r0drv.o \
83 r0drv/powernotification-r0drv.o \
84 r0drv/linux/assert-r0drv-linux.o \
85 r0drv/linux/alloc-r0drv-linux.o \
86 r0drv/linux/initterm-r0drv-linux.o \
87 r0drv/linux/memobj-r0drv-linux.o \
88 r0drv/linux/mp-r0drv-linux.o \
89 r0drv/linux/mpnotification-r0drv-linux.o \
90 r0drv/linux/process-r0drv-linux.o \
91 r0drv/linux/semevent-r0drv-linux.o \
92 r0drv/linux/semeventmulti-r0drv-linux.o \
93 r0drv/linux/semfastmutex-r0drv-linux.o \
94 r0drv/linux/spinlock-r0drv-linux.o \
95 r0drv/linux/thread-r0drv-linux.o \
96 r0drv/linux/thread2-r0drv-linux.o \
97 r0drv/linux/time-r0drv-linux.o \
98 r0drv/linux/timer-r0drv-linux.o \
99 common/err/RTErrConvertFromErrno.o \
100 common/log/log.o \
101 common/log/logellipsis.o \
102 common/log/logrel.o \
103 common/log/logrelellipsis.o \
104 common/log/logcom.o \
105 common/log/logformat.o \
106 common/misc/handletable.o \
107 common/misc/handletablectx.o \
108 common/string/strformat.o \
109 common/string/strformatrt.o \
110 common/string/strformattype.o \
111 common/string/strprintf.o \
112 common/string/strtonum.o \
113 r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
114 generic/RTAssertShouldPanic-generic.o \
115 generic/RTLogWriteStdErr-stub-generic.o \
116 generic/RTLogWriteStdOut-stub-generic.o \
117 generic/RTLogWriteUser-generic.o \
118 VBox/log-vbox.o \
119 VBox/strformat-vbox.o
120ifeq ($(BUILD_TARGET_ARCH),x86)
121OBJS += math/gcc/divdi3.o \
122 math/gcc/moddi3.o \
123 math/gcc/qdivrem.o \
124 math/gcc/udivdi3.o \
125 math/gcc/divdi3.o \
126 math/gcc/umoddi3.o
127endif
128ifeq ($(BUILD_TARGET_ARCH),amd64)
129OBJS += alloc/heapsimple.o
130endif
131
132ifneq ($(MAKECMDGOALS),clean)
133
134ifeq ($(KERNELRELEASE),)
135
136 #
137 # building from this directory
138 #
139
140 # kernel base directory
141 ifndef KERN_DIR
142 # build for the current kernel, version check
143 KERN_DIR := /lib/modules/$(shell uname -r)/build
144 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
145 KERN_DIR := /usr/src/linux
146 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
147 $(error Error: unable to find the sources of your current Linux kernel. \
148 Specify KERN_DIR=<directory> and run Make again)
149 endif
150 $(warning Warning: using /usr/src/linux as the source directory of your \
151 Linux kernel. If this is not correct, specify \
152 KERN_DIR=<directory> and run Make again.)
153 endif
154 # check if versions match -- works only for later 2.6 kernels
155 VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
156 ifneq ($(VBOX_KERN_VER),)
157 ifneq ($(VBOX_KERN_VER),$(shell uname -r))
158 $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
159 the current kernel (version $(shell uname -r)))
160 endif
161 endif
162 else
163 # build for a dedicated kernel, no version check
164 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
165 $(error Error: KERN_DIR does not point to a directory)
166 endif
167 endif
168
169 # includes
170 ifndef KERN_INCL
171 KERN_INCL = $(KERN_DIR)/include
172 endif
173 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
174 $(error Error: unable to find the include directory for your current Linux \
175 kernel. Specify KERN_INCL=<directory> and run Make again)
176 endif
177
178 # module install dir, only for current kernel
179 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
180 ifndef MODULE_DIR
181 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
182 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
183 MODULE_DIR := $(MODULE_DIR_TST)/misc
184 else
185 $(error Unable to find the folder to install the support driver to)
186 endif
187 endif # MODULE_DIR unspecified
188 endif
189
190else # neq($(KERNELRELEASE),)
191
192 #
193 # building from kbuild (make -C <kernel_directory> M=`pwd`)
194 #
195
196endif # neq($(KERNELRELEASE),)
197
198# debug - show guesses.
199ifdef DEBUG
200$(warning dbg: KERN_DIR = $(KERN_DIR))
201$(warning dbg: KERN_INCL = $(KERN_INCL))
202$(warning dbg: MODULE_DIR = $(MODULE_DIR))
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 -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
219ifdef VBOX_REDHAT_KABI
220 KFLAGS += -DVBOX_REDHAT_KABI
221endif
222ifndef CONFIG_VBOXDRV_FIXEDMAJOR
223 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
224endif
225ifeq ($(BUILD_TARGET_ARCH),amd64)
226 KFLAGS += -DRT_ARCH_AMD64
227else
228 KFLAGS += -DRT_ARCH_X86
229endif
230# must be consistent with Config.kmk!
231KFLAGS += -DVBOX_WITH_64_BITS_GUESTS
232ifeq ($(BUILD_TYPE),debug)
233 KFLAGS += -DDEBUG -DDEBUG_$(USER) -g
234 # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
235 KFLAGS += -DIPRT_DEBUG_SEMS
236endif
237
238# 2.6 and later
239MODULE_EXT := ko
240$(MODULE)-y := $(OBJS)
241
242# build defs
243EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
244
245all: $(MODULE)
246
247obj-m += $(MODULE).o
248
249$(MODULE):
250 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
251
252install: $(MODULE)
253 @mkdir -p $(MODULE_DIR); \
254 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
255 PATH="$(PATH):/bin:/sbin" depmod -ae; \
256 rm -f /etc/vbox/module_not_compiled
257
258install_rpm: $(MODULE)
259 @mkdir -p $(MODULE_DIR); \
260 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
261
262endif # eq($(MAKECMDGOALS),clean)
263
264clean:
265 for f in . linux r0drv r0drv/linux VBox common/err common/string common/log generic math/gcc; \
266 do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
267 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