Makefile revision 6c90795355c6e59ba82e8e5a58e10d686a6d6e65
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# Makefile for the VirtualBox Linux Host Virtual Network Adapter Driver.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# (For 2.6.x this file must be called 'Makefile'!)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# Copyright (C) 2006-2007 Sun Microsystems, Inc.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# available from http://www.virtualbox.org. This file is free software;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# you can redistribute it and/or modify it under the terms of the GNU
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# General Public License (GPL) as published by the Free Software
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# additional information or have any questions.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# First, figure out which architecture we're targeting and the build type.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# (We have to support basic cross building (ARCH=i386|x86_64).)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# While at it, warn about BUILD_* vars found to help with user problems.
9040f019271f91b98e1320c0a8c38a42636e3979vboxsyncifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# override is required by the Debian guys
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync # building from this directory
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync # kernel base directory
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync # build for the current kernel, version check
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(error Error: unable to find the sources of your current Linux kernel. \
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(warning Warning: using /usr/src/linux as the source directory of your \
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync # check if versions match -- works only for later 2.6 kernels
6c90795355c6e59ba82e8e5a58e10d686a6d6e65vboxsync VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync # build for a dedicated kernel, no version check
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(error Error: KERN_DIR does not point to a directory)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(error Error: unable to find the include directory for your current Linux \
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync kernel. Specify KERN_INCL=<directory> and run Make again)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync # module install dir, only for current kernel
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(error Unable to find the folder to install the support driver to)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncelse # neq($(KERNELRELEASE),)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync # building from kbuild (make -C <kernel_directory> M=`pwd`)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# debug - show guesses.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# Compiler options
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# must be consistent with Config.kmk!
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# By default we use remap_pfn_range() kernel API to make kernel pages
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# visible for userland. Unfortuately, it leads to situation that
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# during debug session all structures on that page (such as PVM pointer)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# are not accessible to the debugger (see #3214).
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# This code enables experimental support
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# for vm_insert_page() kernel API, allowing to export kernel pages
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# to the userland in more debugger-friendly way. Due to stability
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# concerns, not enabled by default yet.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# build defs
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync for f in . linux r0drv r0drv/linux VBox common/err common/string common/log generic math/gcc; \