Makefile revision 18f9f43e809ff424b14f19e097382f44fda2e11e
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User# Makefile for the VirtualBox Linux Host Driver.
6a42ab64276ff832a47e009be1208f7c7d4da22dAutomatic Updater# (For 2.6.x this file must be called 'Makefile'!)
6a42ab64276ff832a47e009be1208f7c7d4da22dAutomatic Updater# Copyright (C) 2006-2007 Sun Microsystems, Inc.
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# This file is part of VirtualBox Open Source Edition (OSE), as
6a42ab64276ff832a47e009be1208f7c7d4da22dAutomatic Updater# available from http://www.virtualbox.org. This file is free software;
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# you can redistribute it and/or modify it under the terms of the GNU
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# General Public License (GPL) as published by the Free Software
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# Foundation, in version 2 as it comes in the "COPYING" file of the
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# The contents of this file may alternatively be used under the terms
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# of the Common Development and Distribution License Version 1.0
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# VirtualBox OSE distribution, in which case the provisions of the
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# CDDL are applicable instead of those of the GPL.
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User# You may elect to license modified versions of this file under the
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User# terms and conditions of either the GPL or the CDDL or both.
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# Clara, CA 95054 USA or visit http://www.sun.com if you need
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# additional information or have any questions.
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# First, figure out which architecture we're targeting and the build type.
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User# (We have to support basic cross building (ARCH=i386|x86_64).)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# While at it, warn about BUILD_* vars found to help with user problems.
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updaterifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updaterifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
24abfe433efd98bb2099b867fb14d049b2f1f531Tinderbox User BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updaterifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater# override is required by the Debian guys
ed4475f3f583f6137b4ff7fea775c5363a4fdb29Automatic Updater r0drv/linux/mpnotification-r0drv-linux.o \
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User # building from this directory
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User # kernel base directory
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User # build for the current kernel, version check
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User KERN_DIR := /lib/modules/$(shell uname -r)/build
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User $(error Error: unable to find the sources of your current Linux kernel. \
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User Specify KERN_DIR=<directory> and run Make again)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User $(warning Warning: using /usr/src/linux as the source directory of your \
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User Linux kernel. If this is not correct, specify \
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User # check if versions match -- works only for later 2.6 kernels
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) kernelrelease 2> /dev/null || true)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User the current kernel (version $(shell uname -r)))
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User # build for a dedicated kernel, no version check
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User $(error Error: KERN_DIR does not point to a directory)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User $(error Error: unable to find the include directory for your current Linux \
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User kernel. Specify KERN_INCL=<directory> and run Make again)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User # module install dir, only for current kernel
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User MODULE_DIR_TST := /lib/modules/$(shell uname -r)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User $(error Unable to find the folder to install the support driver to)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox Userelse # neq($(KERNELRELEASE),)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User # building from kbuild (make -C <kernel_directory> M=`pwd`)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User# debug - show guesses.
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User# Compiler options
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox UserKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User# must be consistent with Config.kmk!
b46346eb3026ba4bebc093bc93cfe159131e541eTinderbox User # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
548a24c3d36837aa5f0e64f7bb8c7308909ffa89Tinderbox User# 2.6 and later
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic UpdaterEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater for f in . linux r0drv r0drv/linux VBox common/err common/string common/log generic math/gcc; \
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done