Makefile revision 0280e4ae13799a3136778dc90efa5841a3f40cf2
8495845a800cf09321436aed996188c9a92cd647bnicholes# Makefile for the VirtualBox Linux Host Driver.
8495845a800cf09321436aed996188c9a92cd647bnicholes# Copyright (C) 2006-2007 Sun Microsystems, Inc.
8495845a800cf09321436aed996188c9a92cd647bnicholes# This file is part of VirtualBox Open Source Edition (OSE), as
8495845a800cf09321436aed996188c9a92cd647bnicholes# available from http://www.virtualbox.org. This file is free software;
8495845a800cf09321436aed996188c9a92cd647bnicholes# you can redistribute it and/or modify it under the terms of the GNU
8495845a800cf09321436aed996188c9a92cd647bnicholes# General Public License (GPL) as published by the Free Software
8495845a800cf09321436aed996188c9a92cd647bnicholes# Foundation, in version 2 as it comes in the "COPYING" file of the
8495845a800cf09321436aed996188c9a92cd647bnicholes# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8495845a800cf09321436aed996188c9a92cd647bnicholes# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8495845a800cf09321436aed996188c9a92cd647bnicholes# The contents of this file may alternatively be used under the terms
8495845a800cf09321436aed996188c9a92cd647bnicholes# of the Common Development and Distribution License Version 1.0
8495845a800cf09321436aed996188c9a92cd647bnicholes# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8495845a800cf09321436aed996188c9a92cd647bnicholes# VirtualBox OSE distribution, in which case the provisions of the
8495845a800cf09321436aed996188c9a92cd647bnicholes# CDDL are applicable instead of those of the GPL.
8495845a800cf09321436aed996188c9a92cd647bnicholes# You may elect to license modified versions of this file under the
8495845a800cf09321436aed996188c9a92cd647bnicholes# terms and conditions of either the GPL or the CDDL or both.
8495845a800cf09321436aed996188c9a92cd647bnicholes# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
8495845a800cf09321436aed996188c9a92cd647bnicholes# Clara, CA 95054 USA or visit http://www.sun.com if you need
8495845a800cf09321436aed996188c9a92cd647bnicholes# additional information or have any questions.
8495845a800cf09321436aed996188c9a92cd647bnicholes# First, figure out which architecture we're targeting and the build type.
8495845a800cf09321436aed996188c9a92cd647bnicholes# (We have to support basic cross building (ARCH=i386|x86_64).)
8495845a800cf09321436aed996188c9a92cd647bnicholes# While at it, warn about BUILD_* vars found to help with user problems.
8495845a800cf09321436aed996188c9a92cd647bnicholesifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
8495845a800cf09321436aed996188c9a92cd647bnicholesifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
8495845a800cf09321436aed996188c9a92cd647bnicholes $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
8495845a800cf09321436aed996188c9a92cd647bnicholes ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
8495845a800cf09321436aed996188c9a92cd647bnicholes $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
de2feca197f3b0aaff5c201dffda04aea8a47adcfuankgifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
8495845a800cf09321436aed996188c9a92cd647bnicholes $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
8495845a800cf09321436aed996188c9a92cd647bnicholes $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
8495845a800cf09321436aed996188c9a92cd647bnicholes# override is required by the Debian guys
8495845a800cf09321436aed996188c9a92cd647bnicholes # building from this directory
fd780f0b6767d731e4b45c03dbbe9b9c1cbd2a8dbnicholes # kernel base directory
fd780f0b6767d731e4b45c03dbbe9b9c1cbd2a8dbnicholes # build for the current kernel, version check
fd780f0b6767d731e4b45c03dbbe9b9c1cbd2a8dbnicholes ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
fd780f0b6767d731e4b45c03dbbe9b9c1cbd2a8dbnicholes ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
fd780f0b6767d731e4b45c03dbbe9b9c1cbd2a8dbnicholes $(error Error: unable to find the sources of your current Linux kernel. \
fa296e0ab15d4d7e59d657c16acef0fd10e4affdbnicholes $(warning Warning: using /usr/src/linux as the source directory of your \
de2feca197f3b0aaff5c201dffda04aea8a47adcfuankg # check if versions match -- works only for later 2.6 kernels
8495845a800cf09321436aed996188c9a92cd647bnicholes VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
8495845a800cf09321436aed996188c9a92cd647bnicholes $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
8495845a800cf09321436aed996188c9a92cd647bnicholes # build for a dedicated kernel, no version check
8495845a800cf09321436aed996188c9a92cd647bnicholes ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
8495845a800cf09321436aed996188c9a92cd647bnicholes $(error Error: KERN_DIR does not point to a directory)
8495845a800cf09321436aed996188c9a92cd647bnicholes ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
8495845a800cf09321436aed996188c9a92cd647bnicholes $(error Error: unable to find the include directory for your current Linux \
8495845a800cf09321436aed996188c9a92cd647bnicholes kernel. Specify KERN_INCL=<directory> and run Make again)
8495845a800cf09321436aed996188c9a92cd647bnicholes # module install dir, only for current kernel
8495845a800cf09321436aed996188c9a92cd647bnicholes ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
8495845a800cf09321436aed996188c9a92cd647bnicholes ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
8495845a800cf09321436aed996188c9a92cd647bnicholes $(error Unable to find the folder to install the support driver to)
8495845a800cf09321436aed996188c9a92cd647bnicholeselse # neq($(KERNELRELEASE),)
8495845a800cf09321436aed996188c9a92cd647bnicholes # building from kbuild (make -C <kernel_directory> M=`pwd`)
8495845a800cf09321436aed996188c9a92cd647bnicholes# debug - show guesses.
8495845a800cf09321436aed996188c9a92cd647bnicholes# Compiler options
8495845a800cf09321436aed996188c9a92cd647bnicholes INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
8495845a800cf09321436aed996188c9a92cd647bnicholes INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
8495845a800cf09321436aed996188c9a92cd647bnicholesKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
8495845a800cf09321436aed996188c9a92cd647bnicholes# must be consistent with Config.kmk!
8495845a800cf09321436aed996188c9a92cd647bnicholes # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
8495845a800cf09321436aed996188c9a92cd647bnicholes# 2.6 and later
$(MODULE):