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