~ubuntu-branches/ubuntu/trusty/virtualbox-lts-xenial/trusty-proposed

« back to all changes in this revision

Viewing changes to src/VBox/HostDrivers/VBoxPci/linux/Makefile

  • Committer: Package Import Robot
  • Author(s): Gianfranco Costamagna
  • Date: 2016-02-23 14:28:26 UTC
  • Revision ID: package-import@ubuntu.com-20160223142826-bdu69el2z6wa2a44
Tags: upstream-4.3.36-dfsg
ImportĀ upstreamĀ versionĀ 4.3.36-dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Makefile for the VirtualBox Linux Host PCI Driver.
 
3
# (For 2.6.x this file must be called 'Makefile'!)
 
4
#
 
5
 
 
6
#
 
7
#
 
8
# Copyright (C) 2011 Oracle Corporation
 
9
#
 
10
# This file is part of VirtualBox Open Source Edition (OSE), as
 
11
# available from http://www.virtualbox.org. This file is free software;
 
12
# you can redistribute it and/or modify it under the terms of the GNU
 
13
# General Public License (GPL) as published by the Free Software
 
14
# Foundation, in version 2 as it comes in the "COPYING" file of the
 
15
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
16
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
17
#
 
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
#
 
24
ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
 
25
 BUILD_TARGET_ARCH_DEF := amd64
 
26
else
 
27
 BUILD_TARGET_ARCH_DEF := x86
 
28
endif
 
29
ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
 
30
 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
 
31
 BUILD_TARGET_ARCH :=
 
32
endif
 
33
ifeq ($(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
 
43
else
 
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
 
47
endif
 
48
 
 
49
ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
 
50
 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
 
51
 BUILD_TYPE :=
 
52
endif
 
53
ifeq ($(BUILD_TYPE),)
 
54
 BUILD_TYPE := release
 
55
else
 
56
 ifneq ($(BUILD_TYPE),release)
 
57
  $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
 
58
 endif
 
59
endif
 
60
 
 
61
# override is required by the Debian guys
 
62
override MODULE = vboxpci
 
63
OBJS   =                                \
 
64
        linux/VBoxPci-linux.o           \
 
65
        VBoxPci.o                       \
 
66
        SUPR0IdcClient.o                \
 
67
        SUPR0IdcClientComponent.o       \
 
68
        linux/SUPR0IdcClient-linux.o
 
69
 
 
70
ifeq ($(BUILD_TARGET_ARCH),x86)
 
71
OBJS += math/gcc/divdi3.o       \
 
72
        math/gcc/moddi3.o       \
 
73
        math/gcc/qdivrem.o      \
 
74
        math/gcc/udivdi3.o      \
 
75
        math/gcc/divdi3.o       \
 
76
        math/gcc/umoddi3.o
 
77
endif
 
78
 
 
79
ifneq ($(MAKECMDGOALS),clean)
 
80
 
 
81
ifeq ($(KERNELRELEASE),)
 
82
 
 
83
 #
 
84
 # building from this directory
 
85
 #
 
86
 
 
87
 # kernel base directory
 
88
 ifndef KERN_DIR
 
89
 # build for the current kernel, version check
 
90
  KERN_DIR := /lib/modules/$(shell uname -r)/build
 
91
  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
 
92
   KERN_DIR := /usr/src/linux
 
93
   ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
 
94
    $(error Error: unable to find the sources of your current Linux kernel. \
 
95
                   Specify KERN_DIR=<directory> and run Make again)
 
96
   endif
 
97
   $(warning Warning: using /usr/src/linux as the source directory of your \
 
98
                      Linux kernel. If this is not correct, specify \
 
99
                      KERN_DIR=<directory> and run Make again.)
 
100
  endif
 
101
 else
 
102
  ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
 
103
   $(error Error: KERN_DIR does not point to a directory)
 
104
  endif
 
105
 endif
 
106
 
 
107
 # includes
 
108
 ifndef KERN_INCL
 
109
  KERN_INCL = $(KERN_DIR)/include
 
110
 endif
 
111
 ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
 
112
  $(error Error: unable to find the include directory for your current Linux \
 
113
                 kernel. Specify KERN_INCL=<directory> and run Make again)
 
114
 endif
 
115
 
 
116
 # module install dir, only for current kernel
 
117
 ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
 
118
  ifndef MODULE_DIR
 
119
   MODULE_DIR_TST := /lib/modules/$(shell uname -r)
 
120
   ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
 
121
    MODULE_DIR := $(MODULE_DIR_TST)/misc
 
122
   else
 
123
    $(error Unable to find the folder to install the support driver to)
 
124
   endif
 
125
  endif # MODULE_DIR unspecified
 
126
 endif
 
127
 
 
128
else # neq($(KERNELRELEASE),)
 
129
 
 
130
 #
 
131
 # building from kbuild (make -C <kernel_directory> M=`pwd`)
 
132
 #
 
133
 
 
134
endif # neq($(KERNELRELEASE),)
 
135
 
 
136
# debug - show guesses.
 
137
ifdef DEBUG
 
138
$(warning dbg: KERN_DIR     = $(KERN_DIR))
 
139
$(warning dbg: KERN_INCL    = $(KERN_INCL))
 
140
$(warning dbg: MODULE_DIR   = $(MODULE_DIR))
 
141
endif
 
142
 
 
143
KBUILD_VERBOSE ?= 1
 
144
 
 
145
#
 
146
# Compiler options
 
147
#
 
148
ifndef INCL
 
149
 INCL    := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
 
150
 ifndef KBUILD_EXTMOD
 
151
  KBUILD_EXTMOD := $(shell pwd)
 
152
 endif
 
153
 INCL    += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
 
154
 INCL    += $(addprefix -I$(KBUILD_EXTMOD)/vboxpci,/ /include /r0drv/linux)
 
155
 export INCL
 
156
endif
 
157
ifneq ($(wildcard $(KBUILD_EXTMOD)/vboxpci),)
 
158
 MANGLING := $(KBUILD_EXTMOD)/vboxpci/include/VBox/SUPDrvMangling.h
 
159
else
 
160
 MANGLING := $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h
 
161
endif
 
162
KFLAGS   := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
 
163
            -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
 
164
ifdef VBOX_REDHAT_KABI
 
165
 KFLAGS  += -DVBOX_REDHAT_KABI
 
166
endif
 
167
ifeq ($(BUILD_TARGET_ARCH),amd64)
 
168
 KFLAGS  += -DRT_ARCH_AMD64
 
169
else
 
170
 KFLAGS  += -DRT_ARCH_X86
 
171
endif
 
172
# must be consistent with Config.kmk!
 
173
KFLAGS  += -DVBOX_WITH_64_BITS_GUESTS
 
174
ifeq ($(BUILD_TYPE),debug)
 
175
 KFLAGS  += -DDEBUG -DDEBUG_$(USER) -g
 
176
 # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
 
177
 #KFLAGS  += -DIPRT_DEBUG_SEMS
 
178
endif
 
179
 
 
180
# By default we use remap_pfn_range() kernel API to make kernel pages
 
181
# visible for userland. Unfortunately, it leads to situation that
 
182
# during debug session all structures on that page (such as PVM pointer)
 
183
# are not accessible to the debugger (see #3214).
 
184
# This code enables experimental support
 
185
# for vm_insert_page() kernel API, allowing to export kernel pages
 
186
# to the userland in more debugger-friendly way. Due to stability
 
187
# concerns, not enabled by default yet.
 
188
ifdef VBOX_USE_INSERT_PAGE
 
189
 KFLAGS  += -DVBOX_USE_INSERT_PAGE
 
190
endif
 
191
 
 
192
MODULE_EXT    := ko
 
193
$(MODULE)-y   := $(OBJS)
 
194
 
 
195
# build defs
 
196
EXTRA_CFLAGS  += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG)
 
197
 
 
198
all: $(MODULE)
 
199
 
 
200
obj-m += $(MODULE).o
 
201
 
 
202
# OL/UEK: disable module signing for external modules -- we don't have any private key
 
203
$(MODULE):
 
204
        $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) CONFIG_MODULE_SIG= -C $(KERN_DIR) modules
 
205
 
 
206
install: $(MODULE)
 
207
        @mkdir -p $(MODULE_DIR); \
 
208
        install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
 
209
        PATH="$(PATH):/bin:/sbin" depmod -a;
 
210
 
 
211
install_rpm: $(MODULE)
 
212
        @mkdir -p $(MODULE_DIR); \
 
213
        install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
 
214
 
 
215
else # eq ($(MAKECMDGOALS),clean)
 
216
 
 
217
 ifndef KERN_DIR
 
218
  KERN_DIR := /lib/modules/$(shell uname -r)/build
 
219
  ifeq ($(wildcard $(KERN_DIR)/Makefile),)
 
220
   KERN_DIR := /usr/src/linux
 
221
  endif
 
222
 endif
 
223
 ifeq ($(wildcard $(KERN_DIR)/Makefile),)
 
224
 
 
225
clean:
 
226
        find . \( -name \*.o -o -name \*.cmd \) -print0 | xargs -0 rm -f
 
227
        rm -rf .tmp_ver* $(MODULE).* Module.symvers Modules.symvers modules.order
 
228
 
 
229
 else
 
230
 
 
231
clean:
 
232
        $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) clean
 
233
 
 
234
 endif
 
235
 
 
236
endif # eq($(MAKECMDGOALS),clean)