VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/Makefile@ 19455

Last change on this file since 19455 was 19455, checked in by vboxsync, 15 years ago

linux kernel modules: prevent some superflous output during build

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