Makefile revision 7eaaa8a4480370b82ef3735994f986f338fb4df2
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Makefile for the VirtualBox Linux Host Driver.
b60271016957475ef5d675f8a5a116a661b46b82David Lawrence# Copyright (C) 2006-2010 Oracle Corporation
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# This file is part of VirtualBox Open Source Edition (OSE), as
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# available from http://www.virtualbox.org. This file is free software;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# you can redistribute it and/or modify it under the terms of the GNU
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# General Public License (GPL) as published by the Free Software
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# Foundation, in version 2 as it comes in the "COPYING" file of the
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# The contents of this file may alternatively be used under the terms
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# of the Common Development and Distribution License Version 1.0
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
bff64bf12b58a6f80e740e94f2e42a32df18113aEvan Hunt# VirtualBox OSE distribution, in which case the provisions of the
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# CDDL are applicable instead of those of the GPL.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# You may elect to license modified versions of this file under the
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# terms and conditions of either the GPL or the CDDL or both.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# First, figure out which architecture we're targeting and the build type.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# (We have to support basic cross building (ARCH=i386|x86_64).)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# While at it, warn about BUILD_* vars found to help with user problems.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
7eab320180831eeb2bc1e42114b2ae30905513dfBob Halley# override is required by the Debian guys
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # building from this directory
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # kernel base directory
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # build for the current kernel, version check
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(error Error: unable to find the sources of your current Linux kernel. \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(warning Warning: using /usr/src/linux as the source directory of your \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # check if versions match -- works only for later 2.6 kernels
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
5eb91bd90e3ad3426e5e3213031556a737cf3809Mark Andrews $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # build for a dedicated kernel, no version check
5eb91bd90e3ad3426e5e3213031556a737cf3809Mark Andrews ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(error Error: KERN_DIR does not point to a directory)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(error Error: unable to find the include directory for your current Linux \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley kernel. Specify KERN_INCL=<directory> and run Make again)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # module install dir, only for current kernel
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
export INCL
KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
# must be consistent with Config.kmk!
$(MODULE):