VirtualBox

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

Last change on this file since 7389 was 7183, checked in by vboxsync, 17 years ago

Added RTStrFormatTypeRegister/SetUser/Deregister for runtime registration of custom format types. Example: RTStrFormat("%R[pgmpage]", pPage);

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