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