VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/module/Makefile.module@ 21326

Last change on this file since 21326 was 21326, checked in by vboxsync, 16 years ago

build fix.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 KB
Line 
1#
2# VirtualBox Guest Additions Module Makefile.
3#
4# (For 2.6.x this file must be 'Makefile'!)
5#
6# Copyright (C) 2006-2007 Sun Microsystems, Inc.
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License (GPL) as published by the Free Software
12# Foundation, in version 2 as it comes in the "COPYING" file of the
13# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
17# Clara, CA 95054 USA or visit http://www.sun.com if you need
18# additional information or have any questions.
19#
20
21#
22# First, figure out which architecture we're targeting and the build type.
23# (We have to support basic cross building (ARCH=i386|x86_64).)
24# While at it, warn about BUILD_* vars found to help with user problems.
25#
26ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
27 BUILD_TARGET_ARCH_DEF := amd64
28else
29 BUILD_TARGET_ARCH_DEF := x86
30endif
31ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
32 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
33 BUILD_TARGET_ARCH :=
34endif
35ifeq ($(BUILD_TARGET_ARCH),)
36 ifeq ($(ARCH),x86_64)
37 BUILD_TARGET_ARCH := amd64
38 else
39 ifeq ($(ARCH),i386)
40 BUILD_TARGET_ARCH := x86
41 else
42 BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
43 endif
44 endif
45else
46 ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
47 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
48 endif
49endif
50
51ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
52 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
53 BUILD_TYPE :=
54endif
55ifeq ($(BUILD_TYPE),)
56 BUILD_TYPE := release
57else
58 ifneq ($(BUILD_TYPE),release)
59 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
60 endif
61endif
62
63
64# override is required by the Debian guys
65override MODULE = vboxadd
66OBJS = \
67 cmc.o \
68 vboxmod.o \
69 GenericRequest.o \
70 HGCMInternal.o \
71 Init.o \
72 PhysHeap.o \
73 SysHlp.o \
74 VMMDev.o \
75 r0drv/alloc-r0drv.o \
76 r0drv/memobj-r0drv.o \
77 r0drv/linux/alloc-r0drv-linux.o \
78 r0drv/linux/assert-r0drv-linux.o \
79 r0drv/linux/memobj-r0drv-linux.o \
80 r0drv/linux/memuserkernel-r0drv-linux.o \
81 r0drv/linux/process-r0drv-linux.o \
82 r0drv/linux/semevent-r0drv-linux.o \
83 r0drv/linux/semfastmutex-r0drv-linux.o \
84 RTErrConvertToErrno.o \
85 divdi3.o \
86 moddi3.o \
87 udivdi3.o \
88 umoddi3.o \
89 qdivrem.o \
90 logbackdoor.o \
91 logformat.o \
92 strformat.o \
93 strformatrt.o \
94 strformattype.o \
95 strprintf.o \
96 strformat-vbox.o \
97 RTAssertShouldPanic-generic.o
98ifeq ($(BUILD_TARGET_ARCH),amd64)
99OBJS += \
100 alloc/heapsimple.o \
101 r0drv/linux/spinlock-r0drv-linux.o
102endif
103
104ifneq ($(MAKECMDGOALS),clean)
105
106ifeq ($(KERNELRELEASE),)
107
108 #
109 # building from this directory
110 #
111
112 # kernel base directory
113 ifndef KERN_DIR
114 KERN_DIR := /lib/modules/$(shell uname -r)/build
115 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
116 KERN_DIR := /usr/src/linux
117 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
118 $(error Error: unable to find the sources of your current Linux kernel. \
119 Specify KERN_DIR=<directory> and run Make again)
120 endif
121 $(warning Warning: using /usr/src/linux as the source directory of your \
122 Linux kernel. If this is not correct, specify \
123 KERN_DIR=<directory> and run Make again.)
124 endif
125 else
126 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
127 $(error Error: KERN_DIR does not point to a directory)
128 endif
129 endif
130
131 # includes
132 ifndef KERN_INCL
133 KERN_INCL = $(KERN_DIR)/include
134 endif
135 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
136 $(error Error: unable to find the include directory for your current Linux \
137 kernel. Specify KERN_INCL=<directory> and run Make again)
138 endif
139
140 # module install dir, only for current kernel
141 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
142 ifndef MODULE_DIR
143 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
144 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
145 MODULE_DIR := $(MODULE_DIR_TST)/misc
146 else
147 $(error Unable to find the folder to install the additions driver to)
148 endif
149 endif # MODULE_DIR unspecified
150 endif
151
152 # guess kernel version (24 or 26)
153 ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
154 KERN_VERSION := 24
155 else
156 KERN_VERSION := 26
157 endif
158
159else # neq($(KERNELRELEASE),)
160
161 #
162 # building from kbuild (make -C <kernel_directory> M=`pwd`)
163 #
164
165 # guess kernel version (24 or 26)
166 ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
167 KERN_VERSION := 24
168 else
169 KERN_VERSION := 26
170 endif
171
172endif # neq($(KERNELRELEASE),)
173
174# debug - show guesses.
175ifdef DEBUG
176$(warning dbg: KERN_DIR = $(KERN_DIR))
177$(warning dbg: KERN_INCL = $(KERN_INCL))
178$(warning dbg: MODULE_DIR = $(MODULE_DIR))
179$(warning dbg: KERN_VERSION = $(KERN_VERSION))
180endif
181
182KBUILD_VERBOSE ?= 1
183
184#
185# Compiler options
186#
187ifndef INCL
188 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
189 ifndef KBUILD_EXTMOD
190 KBUILD_EXTMOD := $(shell pwd)
191 endif
192 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
193 export INCL
194endif
195KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 \
196 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM \
197 -DLOG_TO_BACKDOOR -DRT_WITH_VBOX -DIN_MODULE -DIN_GUEST_R0
198ifeq ($(BUILD_TARGET_ARCH),amd64)
199 KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
200else
201 KFLAGS += -DRT_ARCH_X86
202endif
203ifeq ($(BUILD_TYPE),debug)
204KFLAGS += -DDEBUG
205endif
206
207ifeq ($(KERN_VERSION), 24)
208#
209# 2.4
210#
211
212CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
213MODULE_EXT := o
214
215# 2.4 Module linking
216$(MODULE).o: $(OBJS)
217 $(LD) -o $@ -r $(OBJS)
218
219.PHONY: $(MODULE)
220all: $(MODULE)
221$(MODULE): $(MODULE).o
222
223else
224#
225# 2.6 and later
226#
227
228MODULE_EXT := ko
229
230$(MODULE)-y := $(OBJS)
231
232# build defs
233EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
234
235all: $(MODULE)
236
237obj-m += $(MODULE).o
238
239$(MODULE):
240 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
241
242endif
243
244install: $(MODULE)
245 @mkdir -p $(MODULE_DIR); \
246 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
247 PATH="$(PATH):/bin:/sbin" depmod -ae;
248
249endif # eq($(MAKECMDGOALS),clean)
250
251clean:
252 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
253 rm -rf .vboxadd* .tmp_ver* vboxadd.* Module.symvers 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