VirtualBox

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

最後變更 在這個檔案從7206是 7183,由 vboxsync 提交於 17 年 前

Added RTStrFormatTypeRegister/SetUser/Deregister for runtime registration of custom format types. Example: RTStrFormat("%R[pgmpage]", pPage);

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.8 KB
 
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 innotek GmbH
9#
10# This file is part of VirtualBox Open Source Edition (OSE), as
11# available from http://www.alldomusa.eu.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#
33ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
34 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
35 BUILD_TARGET_ARCH :=
36endif
37ifeq ($(BUILD_TARGET_ARCH),)
38 ifeq ($(ARCH),x86_64)
39 BUILD_TARGET_ARCH := amd64
40 else
41 ifeq ($(ARCH),i386)
42 BUILD_TARGET_ARCH := x86
43 else
44 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
45 BUILD_TARGET_ARCH := amd64
46 else
47 BUILD_TARGET_ARCH := x86
48 endif
49 endif
50 endif
51else
52 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
53endif
54
55ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
56 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
57 BUILD_TYPE :=
58endif
59ifeq ($(BUILD_TYPE),)
60 BUILD_TYPE := release
61else
62 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
63endif
64
65
66# override is required by the Debian guys
67override MODULE = vboxdrv
68OBJS = \
69 linux/SUPDrv-linux.o \
70 SUPDRVShared.o \
71 r0drv/alloc-r0drv.o \
72 r0drv/initterm-r0drv.o \
73 r0drv/linux/alloc-r0drv-linux.o \
74 r0drv/linux/initterm-r0drv-linux.o \
75 r0drv/linux/process-r0drv-linux.o \
76 r0drv/linux/semevent-r0drv-linux.o \
77 r0drv/linux/semeventmulti-r0drv-linux.o \
78 r0drv/linux/semfastmutex-r0drv-linux.o \
79 r0drv/linux/spinlock-r0drv-linux.o \
80 r0drv/linux/thread-r0drv-linux.o
81ifeq ($(BUILD_TARGET_ARCH),amd64)
82OBJS += alloc/heapsimple.o
83endif
84ifeq ($(BUILD_TYPE),debug)
85OBJS += \
86 math/gcc/divdi3.o \
87 math/gcc/moddi3.o \
88 math/gcc/udivdi3.o \
89 math/gcc/umoddi3.o \
90 math/gcc/qdivrem.o \
91 common/log/log.o \
92 common/log/logcom.o \
93 common/log/logformat.o \
94 common/string/strformat.o \
95 common/string/strformatrt.o \
96 common/string/strformattype.o \
97 common/string/strprintf.o \
98 common/string/strtonum.o \
99 r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
100 generic/RTLogWriteStdErr-stub-generic.o \
101 generic/RTLogWriteStdOut-stub-generic.o \
102 generic/RTLogWriteUser-generic.o \
103 VBox/log-vbox.o \
104 VBox/strformat-vbox.o
105endif
106
107ifneq ($(MAKECMDGOALS),clean)
108
109ifeq ($(KERNELRELEASE),)
110
111 #
112 # building from this directory
113 #
114
115 # kernel base directory
116 ifndef KERN_DIR
117 # build for the current kernel, version check
118 KERN_DIR := /lib/modules/$(shell uname -r)/build
119 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
120 KERN_DIR := /usr/src/linux
121 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
122 $(error Error: unable to find the sources of your current Linux kernel. \
123 Specify KERN_DIR=<directory> and run Make again)
124 endif
125 $(warning Warning: using /usr/src/linux as the source directory of your \
126 Linux kernel. If this is not correct, specify \
127 KERN_DIR=<directory> and run Make again.)
128 endif
129 # check if versions match -- works only for later 2.6 kernels
130 VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) kernelrelease 2> /dev/null || true)
131 ifneq ($(VBOX_KERN_VER),)
132 ifneq ($(VBOX_KERN_VER),$(shell uname -r))
133 $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
134 the current kernel (version $(shell uname -r)))
135 endif
136 endif
137 else
138 # build for a dedicated kernel, no version check
139 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
140 $(error Error: KERN_DIR does not point to a directory)
141 endif
142 endif
143
144 # includes
145 ifndef KERN_INCL
146 KERN_INCL = $(KERN_DIR)/include
147 endif
148 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
149 $(error Error: unable to find the include directory for your current Linux \
150 kernel. Specify KERN_INCL=<directory> and run Make again)
151 endif
152
153 # module install dir, only for current kernel
154 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
155 ifndef MODULE_DIR
156 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
157 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
158 MODULE_DIR := $(MODULE_DIR_TST)/misc
159 else
160 $(error Unable to find the folder to install the support driver to)
161 endif
162 endif # MODULE_DIR unspecified
163 endif
164
165 # guess kernel version (24 or 26)
166 KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
167
168else # neq($(KERNELRELEASE),)
169
170 #
171 # building from kbuild (make -C <kernel_directory> M=`pwd`)
172 #
173
174 # guess kernel version (24 or 26)
175 KERN_VERSION := $(if $(wildcard $(PWD)/Rules.make),24,26)
176
177endif # neq($(KERNELRELEASE),)
178
179# debug - show guesses.
180ifdef DEBUG
181$(warning dbg: KERN_DIR = $(KERN_DIR))
182$(warning dbg: KERN_INCL = $(KERN_INCL))
183$(warning dbg: MODULE_DIR = $(MODULE_DIR))
184$(warning dbg: KERN_VERSION = $(KERN_VERSION))
185endif
186
187#
188# Compiler options
189#
190ifndef INCL
191 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
192 ifndef KBUILD_EXTMOD
193 KBUILD_EXTMOD := $(shell pwd)
194 endif
195 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
196 export INCL
197endif
198KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX
199ifdef VBOX_REDHAT_KABI
200 KFLAGS += -DVBOX_REDHAT_KABI
201endif
202ifndef CONFIG_VBOXDRV_FIXEDMAJOR
203 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
204endif
205ifeq ($(BUILD_TARGET_ARCH),amd64)
206 KFLAGS += -DRT_ARCH_AMD64
207else
208 KFLAGS += -DRT_ARCH_X86
209endif
210ifeq ($(BUILD_TYPE),debug)
211 KFLAGS += -DDEBUG -DDEBUG_$(USER)
212 # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
213 KFLAGS += -DIPRT_DEBUG_SEMS
214endif
215
216#
217# Use the RTR0MemObj API - testing.
218# If this makes testboxes crash/burn/leak disable it and add a comment to defect #2116.
219#
220KFLAGS += -DUSE_NEW_OS_INTERFACE_FOR_MM
221OBJS += r0drv/memobj-r0drv.o \
222 r0drv/linux/memobj-r0drv-linux.o
223ifeq ($(BUILD_TARGET_ARCH),x86) # Some gcc versions ends up needing __divdi3.
224OBJS += math/gcc/qdivrem.o \
225 math/gcc/divdi3.o
226endif
227
228ifeq ($(KERN_VERSION), 24)
229# 2.4
230TOPDIR = $(KERN_DIR)
231MODULE_EXT := o
232EXTRA_CFLAGS := -DVBOX_LINUX_2_4
233$(MODULE)-objs = $(OBJS)
234else
235# 2.6 and later
236MODULE_EXT := ko
237$(MODULE)-y := $(OBJS)
238endif
239
240# build defs
241EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
242
243all: $(MODULE)
244
245obj-m += $(MODULE).o
246
247$(MODULE):
248 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
249
250ifeq ($(KERN_VERSION), 24)
251#
252# 2.4 Module linking
253#
254$(MODULE).o: $(OBJS)
255 $(LD) -o $@ -r $(OBJS)
256
257include $(KERN_DIR)/Rules.make
258
259endif
260
261install: $(MODULE)
262 @mkdir -p $(MODULE_DIR); \
263 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
264 PATH="$(PATH):/bin:/sbin" depmod -ae; \
265 rm -f /etc/vbox/module_not_compiled
266
267install_rpm: $(MODULE)
268 @mkdir -p $(MODULE_DIR); \
269 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
270
271endif # eq($(MAKECMDGOALS),clean)
272
273clean:
274 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
275 rm -rf .vboxdrv* .tmp_ver* vboxdrv.* Module.symvers Modules.symvers
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette