Makefile revision c27687da2bcbaefd006c856b0dbc7f749ec01f4e
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# Makefile for the VirtualBox Linux Host Driver.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# (For 2.6.x this file must be called 'Makefile'!)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# Copyright (C) 2006-2007 Sun Microsystems, Inc.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# available from http://www.virtualbox.org. This file is free software;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# you can redistribute it and/or modify it under the terms of the GNU
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# General Public License (GPL) as published by the Free Software
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# The contents of this file may alternatively be used under the terms
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# of the Common Development and Distribution License Version 1.0
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# VirtualBox OSE distribution, in which case the provisions of the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# CDDL are applicable instead of those of the GPL.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# You may elect to license modified versions of this file under the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# terms and conditions of either the GPL or the CDDL or both.
50453af238fcec34bf98f91cc4c32bf57f738bd3vboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
f2490dbf97c8247439446844458461b00e50beb0vboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
35d8d2372afb180daa0ba01af33a1922511d6b07vboxsync# additional information or have any questions.
d5bf937d132098565e18a0d1fc408fb777c5e5b6vboxsync# First, figure out which architecture we're targeting and the build type.
21293ca6a2967f796ed30a6c8492911619476a48vboxsync# (We have to support basic cross building (ARCH=i386|x86_64).)
d5bf937d132098565e18a0d1fc408fb777c5e5b6vboxsync# While at it, warn about BUILD_* vars found to help with user problems.
d5bf937d132098565e18a0d1fc408fb777c5e5b6vboxsyncifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
d5bf937d132098565e18a0d1fc408fb777c5e5b6vboxsync $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
f7c0f913c4c22ee18059ff97055442566d0f14a1vboxsync ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsyncifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# use vm_insert_page() API (if available) to map kernel pages to userland - better debugging
f2490dbf97c8247439446844458461b00e50beb0vboxsync# override is required by the Debian guys
b8ae33177906f4130b85b7c861cae0e78ed4859bvboxsync # building from this directory
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync # kernel base directory
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync # build for the current kernel, version check
b8ae33177906f4130b85b7c861cae0e78ed4859bvboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
d76ca6cbea4e45aa218c74e33c784bde5e997ffcvboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
d76ca6cbea4e45aa218c74e33c784bde5e997ffcvboxsync $(error Error: unable to find the sources of your current Linux kernel. \
d76ca6cbea4e45aa218c74e33c784bde5e997ffcvboxsync $(warning Warning: using /usr/src/linux as the source directory of your \
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync # check if versions match -- works only for later 2.6 kernels
35d8d2372afb180daa0ba01af33a1922511d6b07vboxsync VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) kernelrelease 2> /dev/null || true)
35d8d2372afb180daa0ba01af33a1922511d6b07vboxsync $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
21293ca6a2967f796ed30a6c8492911619476a48vboxsync # build for a dedicated kernel, no version check
21293ca6a2967f796ed30a6c8492911619476a48vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2c1d8cd8efdd4c486ff681135035d24111b03af8vboxsync $(error Error: KERN_DIR does not point to a directory)
f2490dbf97c8247439446844458461b00e50beb0vboxsync ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
f2490dbf97c8247439446844458461b00e50beb0vboxsync $(error Error: unable to find the include directory for your current Linux \
f2490dbf97c8247439446844458461b00e50beb0vboxsync kernel. Specify KERN_INCL=<directory> and run Make again)
f2490dbf97c8247439446844458461b00e50beb0vboxsync # module install dir, only for current kernel
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
db85b6b8ce514217c1fb35d04b0854a65dc299f3vboxsync ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync $(error Unable to find the folder to install the support driver to)
40becad9511726726c5959a8ad8b62fb3e1c020cvboxsync # guess kernel version (24 or 26)
40becad9511726726c5959a8ad8b62fb3e1c020cvboxsync KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
50453af238fcec34bf98f91cc4c32bf57f738bd3vboxsyncelse # neq($(KERNELRELEASE),)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync # building from kbuild (make -C <kernel_directory> M=`pwd`)
f32de6c198a491c28ace2b4c53f8d04a79fd6d69vboxsync # guess kernel version (24 or 26)
f32de6c198a491c28ace2b4c53f8d04a79fd6d69vboxsync KERN_VERSION := $(if $(wildcard $(PWD)/Rules.make),24,26)
c4d6c81bd0de216d0f42db2e477b1d788fbaefb4vboxsync# debug - show guesses.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# Compiler options
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsyncKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync # must be consistent with Config.kmk!
611af5c9fc04865215e86b6e4906c9dfdfb6a381vboxsync # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
d07e901177d22a8f66c66f155c423a524ac07776vboxsync# By default we use remap_pfn_range() kernel API to make kernel pages
d07e901177d22a8f66c66f155c423a524ac07776vboxsync# visible for userland. Unfortuately, it leads to situation that
d07e901177d22a8f66c66f155c423a524ac07776vboxsync# during debug session all structures on that page (such as PVM pointer)
d07e901177d22a8f66c66f155c423a524ac07776vboxsync# are not accessible to the debugger (see #3214).
f48fe310f85f13db0140bef980de1f56c2007957vboxsync# This code enables experimental support
f48fe310f85f13db0140bef980de1f56c2007957vboxsync# for vm_insert_page() kernel API, allowing to export kernel pages
f48fe310f85f13db0140bef980de1f56c2007957vboxsync# to the userland in more debugger-friendly way. Due to stability
f48fe310f85f13db0140bef980de1f56c2007957vboxsync# concerns, not enabled by default yet.
4831e82ecaa3c813398d2f343e9d38ee34a3acf4vboxsync# 2.6 and later
f9cac318205d74ee5b35dabcf2bd39118f6293d7vboxsync# build defs
db85b6b8ce514217c1fb35d04b0854a65dc299f3vboxsync $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
3221ae1f7bf53d9cccdd578099f55f782dba1447vboxsync# 2.4 Module linking