VirtualBox

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

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

clean one more file

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