VirtualBox

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

Last change on this file since 21015 was 21015, checked in by vboxsync, 15 years ago

Linux guest kernel modules: prevent some superflous output during build

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