VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/installer/Makefile.include.footer@ 33944

Last change on this file since 33944 was 28998, checked in by vboxsync, 15 years ago

Linux Additions: rename the vboxvfs module to vboxsf to make it load by demand of the Linux kernel

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1#
2# VirtualBox Guest Additions kernel module Makefile, common parts.
3#
4# (For 2.6.x, the main file must be called 'Makefile'!)
5#
6# Copyright (C) 2006-2007 Oracle Corporation
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# These file should be included by the Makefiles for any kernel modules we
19# build as part of the Guest Additions. The intended way of doing this is as
20# follows:
21#
22# include Makefile.include
23# MOD_NAME = <name of the module to be built, without extension>
24# MOD_OBJS = <list of object files which should be included>
25# MOD_FLAGS = <any additional CFLAGS which this module needs>
26#
27# The kmk kBuild define KBUILD_TARGET_ARCH is available.
28#
29# @todo the shared folders module Makefile also includes the following bits.
30# Integrate them if necessary.
31# MOD_FLAGS += -DEXPORT_SYMTAB -DVBGL_VBOXGUEST -DRT_WITH_VBOX
32#
33# # special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
34# # ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
35# ifeq ($(KERNELRELEASE),)
36# KFLAGS += $(foreach inc,$(KERN_INCL),\
37# $(if $(wildcard $(inc)/linux/utsrelease.h),\
38# $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
39# grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
40# grep '"2.6.18.*v5.*"' $(inc)/linux/utsrelease.h; \
41# grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
42# -DKERNEL_FC6,),))
43# else
44# KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
45# echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
46# echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
47# echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
48# -DKERNEL_FC6,)
49# endif
50#
51## important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
52# rm -rf .vboxsf* .tmp_ver* vboxsf.* Modules.symvers modules.order
53#
54
55
56
57# override is required by the Debian guys
58override MODULE = $(MOD_NAME)
59OBJS = $(MOD_OBJS)
60
61ifneq ($(MAKECMDGOALS),clean)
62
63ifeq ($(KERNELRELEASE),)
64
65 #
66 # building from this directory
67 #
68
69 # kernel base directory
70 ifndef KERN_DIR
71 KERN_DIR := /lib/modules/$(shell uname -r)/build
72 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
73 KERN_DIR := /usr/src/linux
74 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
75 $(error Error: unable to find the sources of your current Linux kernel. \
76 Specify KERN_DIR=<directory> and run Make again)
77 endif
78 $(warning Warning: using /usr/src/linux as the source directory of your \
79 Linux kernel. If this is not correct, specify \
80 KERN_DIR=<directory> and run Make again.)
81 endif
82 else
83 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
84 $(error Error: KERN_DIR does not point to a directory)
85 endif
86 endif
87
88 # includes
89 ifndef KERN_INCL
90 KERN_INCL = $(KERN_DIR)/include
91 endif
92 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
93 $(error Error: unable to find the include directory for your current Linux \
94 kernel. Specify KERN_INCL=<directory> and run Make again)
95 endif
96
97 # module install dir, only for current kernel
98 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
99 ifndef MODULE_DIR
100 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
101 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
102 MODULE_DIR := $(MODULE_DIR_TST)/misc
103 else
104 $(error Unable to find the folder to install the driver ($(MOD_NAME)) to)
105 endif
106 endif # MODULE_DIR unspecified
107 endif
108
109 # guess kernel version (24 or 26)
110 ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
111 KERN_VERSION := 24
112 else
113 KERN_VERSION := 26
114 endif
115
116else # neq($(KERNELRELEASE),)
117
118 #
119 # building from kbuild (make -C <kernel_directory> M=`pwd`)
120 #
121
122 # guess kernel version (24 or 26)
123 ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
124 KERN_VERSION := 24
125 else
126 KERN_VERSION := 26
127 endif
128
129endif # neq($(KERNELRELEASE),)
130
131# debug - show guesses.
132ifdef DEBUG
133$(warning dbg: KERN_DIR = $(KERN_DIR))
134$(warning dbg: KERN_INCL = $(KERN_INCL))
135$(warning dbg: MODULE_DIR = $(MODULE_DIR))
136$(warning dbg: KERN_VERSION = $(KERN_VERSION))
137endif
138
139KBUILD_VERBOSE ?= 1
140
141#
142# Compiler options
143#
144ifndef INCL
145 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
146 ifndef KBUILD_EXTMOD
147 KBUILD_EXTMOD := $(shell pwd)
148 endif
149 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
150 export INCL
151endif
152KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 \
153 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM \
154 -DLOG_TO_BACKDOOR -DRT_WITH_VBOX -DIN_MODULE -DIN_GUEST_R0
155ifeq ($(BUILD_TARGET_ARCH),amd64)
156 KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
157else
158 KFLAGS += -DRT_ARCH_X86
159endif
160ifeq ($(BUILD_TYPE),debug)
161KFLAGS += -DDEBUG
162endif
163
164ifeq ($(KERN_VERSION), 24)
165#
166# 2.4
167#
168
169CFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
170MODULE_EXT := o
171
172# 2.4 Module linking
173$(MODULE).o: $(OBJS)
174 $(LD) -o $@ -r $(OBJS)
175
176.PHONY: $(MODULE)
177all: $(MODULE)
178$(MODULE): $(MODULE).o
179
180else
181#
182# 2.6 and later
183#
184
185MODULE_EXT := ko
186
187$(MODULE)-y := $(OBJS)
188
189# build defs
190EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
191
192all: $(MODULE)
193
194obj-m += $(MODULE).o
195
196$(MODULE):
197 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
198
199endif
200
201install: $(MODULE)
202 @mkdir -p $(MODULE_DIR); \
203 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
204 PATH="$(PATH):/bin:/sbin" depmod -a;
205
206endif # eq($(MAKECMDGOALS),clean)
207
208clean:
209 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
210 rm -rf .$(MOD_NAME)* .tmp_ver* $(MOD_NAME).* Module.symvers Modules.symvers modules.order
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette