VirtualBox

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

Last change on this file since 1248 was 1183, checked in by vboxsync, 18 years ago

typos

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