VirtualBox

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

Last change on this file since 3669 was 3400, checked in by vboxsync, 18 years ago

Linux modules: don't demand on the MODULE_DIR if we don't install the kernel

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 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.
64ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
65 ifndef MODULE_DIR
66 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
67 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
68 MODULE_DIR := $(MODULE_DIR_TST)/misc
69 else
70 $(error Unable to find the folder to install the additions driver to)
71 endif
72 endif # MODULE_DIR unspecified
73endif
74
75# guess kernel version (24 or 26)
76ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
77KERN_VERSION := 24
78else
79KERN_VERSION := 26
80endif
81# KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
82
83# debug - show guesses.
84ifdef DEBUG
85$(warning dbg: KERN_DIR = $(KERN_DIR))
86$(warning dbg: KERN_INCL = $(KERN_INCL))
87$(warning dbg: MODULE_DIR = $(MODULE_DIR))
88$(warning dbg: KERN_VERSION = $(KERN_VERSION))
89endif
90
91
92#
93# Compiler options
94#
95ifndef INCL
96 INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
97 ifndef KBUILD_EXTMOD
98 KBUILD_EXTMOD := $(shell pwd)
99 endif
100 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
101 export INCL
102endif
103KFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -D_X86_ -DIN_RT_R0 -DIN_SUP_R0 \
104 -DVBGL_VBOXGUEST -DVBOX_HGCM -DLOG_TO_BACKDOOR
105#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
106#KFLAGS += -DDEBUG
107#endif
108
109ifeq ($(KERN_VERSION), 24)
110#
111# 2.4
112#
113
114CFLAGS := -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
115MODULE_EXT := o
116
117# 2.4 Module linking
118$(MODULE).o: $(OBJS)
119 $(LD) -o $@ -r $(OBJS)
120
121.PHONY: $(MODULE)
122all: $(MODULE)
123$(MODULE): $(MODULE).o
124
125else
126#
127# 2.6 and later
128#
129
130MODULE_EXT := ko
131
132$(MODULE)-y := $(OBJS)
133
134# build defs
135EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
136
137all: $(MODULE)
138
139obj-m += $(MODULE).o
140
141$(MODULE):
142 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
143
144endif
145
146install: $(MODULE)
147 @mkdir -p $(MODULE_DIR); \
148 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
149 PATH="$(PATH):/bin:/sbin" depmod -ae;
150
151endif # eq($(MAKECMDGOALS),clean)
152
153clean:
154 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
155 rm -rf .vboxadd* .tmp_ver* vboxadd.* Module.symvers Modules.symvers
Note: See TracBrowser for help on using the repository browser.

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