Makefile revision ab455939477d81b7bb500586f88029d3a3c0b34c
080575042aba2197b425ebfd52061dea061a9aa1xy# $Revision$
080575042aba2197b425ebfd52061dea061a9aa1xy# Makefile for the VirtualBox Linux Host Driver.
080575042aba2197b425ebfd52061dea061a9aa1xy# Copyright (C) 2006-2010 Oracle Corporation
080575042aba2197b425ebfd52061dea061a9aa1xy# This file is part of VirtualBox Open Source Edition (OSE), as
080575042aba2197b425ebfd52061dea061a9aa1xy# available from http://www.virtualbox.org. This file is free software;
080575042aba2197b425ebfd52061dea061a9aa1xy# you can redistribute it and/or modify it under the terms of the GNU
080575042aba2197b425ebfd52061dea061a9aa1xy# General Public License (GPL) as published by the Free Software
080575042aba2197b425ebfd52061dea061a9aa1xy# Foundation, in version 2 as it comes in the "COPYING" file of the
080575042aba2197b425ebfd52061dea061a9aa1xy# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
080575042aba2197b425ebfd52061dea061a9aa1xy# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
080575042aba2197b425ebfd52061dea061a9aa1xy# The contents of this file may alternatively be used under the terms
080575042aba2197b425ebfd52061dea061a9aa1xy# of the Common Development and Distribution License Version 1.0
080575042aba2197b425ebfd52061dea061a9aa1xy# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
47b7744cbea59975a6b583125b7ed1ff2ac45313yy# VirtualBox OSE distribution, in which case the provisions of the
080575042aba2197b425ebfd52061dea061a9aa1xy# CDDL are applicable instead of those of the GPL.
080575042aba2197b425ebfd52061dea061a9aa1xy# You may elect to license modified versions of this file under the
080575042aba2197b425ebfd52061dea061a9aa1xy# terms and conditions of either the GPL or the CDDL or both.
080575042aba2197b425ebfd52061dea061a9aa1xy# First, figure out which architecture we're targeting and the build type.
080575042aba2197b425ebfd52061dea061a9aa1xy# (We have to support basic cross building (ARCH=i386|x86_64).)
080575042aba2197b425ebfd52061dea061a9aa1xy# While at it, warn about BUILD_* vars found to help with user problems.
080575042aba2197b425ebfd52061dea061a9aa1xyifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
080575042aba2197b425ebfd52061dea061a9aa1xy $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
080575042aba2197b425ebfd52061dea061a9aa1xy $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
080575042aba2197b425ebfd52061dea061a9aa1xyifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
080575042aba2197b425ebfd52061dea061a9aa1xy $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
080575042aba2197b425ebfd52061dea061a9aa1xy $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
080575042aba2197b425ebfd52061dea061a9aa1xy# override is required by the Debian guys
080575042aba2197b425ebfd52061dea061a9aa1xy # building from this directory
080575042aba2197b425ebfd52061dea061a9aa1xy # kernel base directory
080575042aba2197b425ebfd52061dea061a9aa1xy # build for the current kernel, version check
080575042aba2197b425ebfd52061dea061a9aa1xy ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
080575042aba2197b425ebfd52061dea061a9aa1xy ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
080575042aba2197b425ebfd52061dea061a9aa1xy $(error Error: unable to find the sources of your current Linux kernel. \
080575042aba2197b425ebfd52061dea061a9aa1xy $(warning Warning: using /usr/src/linux as the source directory of your \
080575042aba2197b425ebfd52061dea061a9aa1xy ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
080575042aba2197b425ebfd52061dea061a9aa1xy # includes
080575042aba2197b425ebfd52061dea061a9aa1xy ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
080575042aba2197b425ebfd52061dea061a9aa1xy $(error Error: unable to find the include directory for your current Linux \
080575042aba2197b425ebfd52061dea061a9aa1xy kernel. Specify KERN_INCL=<directory> and run Make again)
080575042aba2197b425ebfd52061dea061a9aa1xy # module install dir, only for current kernel
080575042aba2197b425ebfd52061dea061a9aa1xy ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
080575042aba2197b425ebfd52061dea061a9aa1xy $(error Unable to find the folder to install the support driver to)
080575042aba2197b425ebfd52061dea061a9aa1xyelse # neq($(KERNELRELEASE),)
080575042aba2197b425ebfd52061dea061a9aa1xy # building from kbuild (make -C <kernel_directory> M=`pwd`)
080575042aba2197b425ebfd52061dea061a9aa1xy# debug - show guesses.
080575042aba2197b425ebfd52061dea061a9aa1xy# Compiler options
080575042aba2197b425ebfd52061dea061a9aa1xy INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
080575042aba2197b425ebfd52061dea061a9aa1xy INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxdrv,/ /include /r0drv/linux)
080575042aba2197b425ebfd52061dea061a9aa1xy MANGLING := $(KBUILD_EXTMOD)/vboxdrv/include/VBox/SUPDrvMangling.h
080575042aba2197b425ebfd52061dea061a9aa1xy MANGLING := $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h
080575042aba2197b425ebfd52061dea061a9aa1xyKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
080575042aba2197b425ebfd52061dea061a9aa1xy# must be consistent with Config.kmk!
080575042aba2197b425ebfd52061dea061a9aa1xy # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
080575042aba2197b425ebfd52061dea061a9aa1xy #KFLAGS += -DIPRT_DEBUG_SEMS
080575042aba2197b425ebfd52061dea061a9aa1xy# 2.6 and later
080575042aba2197b425ebfd52061dea061a9aa1xy# build defs
080575042aba2197b425ebfd52061dea061a9aa1xyEXTRA_CFLAGS += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG)
080575042aba2197b425ebfd52061dea061a9aa1xy $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) modules
080575042aba2197b425ebfd52061dea061a9aa1xy install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
080575042aba2197b425ebfd52061dea061a9aa1xyelse # eq ($(MAKECMDGOALS),clean)
080575042aba2197b425ebfd52061dea061a9aa1xy find . \( -name \*.o -o -name \*.cmd \) -print0 | xargs -0 rm -f
080575042aba2197b425ebfd52061dea061a9aa1xy rm -rf .tmp_ver* $(MODULE).* Module.symvers Modules.symvers modules.order
080575042aba2197b425ebfd52061dea061a9aa1xy $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) clean
080575042aba2197b425ebfd52061dea061a9aa1xy @if ! readelf -p __ksymtab_strings vboxdrv.ko | grep -E "\[.*\] *(RT|g_..*RT.*)"; then \
080575042aba2197b425ebfd52061dea061a9aa1xy echo "All exported IPRT symbols are properly renamed!"; \
080575042aba2197b425ebfd52061dea061a9aa1xy echo "error: Some exported IPRT symbols was not properly renamed! See above." >&2; \