VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module@ 6159

Last change on this file since 6159 was 6159, checked in by vboxsync, 17 years ago

Linux kernel module Makefiles: use KDIR if set

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
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#
18MODULE = vboxvfs
19OBJS = \
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
42EXTRA_CFLAGS = -fshort-wchar
43
44ifneq ($(MAKECMDGOALS),clean)
45
46ifdef KDIR
47# Debian kernel module build system
48KERN_DIR := $(KDIR)
49endif
50
51# kernel base directory
52ifndef 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
61else
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
65endif
66
67# includes
68ifndef KERN_INCL
69 KERN_INCL = $(KERN_DIR)/include
70endif
71ifneq ($(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.)
73endif
74
75# module install dir.
76ifneq ($(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
85endif
86
87# guess kernel version (24 or 26)
88ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
89KERN_VERSION := 24
90else
91KERN_VERSION := 26
92endif
93# KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
94
95# debug - show guesses.
96ifdef 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))
101endif
102
103
104#
105# Compiler options
106#
107ifndef 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
114endif
115KFLAGS := -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
118ifeq ($(BUILD_TYPE),debug)
119KFLAGS += -DDEBUG
120endif
121
122ifeq ($(KERN_VERSION), 24)
123#
124# 2.4
125#
126
127CFLAGS := -O2 -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
128MODULE_EXT := o
129
130# 2.4 Module linking
131$(MODULE).o: $(OBJS)
132 $(LD) -o $@ -r $(OBJS)
133
134.PHONY: $(MODULE)
135all: $(MODULE)
136$(MODULE): $(MODULE).o
137
138else
139#
140# 2.6 and later
141#
142
143MODULE_EXT := ko
144
145$(MODULE)-y := $(OBJS)
146
147# detect FC6 2.6.18
148KFLAGS += $(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
153KFLAGS += $(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
159EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
160
161all: $(MODULE)
162
163obj-m += $(MODULE).o
164
165$(MODULE):
166 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
167
168endif
169
170install: $(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
175endif # eq($(MAKECMDGOALS),clean)
176
177clean:
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
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