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