VirtualBox

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

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

unbreak Linux Additions

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 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#
26ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
27 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
28 BUILD_TARGET_ARCH :=
29endif
30ifeq ($(BUILD_TARGET_ARCH),)
31 ifeq ($(ARCH),x86_64)
32 BUILD_TARGET_ARCH := amd64
33 else
34 ifeq ($(ARCH),i386)
35 BUILD_TARGET_ARCH := x86
36 else
37 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
38 BUILD_TARGET_ARCH := amd64
39 else
40 BUILD_TARGET_ARCH := x86
41 endif
42 endif
43 endif
44else
45 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
46endif
47
48ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
49 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
50 BUILD_TYPE :=
51endif
52ifeq ($(BUILD_TYPE),)
53 BUILD_TYPE := release
54else
55 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
56endif
57
58
59# override is required by the Debian guys
60override MODULE = vboxadd
61OBJS = \
62 cmc.o \
63 hgcmcall.o \
64 vboxmod.o \
65 GenericRequest.o \
66 HGCMInternal.o \
67 Init.o \
68 PhysHeap.o \
69 SysHlp.o \
70 VMMDev.o \
71 r0drv/alloc-r0drv.o \
72 r0drv/linux/alloc-r0drv-linux.o \
73 r0drv/linux/semevent-r0drv-linux.o \
74 r0drv/linux/semfastmutex-r0drv-linux.o \
75 RTErrConvertToErrno.o \
76 divdi3.o \
77 moddi3.o \
78 udivdi3.o \
79 umoddi3.o \
80 qdivrem.o \
81 assert.o \
82 logbackdoor.o \
83 logformat.o \
84 strformat.o \
85 strformatrt.o \
86 strformattype.o \
87 strformat-vbox.o
88ifeq ($(BUILD_TARGET_ARCH),amd64)
89OBJS += \
90 alloc/heapsimple.o \
91 r0drv/linux/spinlock-r0drv-linux.o
92endif
93
94ifneq ($(MAKECMDGOALS),clean)
95
96ifeq ($(KERNELRELEASE),)
97
98 #
99 # building from this directory
100 #
101
102 # kernel base directory
103 ifndef KERN_DIR
104 KERN_DIR := /lib/modules/$(shell uname -r)/build
105 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
106 KERN_DIR := /usr/src/linux
107 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
108 $(error Error: unable to find the sources of your current Linux kernel. \
109 Specify KERN_DIR=<directory> and run Make again)
110 endif
111 $(warning Warning: using /usr/src/linux as the source directory of your \
112 Linux kernel. If this is not correct, specify \
113 KERN_DIR=<directory> and run Make again.)
114 endif
115 else
116 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
117 $(error Error: KERN_DIR does not point to a directory)
118 endif
119 endif
120
121 # includes
122 ifndef KERN_INCL
123 KERN_INCL = $(KERN_DIR)/include
124 endif
125 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
126 $(error Error: unable to find the include directory for your current Linux \
127 kernel. Specify KERN_INCL=<directory> and run Make again)
128 endif
129
130 # module install dir.
131 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
132 ifndef MODULE_DIR
133 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
134 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
135 MODULE_DIR := $(MODULE_DIR_TST)/misc
136 else
137 $(error Unable to find the folder to install the additions driver to)
138 endif
139 endif # MODULE_DIR unspecified
140 endif
141
142 # guess kernel version (24 or 26)
143 ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
144 KERN_VERSION := 24
145 else
146 KERN_VERSION := 26
147 endif
148
149else # neq($(KERNELRELEASE),)
150
151 #
152 # building from kbuild (make -C <kernel_directory> M=`pwd`)
153 #
154
155 # guess kernel version (24 or 26)
156 ifeq ($(shell if grep '"2\.4\.' $(PWD)/include/linux/version.h > /dev/null; then echo yes; fi),yes)
157 KERN_VERSION := 24
158 else
159 KERN_VERSION := 26
160 endif
161
162endif # neq($(KERNELRELEASE),)
163
164# debug - show guesses.
165ifdef DEBUG
166$(warning dbg: KERN_DIR = $(KERN_DIR))
167$(warning dbg: KERN_INCL = $(KERN_INCL))
168$(warning dbg: MODULE_DIR = $(MODULE_DIR))
169$(warning dbg: KERN_VERSION = $(KERN_VERSION))
170endif
171
172
173#
174# Compiler options
175#
176ifndef INCL
177 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
178 ifndef KBUILD_EXTMOD
179 KBUILD_EXTMOD := $(shell pwd)
180 endif
181 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
182 export INCL
183endif
184KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 \
185 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM \
186 -DLOG_TO_BACKDOOR -DRT_WITH_VBOX -DIN_MODULE -DIN_GUEST_R0
187ifeq ($(BUILD_TARGET_ARCH),amd64)
188 KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
189else
190 KFLAGS += -DRT_ARCH_X86
191endif
192ifeq ($(BUILD_TYPE),debug)
193KFLAGS += -DDEBUG
194endif
195
196ifeq ($(KERN_VERSION), 24)
197#
198# 2.4
199#
200
201CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
202MODULE_EXT := o
203
204# 2.4 Module linking
205$(MODULE).o: $(OBJS)
206 $(LD) -o $@ -r $(OBJS)
207
208.PHONY: $(MODULE)
209all: $(MODULE)
210$(MODULE): $(MODULE).o
211
212else
213#
214# 2.6 and later
215#
216
217MODULE_EXT := ko
218
219$(MODULE)-y := $(OBJS)
220
221# build defs
222EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
223
224all: $(MODULE)
225
226obj-m += $(MODULE).o
227
228$(MODULE):
229 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
230
231endif
232
233install: $(MODULE)
234 @mkdir -p $(MODULE_DIR); \
235 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
236 PATH="$(PATH):/bin:/sbin" depmod -ae;
237
238endif # eq($(MAKECMDGOALS),clean)
239
240clean:
241 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
242 rm -rf .vboxadd* .tmp_ver* vboxadd.* 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