VirtualBox

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

Last change on this file since 8758 was 8155, checked in by vboxsync, 17 years ago

The Big Sun Rebranding Header Change

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