Makefile revision 00019d7a7381b029a3c17229f14c24a3a7b07a94
2N/A#
2N/A# Makefile for the VirtualBox Linux Host Virtual Network Adapter Driver.
2N/A# (For 2.6.x this file must be called 'Makefile'!)
2N/A#
2N/A
2N/A#
2N/A#
2N/A# Copyright (C) 2006-2010 Oracle Corporation
2N/A#
2N/A# This file is part of VirtualBox Open Source Edition (OSE), as
2N/A# available from http://www.virtualbox.org. This file is free software;
2N/A# you can redistribute it and/or modify it under the terms of the GNU
2N/A# General Public License (GPL) as published by the Free Software
2N/A# Foundation, in version 2 as it comes in the "COPYING" file of the
2N/A# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2N/A# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2N/A#
2N/A
2N/A#
2N/A# First, figure out which architecture we're targeting and the build type.
2N/A# (We have to support basic cross building (ARCH=i386|x86_64).)
2N/A# While at it, warn about BUILD_* vars found to help with user problems.
2N/A#
2N/Aifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
2N/A BUILD_TARGET_ARCH_DEF := amd64
2N/Aelse
2N/A BUILD_TARGET_ARCH_DEF := x86
2N/Aendif
2N/Aifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
2N/A $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
2N/A BUILD_TARGET_ARCH :=
2N/Aendif
2N/Aifeq ($(BUILD_TARGET_ARCH),)
2N/A ifeq ($(ARCH),x86_64)
2N/A BUILD_TARGET_ARCH := amd64
2N/A else
2N/A ifeq ($(ARCH),i386)
2N/A BUILD_TARGET_ARCH := x86
2N/A else
2N/A BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
2N/A endif
2N/A endif
2N/Aelse
2N/A ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
2N/A $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
2N/A endif
2N/Aendif
2N/A
2N/Aifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
2N/A $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
2N/A BUILD_TYPE :=
2N/Aendif
2N/Aifeq ($(BUILD_TYPE),)
2N/A BUILD_TYPE := release
2N/Aelse
2N/A ifneq ($(BUILD_TYPE),release)
2N/A $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
2N/A endif
2N/Aendif
2N/A
2N/A# override is required by the Debian guys
2N/Aoverride MODULE = vboxnetadp
2N/AOBJS = \
2N/A linux/VBoxNetAdp-linux.o \
2N/A VBoxNetAdp.o
2N/Aifeq ($(BUILD_TARGET_ARCH),x86)
2N/AOBJS += math/gcc/divdi3.o \
2N/A math/gcc/moddi3.o \
2N/A math/gcc/qdivrem.o \
2N/A math/gcc/udivdi3.o \
2N/A math/gcc/divdi3.o \
2N/A math/gcc/umoddi3.o
2N/Aendif
2N/A
2N/Aifneq ($(MAKECMDGOALS),clean)
2N/A
2N/Aifeq ($(KERNELRELEASE),)
2N/A
2N/A #
2N/A # building from this directory
2N/A #
2N/A
2N/A # kernel base directory
2N/A ifndef KERN_DIR
2N/A # build for the current kernel, version check
2N/A KERN_DIR := /lib/modules/$(shell uname -r)/build
2N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2N/A KERN_DIR := /usr/src/linux
2N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2N/A $(error Error: unable to find the sources of your current Linux kernel. \
2N/A Specify KERN_DIR=<directory> and run Make again)
2N/A endif
2N/A $(warning Warning: using /usr/src/linux as the source directory of your \
2N/A Linux kernel. If this is not correct, specify \
2N/A KERN_DIR=<directory> and run Make again.)
2N/A endif
2N/A else
2N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2N/A $(error Error: KERN_DIR does not point to a directory)
2N/A endif
2N/A endif
2N/A
2N/A # includes
2N/A ifndef KERN_INCL
2N/A KERN_INCL = $(KERN_DIR)/include
2N/A endif
2N/A ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
2N/A $(error Error: unable to find the include directory for your current Linux \
2N/A kernel. Specify KERN_INCL=<directory> and run Make again)
2N/A endif
2N/A
2N/A # module install dir, only for current kernel
2N/A ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
2N/A ifndef MODULE_DIR
2N/A MODULE_DIR_TST := /lib/modules/$(shell uname -r)
2N/A ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
2N/A MODULE_DIR := $(MODULE_DIR_TST)/misc
2N/A else
2N/A $(error Unable to find the folder to install the support driver to)
2N/A endif
2N/A endif # MODULE_DIR unspecified
2N/A endif
2N/A
2N/Aelse # neq($(KERNELRELEASE),)
2N/A
2N/A #
2N/A # building from kbuild (make -C <kernel_directory> M=`pwd`)
2N/A #
2N/A
2N/Aendif # neq($(KERNELRELEASE),)
2N/A
2N/A# debug - show guesses.
2N/Aifdef DEBUG
2N/A$(warning dbg: KERN_DIR = $(KERN_DIR))
2N/A$(warning dbg: KERN_INCL = $(KERN_INCL))
2N/A$(warning dbg: MODULE_DIR = $(MODULE_DIR))
2N/Aendif
2N/A
2N/AKBUILD_VERBOSE ?= 1
2N/A
2N/A#
2N/A# Compiler options
2N/A#
2N/Aifndef INCL
2N/A INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
2N/A ifndef KBUILD_EXTMOD
2N/A KBUILD_EXTMOD := $(shell pwd)
2N/A endif
2N/A INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
2N/A INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxnetadp,/ /include /r0drv/linux)
2N/A export INCL
2N/Aendif
2N/Aifneq ($(wildcard $(KBUILD_EXTMOD)/vboxnetadp),)
2N/A MANGLING := $(KBUILD_EXTMOD)/vboxnetadp/include/VBox/SUPDrvMangling.h
2N/Aelse
2N/A MANGLING := $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h
2N/Aendif
2N/AKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
2N/A -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
2N/Aifdef VBOX_REDHAT_KABI
2N/A KFLAGS += -DVBOX_REDHAT_KABI
2N/Aendif
2N/Aifeq ($(BUILD_TARGET_ARCH),amd64)
2N/A KFLAGS += -DRT_ARCH_AMD64
2N/Aelse
2N/A KFLAGS += -DRT_ARCH_X86
2N/Aendif
2N/A# must be consistent with Config.kmk!
2N/AKFLAGS += -DVBOX_WITH_64_BITS_GUESTS
2N/Aifeq ($(BUILD_TYPE),debug)
2N/A KFLAGS += -DDEBUG -DDEBUG_$(USER) -g
2N/A # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
2N/A #KFLAGS += -DIPRT_DEBUG_SEMS
2N/Aendif
2N/A
2N/A# By default we use remap_pfn_range() kernel API to make kernel pages
2N/A# visible for userland. Unfortunately, it leads to situation that
2N/A# during debug session all structures on that page (such as PVM pointer)
2N/A# are not accessible to the debugger (see #3214).
2N/A# This code enables experimental support
2N/A# for vm_insert_page() kernel API, allowing to export kernel pages
2N/A# to the userland in more debugger-friendly way. Due to stability
2N/A# concerns, not enabled by default yet.
2N/Aifdef VBOX_USE_INSERT_PAGE
2N/A KFLAGS += -DVBOX_USE_INSERT_PAGE
2N/Aendif
2N/A
2N/AMODULE_EXT := ko
2N/A$(MODULE)-y := $(OBJS)
2N/A
2N/A# build defs
2N/AEXTRA_CFLAGS += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG)
2N/A
2N/Aall: $(MODULE)
2N/A
2N/Aobj-m += $(MODULE).o
2N/A
2N/A# OL/UEK: disable module signing for external modules -- we don't have any private key
2N/A$(MODULE):
2N/A $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) CONFIG_MODULE_SIG= -C $(KERN_DIR) modules
2N/A
2N/Ainstall: $(MODULE)
2N/A @mkdir -p $(MODULE_DIR); \
2N/A install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
2N/A PATH="$(PATH):/bin:/sbin" depmod -a; \
2N/A rm -f /etc/vbox/module_not_compiled
2N/A
2N/Ainstall_rpm: $(MODULE)
2N/A @mkdir -p $(MODULE_DIR); \
2N/A install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
2N/A
2N/Aelse # eq ($(MAKECMDGOALS),clean)
2N/A
2N/A ifndef KERN_DIR
2N/A KERN_DIR := /lib/modules/$(shell uname -r)/build
2N/A ifeq ($(wildcard $(KERN_DIR)/Makefile),)
2N/A KERN_DIR := /usr/src/linux
2N/A endif
2N/A endif
2N/A ifeq ($(wildcard $(KERN_DIR)/Makefile),)
2N/A
2N/Aclean:
2N/A find . \( -name \*.o -o -name \*.cmd \) -print0 | xargs -0 rm -f
2N/A rm -rf .tmp_ver* $(MODULE).* Module.symvers Modules.symvers modules.order
2N/A
2N/A else
2N/A
2N/Aclean:
2N/A $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) clean
2N/A
2N/A endif
2N/A
2N/Aendif # eq($(MAKECMDGOALS),clean)
2N/A