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