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