VirtualBox

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

Last change on this file since 2586 was 2197, checked in by vboxsync, 18 years ago

some cleanup

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