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