VirtualBox

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

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

/me was sleeping again, makefiles recognise if and not #if

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