Makefile revision 623f56b78e24ab3154f4a00c7bc8bb43579878c5
7a2a1b8b14fc804ac80612d7b98064095e445be5Automatic Updater# Makefile for the VirtualBox Linux Host Driver.
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User# Copyright (C) 2006-2007 Sun Microsystems, Inc.
79b273c187a4aa1016a62181983dfdd0521681aeMark Andrews# This file is part of VirtualBox Open Source Edition (OSE), as
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User# available from http://www.virtualbox.org. This file is free software;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# you can redistribute it and/or modify it under the terms of the GNU
b253dcf9668f95e141bce9556dc88e30d3305a1dTinderbox User# General Public License (GPL) as published by the Free Software
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# Foundation, in version 2 as it comes in the "COPYING" file of the
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1ac49378a458420bc685293d12e567d7222d17b6Tinderbox User# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# The contents of this file may alternatively be used under the terms
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater# of the Common Development and Distribution License Version 1.0
3cc98b8ecedcbc8465f1cf2740b966b315662430Automatic Updater# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# VirtualBox OSE distribution, in which case the provisions of the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# CDDL are applicable instead of those of the GPL.
89623368b8f662d458d9964b923050f33c5f75b0Tinderbox User# You may elect to license modified versions of this file under the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# terms and conditions of either the GPL or the CDDL or both.
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Clara, CA 95054 USA or visit http://www.sun.com if you need
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# additional information or have any questions.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# First, figure out which architecture we're targeting and the build type.
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# (We have to support basic cross building (ARCH=i386|x86_64).)
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User# While at it, warn about BUILD_* vars found to help with user problems.
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updaterifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
693c4232dfdffaff672197d4b9fea944c64cf80aAutomatic Updater# override is required by the Debian guys
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User # building from this directory
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User # kernel base directory
f132a836c4e386b1af045dd8fe7106ae61b90bffAutomatic Updater # build for the current kernel, version check
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater KERN_DIR := /lib/modules/$(shell uname -r)/build
c6a0f4ae1d7183a16ffb196b86b647f870694796Automatic Updater ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User $(error Error: unable to find the sources of your current Linux kernel. \
269519eeb959d905ed125f96426e01d725c3b597Tinderbox User Specify KERN_DIR=<directory> and run Make again)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $(warning Warning: using /usr/src/linux as the source directory of your \
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater Linux kernel. If this is not correct, specify \
4e0e18467f8ec5a9e5d0c538ce46bf07409ecf9bTinderbox User # check if versions match -- works only for later 2.6 kernels
e85565067cf73f8cc21ee29b11761659f1d47ee9Automatic Updater VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater ifneq ($(VBOX_KERN_VER),$(shell uname -r))
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater the current kernel (version $(shell uname -r)))
7f79131f9a8e804b93c57f3c679065cce878b726Automatic Updater # build for a dedicated kernel, no version check
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $(error Error: KERN_DIR does not point to a directory)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $(error Error: unable to find the include directory for your current Linux \
5ecad47f69b3fd945472ab2900a9ff826a7ce2f6Automatic Updater kernel. Specify KERN_INCL=<directory> and run Make again)
71bd43eebd9d6e42dbcae62b730f5b6508d5acd8Automatic Updater # module install dir, only for current kernel
82447d835d3ff5c658749b4e9b4f66166407b3eaAutomatic Updater ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
96ea71632887c58a9d00f47eb318bf76b35903c3Mark Andrews MODULE_DIR_TST := /lib/modules/$(shell uname -r)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater $(error Unable to find the folder to install the support driver to)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewselse # neq($(KERNELRELEASE),)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews # building from kbuild (make -C <kernel_directory> M=`pwd`)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# debug - show guesses.
cf7e98f59148b559946a7f1ca728471374f1eef3Automatic Updater# Compiler options
8711e5c73ca872d59810760af0332194cbdd619bAutomatic Updater INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
a382ca49c874d38ad3ac8995b49f9f27128e4ca9Automatic UpdaterKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User# must be consistent with Config.kmk!
0b57424d28c9a67018107133f9fbc0a7dcf057e2Mark Andrews # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
b109432c3a939bff66a463be86c371bd88efe3aaAutomatic Updater# 2.6 and later
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic UpdaterEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
b253dcf9668f95e141bce9556dc88e30d3305a1dTinderbox User for f in . linux r0drv r0drv/generic r0drv/linux VBox common/err common/string common/log generic math/gcc; \