VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/Makefile@ 21258

Last change on this file since 21258 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.2 KB
Line 
1#
2# Makefile for the VirtualBox Linux Host Network Filter 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# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19# Clara, CA 95054 USA or visit http://www.sun.com if you need
20# additional information or have any questions.
21#
22
23#
24# First, figure out which architecture we're targeting and the build type.
25# (We have to support basic cross building (ARCH=i386|x86_64).)
26# While at it, warn about BUILD_* vars found to help with user problems.
27#
28ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
29 BUILD_TARGET_ARCH_DEF := amd64
30else
31 BUILD_TARGET_ARCH_DEF := x86
32endif
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 BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
45 endif
46 endif
47else
48 ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
49 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
50 endif
51endif
52
53ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
54 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
55 BUILD_TYPE :=
56endif
57ifeq ($(BUILD_TYPE),)
58 BUILD_TYPE := release
59else
60 ifneq ($(BUILD_TYPE),release)
61 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
62 endif
63endif
64
65# override is required by the Debian guys
66override MODULE = vboxnetflt
67OBJS = \
68 linux/VBoxNetFlt-linux.o \
69 VBoxNetFlt.o \
70 SUPR0IdcClient.o \
71 SUPR0IdcClientComponent.o \
72 SUPR0IdcClient-linux.o \
73 r0drv/alloc-r0drv.o \
74 r0drv/initterm-r0drv.o \
75 r0drv/memobj-r0drv.o \
76 r0drv/mpnotification-r0drv.o \
77 r0drv/powernotification-r0drv.o \
78 r0drv/linux/assert-r0drv-linux.o \
79 r0drv/linux/alloc-r0drv-linux.o \
80 r0drv/linux/initterm-r0drv-linux.o \
81 r0drv/linux/memobj-r0drv-linux.o \
82 r0drv/linux/mp-r0drv-linux.o \
83 r0drv/linux/mpnotification-r0drv-linux.o \
84 r0drv/linux/process-r0drv-linux.o \
85 r0drv/linux/semevent-r0drv-linux.o \
86 r0drv/linux/semeventmulti-r0drv-linux.o \
87 r0drv/linux/semfastmutex-r0drv-linux.o \
88 r0drv/linux/spinlock-r0drv-linux.o \
89 r0drv/linux/thread-r0drv-linux.o \
90 r0drv/linux/thread2-r0drv-linux.o \
91 r0drv/linux/time-r0drv-linux.o \
92 common/err/RTErrConvertFromErrno.o \
93 common/err/RTErrConvertToErrno.o \
94 common/log/log.o \
95 common/log/logellipsis.o \
96 common/log/logrel.o \
97 common/log/logrelellipsis.o \
98 common/log/logcom.o \
99 common/log/logformat.o \
100 common/string/strformat.o \
101 common/string/strformatrt.o \
102 common/string/strformattype.o \
103 common/string/strprintf.o \
104 common/string/strtonum.o \
105 r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
106 generic/RTAssertShouldPanic-generic.o \
107 generic/RTLogWriteStdErr-stub-generic.o \
108 generic/RTLogWriteStdOut-stub-generic.o \
109 generic/RTLogWriteUser-generic.o \
110 generic/uuid-generic.o \
111 VBox/log-vbox.o \
112 VBox/strformat-vbox.o
113ifeq ($(BUILD_TARGET_ARCH),x86)
114OBJS += math/gcc/divdi3.o \
115 math/gcc/moddi3.o \
116 math/gcc/qdivrem.o \
117 math/gcc/udivdi3.o \
118 math/gcc/divdi3.o \
119 math/gcc/umoddi3.o
120endif
121ifeq ($(BUILD_TARGET_ARCH),amd64)
122OBJS += alloc/heapsimple.o
123endif
124
125ifneq ($(MAKECMDGOALS),clean)
126
127ifeq ($(KERNELRELEASE),)
128
129 #
130 # building from this directory
131 #
132
133 # kernel base directory
134 ifndef KERN_DIR
135 # build for the current kernel, version check
136 KERN_DIR := /lib/modules/$(shell uname -r)/build
137 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
138 KERN_DIR := /usr/src/linux
139 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
140 $(error Error: unable to find the sources of your current Linux kernel. \
141 Specify KERN_DIR=<directory> and run Make again)
142 endif
143 $(warning Warning: using /usr/src/linux as the source directory of your \
144 Linux kernel. If this is not correct, specify \
145 KERN_DIR=<directory> and run Make again.)
146 endif
147 # check if versions match -- works only for later 2.6 kernels
148 VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
149 ifneq ($(VBOX_KERN_VER),)
150 ifneq ($(VBOX_KERN_VER),$(shell uname -r))
151 $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
152 the current kernel (version $(shell uname -r)))
153 endif
154 endif
155 else
156 # build for a dedicated kernel, no version check
157 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
158 $(error Error: KERN_DIR does not point to a directory)
159 endif
160 endif
161
162 # includes
163 ifndef KERN_INCL
164 KERN_INCL = $(KERN_DIR)/include
165 endif
166 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
167 $(error Error: unable to find the include directory for your current Linux \
168 kernel. Specify KERN_INCL=<directory> and run Make again)
169 endif
170
171 # module install dir, only for current kernel
172 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
173 ifndef MODULE_DIR
174 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
175 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
176 MODULE_DIR := $(MODULE_DIR_TST)/misc
177 else
178 $(error Unable to find the folder to install the support driver to)
179 endif
180 endif # MODULE_DIR unspecified
181 endif
182
183else # neq($(KERNELRELEASE),)
184
185 #
186 # building from kbuild (make -C <kernel_directory> M=`pwd`)
187 #
188
189endif # neq($(KERNELRELEASE),)
190
191# debug - show guesses.
192ifdef DEBUG
193$(warning dbg: KERN_DIR = $(KERN_DIR))
194$(warning dbg: KERN_INCL = $(KERN_INCL))
195$(warning dbg: MODULE_DIR = $(MODULE_DIR))
196endif
197
198KBUILD_VERBOSE ?= 1
199
200#
201# Compiler options
202#
203ifndef INCL
204 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
205 ifndef KBUILD_EXTMOD
206 KBUILD_EXTMOD := $(shell pwd)
207 endif
208 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
209 export INCL
210endif
211KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
212ifdef VBOX_REDHAT_KABI
213 KFLAGS += -DVBOX_REDHAT_KABI
214endif
215ifeq ($(BUILD_TARGET_ARCH),amd64)
216 KFLAGS += -DRT_ARCH_AMD64
217else
218 KFLAGS += -DRT_ARCH_X86
219endif
220# must be consistent with Config.kmk!
221KFLAGS += -DVBOX_WITH_64_BITS_GUESTS
222ifeq ($(BUILD_TYPE),debug)
223 KFLAGS += -DDEBUG -DDEBUG_$(USER) -g
224 # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
225 KFLAGS += -DIPRT_DEBUG_SEMS
226endif
227
228# By default we use remap_pfn_range() kernel API to make kernel pages
229# visible for userland. Unfortuately, it leads to situation that
230# during debug session all structures on that page (such as PVM pointer)
231# are not accessible to the debugger (see #3214).
232# This code enables experimental support
233# for vm_insert_page() kernel API, allowing to export kernel pages
234# to the userland in more debugger-friendly way. Due to stability
235# concerns, not enabled by default yet.
236ifdef VBOX_USE_INSERT_PAGE
237 KFLAGS += -DVBOX_USE_INSERT_PAGE
238endif
239
240MODULE_EXT := ko
241$(MODULE)-y := $(OBJS)
242
243# build defs
244EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
245
246all: $(MODULE)
247
248obj-m += $(MODULE).o
249
250$(MODULE):
251 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
252
253install: $(MODULE)
254 @mkdir -p $(MODULE_DIR); \
255 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
256 PATH="$(PATH):/bin:/sbin" depmod -ae; \
257 rm -f /etc/vbox/module_not_compiled
258
259install_rpm: $(MODULE)
260 @mkdir -p $(MODULE_DIR); \
261 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
262
263endif # eq($(MAKECMDGOALS),clean)
264
265# important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
266clean:
267 for f in . linux r0drv r0drv/linux VBox common/err common/string common/log generic math/gcc; \
268 do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
269 rm -rf .vboxnetflt* .tmp_ver* vboxnetflt.* 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