Makefile revision d67d8d3162b0d9cac99842fc7da74e8371453046
18920d790825d96ca3943aa2dcb6eb80dc611c5fTinderbox User# VirtualBox Guest Additions Module Makefile.
e9e4257668ff6c4e583b0c0db2508650b0b677b8Tinderbox User# Copyright (C) 2006-2009 Sun Microsystems, Inc.
5e047890ac9b745db060d95f7d1b4f876511240dTinderbox User# This file is part of VirtualBox Open Source Edition (OSE), as
137fdbc214e99c4cbe57551e9e14f2015c2e42aeTinderbox User# available from http://www.virtualbox.org. This file is free software;
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User# you can redistribute it and/or modify it under the terms of the GNU
bed0874e1a09e810575328c4bfc346a47514b69fMark Andrews# General Public License (GPL) as published by the Free Software
02b47c5d62e1e827743684c28a08e871da454a2dMark Andrews# Foundation, in version 2 as it comes in the "COPYING" file of the
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e20309353e6246485c521278131d3fced73d7957Tinderbox User# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Clara, CA 95054 USA or visit http://www.sun.com if you need
9a5217f827ac0e006016745e5305b31dc0c7767fTinderbox User# additional information or have any questions.
e20309353e6246485c521278131d3fced73d7957Tinderbox User# First, figure out which architecture we're targeting and the build type.
e20309353e6246485c521278131d3fced73d7957Tinderbox User# (We have to support basic cross building (ARCH=i386|x86_64).)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# While at it, warn about BUILD_* vars found to help with user problems.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrewsifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrewsifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Huntifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
24934f08b9ff81c2be711e566e8002d145573031Tinderbox User $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# override is required by the Debian guys
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont # building from this directory
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User # kernel base directory
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews KERN_DIR := /lib/modules/$(shell uname -r)/build
bed0874e1a09e810575328c4bfc346a47514b69fMark Andrews ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews $(error Error: unable to find the sources of your current Linux kernel. \
2ba8f584b97cbab864570e38fd26b8cb90961428Tinderbox User Specify KERN_DIR=<directory> and run Make again)
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews $(warning Warning: using /usr/src/linux as the source directory of your \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews Linux kernel. If this is not correct, specify \
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews $(error Error: KERN_DIR does not point to a directory)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews $(error Error: unable to find the include directory for your current Linux \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews kernel. Specify KERN_INCL=<directory> and run Make again)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # module install dir, only for current kernel
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
e16b482740c5e7ad4c27e271fa829b957cdf67d4Mark Andrews MODULE_DIR_TST := /lib/modules/$(shell uname -r)
fa0326cc2cf428f67575b6ba3b97b528a31b0010Tinderbox User ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews $(error Unable to find the folder to install the additions driver to)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # guess kernel version (24 or 26)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrewselse # neq($(KERNELRELEASE),)
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater # building from kbuild (make -C <kernel_directory> M=`pwd`)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # guess kernel version (24 or 26)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# debug - show guesses.
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# Compiler options
c7ef13f6c9ef4436bc804b150e0a93307b11fa27Tinderbox User INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
d642d3857129678797a01adee14fbd70335b05a9Mark Andrews INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 \
8e5fce1f9ceba17dd7e3ff0eb287e1e999c14249Mark Andrews -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM
8711e5c73ca872d59810760af0332194cbdd619bAutomatic Updater KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic UpdaterCFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater# 2.4 Module linking
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# 2.6 and later
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic UpdaterEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updater $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
27c3c21f41520e8d6336d80a8094389e321cb6d2Mark Andrews install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
f751b1576ee6fef4023bf7101d10167e4fe520f3Tinderbox User for f in . linux r0drv r0drv/linux VBox common/err common/string common/log generic common/math/gcc; \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done