VirtualBox

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

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

Created assert-r0drv-linux.c (finally).

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