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