VirtualBox

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

Last change on this file since 3382 was 3096, checked in by vboxsync, 18 years ago

added another missing file to additions

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