Makefile revision ad27e1d5e48ca41245120c331cc88b50464813ce
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# Makefile for the VirtualBox Linux Host Virtual Network Adapter Driver.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# (For 2.6.x this file must be called 'Makefile'!)
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync# Copyright (C) 2006-2010 Oracle Corporation
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# 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)
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxnetadp,/ /include /r0drv/linux)
479124979f37167f8ce75bf59090903d30e1ced3vboxsyncKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
479124979f37167f8ce75bf59090903d30e1ced3vboxsync -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.
88e9d91abf9293ecc1c70e0bf40e42f1c3a0bdcevboxsync #KFLAGS += -DIPRT_DEBUG_SEMS
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync# By default we use remap_pfn_range() kernel API to make kernel pages
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync# visible for userland. Unfortunately, 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
479124979f37167f8ce75bf59090903d30e1ced3vboxsync $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) modules
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
bbf3d430bae83177ab9ce3097f49d89cc873e7c0vboxsyncelse # eq ($(MAKECMDGOALS),clean)
bbf3d430bae83177ab9ce3097f49d89cc873e7c0vboxsync find . \( -name \*.o -o -name \*.cmd \) -print0 | xargs -0 rm -f
bbf3d430bae83177ab9ce3097f49d89cc873e7c0vboxsync rm -rf .tmp_ver* $(MODULE).* Module.symvers Modules.symvers modules.order