VirtualBox

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

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

RT_OS_LINUX

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