VirtualBox

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

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

Linux modules: unbreak compilation against Linux 2.4

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.6 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/strprintf.o \
97 common/string/strtonum.o \
98 r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
99 generic/RTLogWriteStdErr-stub-generic.o \
100 generic/RTLogWriteStdOut-stub-generic.o \
101 generic/RTLogWriteUser-generic.o \
102 VBox/log-vbox.o \
103 VBox/strformat-vbox.o
104endif
105
106ifneq ($(MAKECMDGOALS),clean)
107
108ifeq ($(KERNELRELEASE),)
109
110 #
111 # building from this directory
112 #
113
114 # kernel base directory
115 ifndef KERN_DIR
116 # build for the current kernel, version check
117 KERN_DIR := /lib/modules/$(shell uname -r)/build
118 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
119 KERN_DIR := /usr/src/linux
120 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
121 $(error Error: unable to find the sources of your current Linux kernel. \
122 Specify KERN_DIR=<directory> and run Make again)
123 endif
124 $(warning Warning: using /usr/src/linux as the source directory of your \
125 Linux kernel. If this is not correct, specify \
126 KERN_DIR=<directory> and run Make again.)
127 endif
128 # check if versions match -- works only for later 2.6 kernels
129 VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) kernelrelease 2> /dev/null || true)
130 ifneq ($(VBOX_KERN_VER),)
131 ifneq ($(VBOX_KERN_VER),$(shell uname -r))
132 $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
133 the current kernel (version $(shell uname -r)))
134 endif
135 endif
136 else
137 # build for a dedicated kernel, no version check
138 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
139 $(error Error: KERN_DIR does not point to a directory)
140 endif
141 endif
142
143 # includes
144 ifndef KERN_INCL
145 KERN_INCL = $(KERN_DIR)/include
146 endif
147 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
148 $(error Error: unable to find the include directory for your current Linux \
149 kernel. Specify KERN_INCL=<directory> and run Make again)
150 endif
151
152 # module install dir, only for current kernel
153 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
154 ifndef MODULE_DIR
155 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
156 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
157 MODULE_DIR := $(MODULE_DIR_TST)/misc
158 else
159 $(error Unable to find the folder to install the support driver to)
160 endif
161 endif # MODULE_DIR unspecified
162 endif
163
164 # guess kernel version (24 or 26)
165 KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
166
167else # neq($(KERNELRELEASE),)
168
169 #
170 # building from kbuild (make -C <kernel_directory> M=`pwd`)
171 #
172
173 # guess kernel version (24 or 26)
174 KERN_VERSION := $(if $(wildcard $(PWD)/Rules.make),24,26)
175
176endif # neq($(KERNELRELEASE),)
177
178# debug - show guesses.
179ifdef DEBUG
180$(warning dbg: KERN_DIR = $(KERN_DIR))
181$(warning dbg: KERN_INCL = $(KERN_INCL))
182$(warning dbg: MODULE_DIR = $(MODULE_DIR))
183$(warning dbg: KERN_VERSION = $(KERN_VERSION))
184endif
185
186#
187# Compiler options
188#
189ifndef INCL
190 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
191 ifndef KBUILD_EXTMOD
192 KBUILD_EXTMOD := $(shell pwd)
193 endif
194 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
195 export INCL
196endif
197KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX
198ifndef CONFIG_VBOXDRV_FIXEDMAJOR
199 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
200endif
201ifeq ($(BUILD_TARGET_ARCH),amd64)
202 KFLAGS += -DRT_ARCH_AMD64
203else
204 KFLAGS += -DRT_ARCH_X86
205endif
206ifeq ($(BUILD_TYPE),debug)
207 KFLAGS += -DDEBUG -DDEBUG_$(USER)
208endif
209
210#
211# Use the RTR0MemObj API - testing.
212# If this makes testboxes crash/burn/leak disable it and add a comment to defect #2116.
213#
214KFLAGS += -DUSE_NEW_OS_INTERFACE_FOR_MM
215OBJS += r0drv/memobj-r0drv.o \
216 r0drv/linux/memobj-r0drv-linux.o
217ifeq ($(BUILD_TARGET_ARCH),x86) # Some gcc versions ends up needing __divdi3.
218OBJS += math/gcc/qdivrem.o \
219 math/gcc/divdi3.o
220endif
221
222ifeq ($(KERN_VERSION), 24)
223# 2.4
224TOPDIR = $(KERN_DIR)
225MODULE_EXT := o
226EXTRA_CFLAGS := -DVBOX_LINUX_2_4
227$(MODULE)-objs = $(OBJS)
228else
229# 2.6 and later
230MODULE_EXT := ko
231$(MODULE)-y := $(OBJS)
232endif
233
234# build defs
235EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
236
237all: $(MODULE)
238
239obj-m += $(MODULE).o
240
241$(MODULE):
242 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
243
244ifeq ($(KERN_VERSION), 24)
245#
246# 2.4 Module linking
247#
248$(MODULE).o: $(OBJS)
249 $(LD) -o $@ -r $(OBJS)
250
251include $(KERN_DIR)/Rules.make
252
253endif
254
255install: $(MODULE)
256 @mkdir -p $(MODULE_DIR); \
257 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
258 PATH="$(PATH):/bin:/sbin" depmod -ae; \
259 rm -f /etc/vbox/module_not_compiled
260
261install_rpm: $(MODULE)
262 @mkdir -p $(MODULE_DIR); \
263 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
264
265endif # eq($(MAKECMDGOALS),clean)
266
267clean:
268 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
269 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