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