VirtualBox

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

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

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 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 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#
17MODULE = vboxvfs
18OBJS = \
19 vfsmod.o \
20 vfs-utils.o \
21 GenericRequest.o \
22 SysHlp.o \
23 PhysHeap.o \
24 Init.o \
25 VMMDev.o \
26 HGCM.o \
27 VBoxCalls.o \
28 r0drv/alloc-r0drv.o \
29 r0drv/linux/alloc-r0drv-linux.o \
30 r0drv/linux/semaphore-r0drv-linux.o
31EXTRA_CFLAGS = -fshort-wchar
32
33ifneq ($(MAKECMDGOALS),clean)
34
35# kernel base directory
36ifndef KERN_DIR
37 KERN_DIR := /lib/modules/$(shell uname -r)/build
38 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
39 KERN_DIR := /usr/src/linux
40 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
41 $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
42 endif
43 $(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.)
44 endif
45else
46 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
47 $(error Error: KERN_DIR does not point to a directory.)
48 endif
49endif
50
51# includes
52ifndef KERN_INCL
53 KERN_INCL = $(KERN_DIR)/include
54endif
55ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
56 $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
57endif
58
59# module install dir.
60ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
61 ifndef MODULE_DIR
62 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
63 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
64 MODULE_DIR := $(MODULE_DIR_TST)/misc
65 else
66 $(error Unable to find the folder to install the shared folders driver to)
67 endif
68 endif # MODULE_DIR unspecified
69endif
70
71# guess kernel version (24 or 26)
72ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
73KERN_VERSION := 24
74else
75KERN_VERSION := 26
76endif
77# KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
78
79# debug - show guesses.
80ifdef DEBUG
81$(warning dbg: KERN_DIR = $(KERN_DIR))
82$(warning dbg: KERN_INCL = $(KERN_INCL))
83$(warning dbg: MODULE_DIR = $(MODULE_DIR))
84$(warning dbg: KERN_VERSION = $(KERN_VERSION))
85endif
86
87
88#
89# Compiler options
90#
91ifndef INCL
92 INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
93 ifndef KBUILD_EXTMOD
94 KBUILD_EXTMOD := $(shell pwd)
95 endif
96 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
97 export INCL
98endif
99KFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -D_X86_ -DIN_RT_R0 -DIN_SUP_R0 \
100 -DVBOX_HGCM -DLOG_TO_BACKDOOR
101#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
102#KFLAGS += -DDEBUG
103#endif
104
105ifeq ($(KERN_VERSION), 24)
106#
107# 2.4
108#
109
110CFLAGS := -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
111MODULE_EXT := o
112
113# 2.4 Module linking
114$(MODULE).o: $(OBJS)
115 $(LD) -o $@ -r $(OBJS)
116
117.PHONY: $(MODULE)
118all: $(MODULE)
119$(MODULE): $(MODULE).o
120
121else
122#
123# 2.6 and later
124#
125
126MODULE_EXT := ko
127
128$(MODULE)-y := $(OBJS)
129
130# detect FC6 2.6.18
131KFLAGS += $(foreach inc,$(KERN_INCL),\
132 $(if $(wildcard $(inc)/linux/utsrelease.h),\
133 $(if $(shell if grep -q '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h;\
134 then echo yes; fi),-DKERNEL_FC6,),))
135# detect rhel5 2.6.18
136KFLAGS += $(foreach inc,$(KERN_INCL),\
137 $(if $(wildcard $(inc)/linux/utsrelease.h),\
138 $(if $(shell if grep -q '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h;\
139 then echo yes; fi),-DKERNEL_FC6,),))
140
141# build defs
142EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
143
144all: $(MODULE)
145
146obj-m += $(MODULE).o
147
148$(MODULE):
149 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
150
151endif
152
153install: $(MODULE)
154 @mkdir -p $(MODULE_DIR); \
155 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
156 PATH="$(PATH):/bin:/sbin" depmod -ae;
157
158endif # eq($(MAKECMDGOALS),clean)
159
160clean:
161 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
162 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