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