VirtualBox

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

Last change on this file since 36190 was 36190, checked in by vboxsync, 14 years ago

IPRT,Drivers: Committed a modified version of the diff_linux_guest_host patch. This mangles the IPRT symbols in kernel space on linux and later other platforms.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 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-2010 Oracle Corporation
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 (GPL) as published by the Free Software
12# Foundation, in version 2 as it comes in the "COPYING" file of the
13# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16
17## @todo We must make this into a common template *soon*.
18
19#
20# First, figure out which architecture we're targeting and the build type.
21# (We have to support basic cross building (ARCH=i386|x86_64).)
22# While at it, warn about BUILD_* vars found to help with user problems.
23#
24ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
25 BUILD_TARGET_ARCH_DEF := amd64
26else
27 BUILD_TARGET_ARCH_DEF := x86
28endif
29ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
30 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
31 BUILD_TARGET_ARCH :=
32endif
33ifeq ($(BUILD_TARGET_ARCH),)
34 ifeq ($(ARCH),x86_64)
35 BUILD_TARGET_ARCH := amd64
36 else
37 ifeq ($(ARCH),i386)
38 BUILD_TARGET_ARCH := x86
39 else
40 BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
41 endif
42 endif
43else
44 ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
45 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
46 endif
47endif
48
49ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
50 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
51 BUILD_TYPE :=
52endif
53ifeq ($(BUILD_TYPE),)
54 BUILD_TYPE := release
55else
56 ifneq ($(BUILD_TYPE),release)
57 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
58 endif
59endif
60
61EXTRA_CFLAGS = -fshort-wchar
62
63ifneq ($(MAKECMDGOALS),clean)
64
65ifeq ($(KERNELRELEASE),)
66
67 #
68 # building from this directory
69 #
70
71 # kernel base directory
72 ifndef KERN_DIR
73 KERN_DIR := /lib/modules/$(shell uname -r)/build
74 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
75 KERN_DIR := /usr/src/linux
76 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
77 $(error Error: unable to find the sources of your current Linux kernel. \
78 Specify KERN_DIR=<directory> and run Make again)
79 endif
80 $(warning Warning: using /usr/src/linux as the source directory of your \
81 Linux kernel. If this is not correct, specify \
82 KERN_DIR=<directory> and run Make again.)
83 endif
84 else
85 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
86 $(error Error: KERN_DIR does not point to a directory)
87 endif
88 endif
89
90 # includes
91 ifndef KERN_INCL
92 KERN_INCL = $(KERN_DIR)/include
93 endif
94 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
95 $(error Error: unable to find the include directory for your current Linux \
96 kernel. Specify KERN_INCL=<directory> and run Make again)
97 endif
98
99 # module install dir.
100 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
101 ifndef MODULE_DIR
102 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
103 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
104 MODULE_DIR := $(MODULE_DIR_TST)/misc
105 else
106 $(error Unable to find the folder to install the DRM driver to)
107 endif
108 endif # MODULE_DIR unspecified
109 endif
110
111 # guess kernel version (24 or 26)
112 ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
113 KERN_VERSION := 24
114 else
115 KERN_VERSION := 26
116 endif
117
118else # neq($(KERNELRELEASE),)
119
120 #
121 # building from kbuild (make -C <kernel_directory> M=`pwd`)
122 #
123
124 # guess kernel version (24 or 26)
125 ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
126 KERN_VERSION := 24
127 else
128 KERN_VERSION := 26
129 endif
130
131endif # neq($(KERNELRELEASE),)
132
133# debug - show guesses.
134ifdef DEBUG
135$(warning dbg: KERN_DIR = $(KERN_DIR))
136$(warning dbg: KERN_INCL = $(KERN_INCL))
137$(warning dbg: MODULE_DIR = $(MODULE_DIR))
138$(warning dbg: KERN_VERSION = $(KERN_VERSION))
139endif
140
141KBUILD_VERBOSE ?= 1
142
143#
144# Compiler options
145#
146ifndef INCL
147 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
148 ifndef KBUILD_EXTMOD
149 KBUILD_EXTMOD := $(shell pwd)
150 endif
151 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
152 INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxvideo,/ /include /r0drv/linux)
153 export INCL
154endif
155KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
156 -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DLOG_TO_BACKDOOR -DIN_MODULE \
157 -DIN_GUEST_R0
158# our module does not export any symbol
159KFLAGS += -DRT_NO_EXPORT_SYMBOL
160ifeq ($(BUILD_TARGET_ARCH),amd64)
161 KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
162else
163 KFLAGS += -DRT_ARCH_X86
164endif
165ifeq ($(BUILD_TYPE),debug)
166KFLAGS += -DDEBUG
167endif
168
169# override is required by the Debian guys
170override MODULE = vboxvideo
171OBJS = vboxvideo_drm.o
172
173ifeq ($(KERN_VERSION), 24)
174#
175# 2.4
176#
177
178CFLAGS := -O2 -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
179MODULE_EXT := o
180
181# 2.4 Module linking
182$(MODULE).o: $(OBJS)
183 $(LD) -o $@ -r $(OBJS)
184
185.PHONY: $(MODULE)
186all: $(MODULE)
187$(MODULE): $(MODULE).o
188
189else
190#
191# 2.6 and later
192#
193
194MODULE_EXT := ko
195
196$(MODULE)-y := $(OBJS)
197
198# special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
199# ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
200ifeq ($(KERNELRELEASE),)
201 KFLAGS += $(foreach inc,$(KERN_INCL),\
202 $(if $(wildcard $(inc)/linux/utsrelease.h),\
203 $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
204 grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
205 grep '"2.6.18.*v5.*"' $(inc)/linux/utsrelease.h; \
206 grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
207 -DKERNEL_FC6,),))
208else
209 KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
210 echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
211 echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
212 echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
213 -DKERNEL_FC6,)
214endif
215
216# build defs
217EXTRA_CFLAGS += -include $(KBUILD_EXTMOD)/include/VBox/VBoxGuestMangling.h $(INCL) $(KFLAGS) $(KDEBUG)
218
219all: $(MODULE)
220
221obj-m += $(MODULE).o
222
223$(MODULE):
224 $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
225
226endif
227
228install: $(MODULE)
229 @mkdir -p $(MODULE_DIR); \
230 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
231 PATH="$(PATH):/bin:/sbin" depmod -a;
232
233endif # eq($(MAKECMDGOALS),clean)
234
235# important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
236clean:
237 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
238 rm -rf .vboxvideo* .tmp_ver* vboxvideo.* Modules.symvers modules.order
239
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