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