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