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