Makefile revision 9868c07279330f31ed91aa986bec707b7e8635a3
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater# Makefile for the VirtualBox Linux Host Driver.
c78c39caab4cf8b5daefc9c65878f7f5ed3eb7a0Tinderbox User# (For 2.6.x this file must be called 'Makefile'!)
a7c412f37cc73d0332887a746e81220cbf09dd00Mark Andrews# Copyright (C) 2006-2007 innotek GmbH
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews# This file is part of VirtualBox Open Source Edition (OSE), as
8de3f14f1c300c3e1ed99084cc03485b42c92bf1Tinderbox User# available from http://www.virtualbox.org. This file is free software;
950d203b64f512b85fcc093ee1e9e3e531a1aea3Tinderbox User# you can redistribute it and/or modify it under the terms of the GNU
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# General Public License (GPL) as published by the Free Software
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews# Foundation, in version 2 as it comes in the "COPYING" file of the
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a7c412f37cc73d0332887a746e81220cbf09dd00Mark Andrews# The contents of this file may alternatively be used under the terms
a7c412f37cc73d0332887a746e81220cbf09dd00Mark Andrews# of the Common Development and Distribution License Version 1.0
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# VirtualBox OSE distribution, in which case the provisions of the
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# CDDL are applicable instead of those of the GPL.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# You may elect to license modified versions of this file under the
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# terms and conditions of either the GPL or the CDDL or both.
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# First, figure out which architecture we're targeting and the build type.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# (We have to support basic cross building (ARCH=i386|x86_64).)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# While at it, warn about BUILD_* vars found to help with user problems.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrewsifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
dc238a06bffa79de141ee7655765e2df91498a8aTinderbox User $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox Userifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
7a6494cfb6cc7d3f67af07359561e05e6bb8c0edTinderbox User r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # building from this directory
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # kernel base directory
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # build for the current kernel, version check
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User KERN_DIR := /lib/modules/$(shell uname -r)/build
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User $(error Error: unable to find the sources of your current Linux kernel. \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews Specify KERN_DIR=<directory> and run Make again)
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson $(warning Warning: using /usr/src/linux as the source directory of your \
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User Linux kernel. If this is not correct, specify \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # check if versions match -- works only for later 2.6 kernels
28a5dd720187fddb16055a0f64b63a7b66f29f64Mark Andrews VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) kernelrelease 2> /dev/null || true)
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
0e573cdd111e060e5f6c18249b5ccacbe8abe278Tinderbox User the current kernel (version $(shell uname -r)))
37d8e0a4455876fe1e4cca511076cc2c5ab9eedeTinderbox User # build for a dedicated kernel, no version check
fd972434c29fc1169d66594e4cc7697d33036c2bTinderbox User ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont $(error Error: KERN_DIR does not point to a directory)
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews $(error Error: unable to find the include directory for your current Linux \
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews kernel. Specify KERN_INCL=<directory> and run Make again)
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews # module install dir, only for current kernel
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews MODULE_DIR_TST := /lib/modules/$(shell uname -r)
dc238a06bffa79de141ee7655765e2df91498a8aTinderbox User ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
e20788e1216ed720aefa84f3295f7899d9f28c22Mark Andrews $(error Unable to find the folder to install the support driver to)
37d8e0a4455876fe1e4cca511076cc2c5ab9eedeTinderbox User # guess kernel version (24 or 26)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrewselse # neq($(KERNELRELEASE),)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # building from Linux-2.6-kbuild (make -C <kernel_directory> M=`pwd`)
fa0326cc2cf428f67575b6ba3b97b528a31b0010Tinderbox User# debug - show guesses.
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User$(warning dbg: KERN_VERSION = $(KERN_VERSION))
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# Compiler options
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox UserKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# Use the RTR0MemObj API - testing.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# If this makes testboxes crash/burn/leak disable it and add a comment to defect #2116.
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox Userifeq ($(BUILD_TARGET_ARCH),x86) # Some gcc versions ends up needing __divdi3.
7ca715ad1587a68a531ea1cdea07515d7232567eTinderbox User# 2.6 and later
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# 2.4 Module linking
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
e21f41f6504b3381be86cbe7f457f9ee1fff947bTinderbox User install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
dc238a06bffa79de141ee7655765e2df91498a8aTinderbox User for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done