Makefile revision 78df3a3ca20e014e0d9eb72cd7bb72711255d5f6
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# $Revision$
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# VirtualBox Guest Additions Module Makefile.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# Copyright (C) 2006-2009 Sun Microsystems, Inc.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# This file is part of VirtualBox Open Source Edition (OSE), as
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# available from http://www.virtualbox.org. This file is free software;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# you can redistribute it and/or modify it under the terms of the GNU
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# General Public License (GPL) as published by the Free Software
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# Foundation, in version 2 as it comes in the "COPYING" file of the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# Clara, CA 95054 USA or visit http://www.sun.com if you need
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# additional information or have any questions.
b5353d912e615fb002628d16835832e79668c442Abhinandan Ekande# First, figure out which architecture we're targeting and the build type.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# (We have to support basic cross building (ARCH=i386|x86_64).)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# While at it, warn about BUILD_* vars found to help with user problems.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# override is required by the Debian guys
b5353d912e615fb002628d16835832e79668c442Abhinandan Ekande r0drv/linux/mpnotification-r0drv-linux.o \
b5353d912e615fb002628d16835832e79668c442Abhinandan Ekande r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo # building from this directory
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo # kernel base directory
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(error Error: unable to find the sources of your current Linux kernel. \
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(warning Warning: using /usr/src/linux as the source directory of your \
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(error Error: KERN_DIR does not point to a directory)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(error Error: unable to find the include directory for your current Linux \
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kernel. Specify KERN_INCL=<directory> and run Make again)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo # module install dir, only for current kernel
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(error Unable to find the folder to install the additions driver to)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo # guess kernel version (24 or 26)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoelse # neq($(KERNELRELEASE),)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo # building from kbuild (make -C <kernel_directory> M=`pwd`)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo # guess kernel version (24 or 26)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# debug - show guesses.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# Compiler options
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 \
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoCFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# 2.4 Module linking
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# 2.6 and later
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo# build defs
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo for f in . linux r0drv r0drv/linux r0drv/generic VBox common/err common/string common/log generic common/math/gcc; \