Makefile revision 7eaaa8a4480370b82ef3735994f986f338fb4df2
b60271016957475ef5d675f8a5a116a661b46b82David Lawrence# $Revision$
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews## @file
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Makefile for the VirtualBox Linux Host Driver.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews#
b60271016957475ef5d675f8a5a116a661b46b82David Lawrence#
b60271016957475ef5d675f8a5a116a661b46b82David Lawrence# Copyright (C) 2006-2010 Oracle Corporation
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley#
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# This file is part of VirtualBox Open Source Edition (OSE), as
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# available from http://www.virtualbox.org. This file is free software;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# you can redistribute it and/or modify it under the terms of the GNU
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# General Public License (GPL) as published by the Free Software
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# Foundation, in version 2 as it comes in the "COPYING" file of the
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley#
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# The contents of this file may alternatively be used under the terms
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# of the Common Development and Distribution License Version 1.0
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
bff64bf12b58a6f80e740e94f2e42a32df18113aEvan Hunt# VirtualBox OSE distribution, in which case the provisions of the
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# CDDL are applicable instead of those of the GPL.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley#
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# You may elect to license modified versions of this file under the
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# terms and conditions of either the GPL or the CDDL or both.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley#
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley#
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# First, figure out which architecture we're targeting and the build type.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# (We have to support basic cross building (ARCH=i386|x86_64).)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley# While at it, warn about BUILD_* vars found to help with user problems.
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley#
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley BUILD_TARGET_ARCH_DEF := amd64
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyelse
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley BUILD_TARGET_ARCH_DEF := x86
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyendif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence BUILD_TARGET_ARCH :=
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyendif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifeq ($(BUILD_TARGET_ARCH),)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifeq ($(ARCH),x86_64)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley BUILD_TARGET_ARCH := amd64
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley else
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifeq ($(ARCH),i386)
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence BUILD_TARGET_ARCH := x86
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley else
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyelse
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyendif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley BUILD_TYPE :=
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyendif
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updaterifeq ($(BUILD_TYPE),)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley BUILD_TYPE := release
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyelse
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(BUILD_TYPE),release)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyendif
7eab320180831eeb2bc1e42114b2ae30905513dfBob Halley
7eab320180831eeb2bc1e42114b2ae30905513dfBob Halley# override is required by the Debian guys
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyoverride MODULE = vboxdrv
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob HalleyOBJS = \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley linux/SUPDrv-linux.o \
089b7bf0a57caa90cddb95718678bd402fa375fdBrian Wellington SUPDrv.o \
089b7bf0a57caa90cddb95718678bd402fa375fdBrian Wellington SUPDrvSem.o \
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein r0drv/alloc-r0drv.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/initterm-r0drv.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/memobj-r0drv.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/mpnotification-r0drv.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/powernotification-r0drv.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/assert-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/alloc-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/initterm-r0drv-linux.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence r0drv/linux/memobj-r0drv-linux.o \
47c5b8af920a93763c97d9a93ea1fd766961a5b3Evan Hunt r0drv/linux/memuserkernel-r0drv-linux.o \
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews r0drv/linux/mp-r0drv-linux.o \
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews r0drv/linux/mpnotification-r0drv-linux.o \
db9628e8973fe17b8fbff96fdb23b7996a1ebce9David Lawrence r0drv/linux/process-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/semevent-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/semeventmulti-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/semfastmutex-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/semmutex-r0drv-linux.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington r0drv/linux/spinlock-r0drv-linux.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington r0drv/linux/thread-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/thread2-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/time-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/timer-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/generic/semspinmutex-r0drv-generic.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/alloc/alloc.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/checksum/crc32.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/checksum/ipv4.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/checksum/ipv6.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/err/RTErrConvertFromErrno.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington common/err/RTErrConvertToErrno.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington common/log/log.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington common/log/logellipsis.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/log/logrel.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/log/logrelellipsis.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington common/log/logcom.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington common/log/logformat.o \
a3fb84bd1b6a56585c0d8181f2ab0338b0cf852fTinderbox User common/misc/RTAssertMsg1Weak.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington common/misc/RTAssertMsg2.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/misc/RTAssertMsg2Add.o \
f356f1bb5d54a1a768c1470b637b8c24e13b38f9Brian Wellington common/misc/RTAssertMsg2AddWeak.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/misc/RTAssertMsg2AddWeakV.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/misc/RTAssertMsg2Weak.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/misc/RTAssertMsg2WeakV.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence common/misc/assert.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence common/misc/handletable.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence common/misc/handletablectx.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence common/string/strformat.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence common/string/strformatrt.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence common/string/strformattype.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence common/string/strprintf.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/string/strtonum.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley common/time/time.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley generic/RTAssertShouldPanic-generic.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley generic/RTLogWriteStdErr-stub-generic.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence generic/RTLogWriteStdOut-stub-generic.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley generic/RTLogWriteUser-generic.o \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence generic/uuid-generic.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley VBox/log-vbox.o
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifeq ($(BUILD_TARGET_ARCH),x86)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob HalleyOBJS += math/gcc/divdi3.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley math/gcc/moddi3.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley math/gcc/qdivrem.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley math/gcc/udivdi3.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley math/gcc/divdi3.o \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley math/gcc/umoddi3.o
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyendif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifeq ($(BUILD_TARGET_ARCH),amd64)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob HalleyOBJS += common/alloc/heapsimple.o
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyendif
5eb91bd90e3ad3426e5e3213031556a737cf3809Mark Andrews
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifneq ($(MAKECMDGOALS),clean)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halleyifeq ($(KERNELRELEASE),)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley #
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # building from this directory
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley #
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # kernel base directory
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence ifndef KERN_DIR
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # build for the current kernel, version check
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley KERN_DIR := /lib/modules/$(shell uname -r)/build
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley KERN_DIR := /usr/src/linux
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(error Error: unable to find the sources of your current Linux kernel. \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley Specify KERN_DIR=<directory> and run Make again)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(warning Warning: using /usr/src/linux as the source directory of your \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley Linux kernel. If this is not correct, specify \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley KERN_DIR=<directory> and run Make again.)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # check if versions match -- works only for later 2.6 kernels
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(VBOX_KERN_VER),)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(VBOX_KERN_VER),$(shell uname -r))
5eb91bd90e3ad3426e5e3213031556a737cf3809Mark Andrews $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley the current kernel (version $(shell uname -r)))
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley else
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # build for a dedicated kernel, no version check
5eb91bd90e3ad3426e5e3213031556a737cf3809Mark Andrews ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(error Error: KERN_DIR does not point to a directory)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # includes
5eb91bd90e3ad3426e5e3213031556a737cf3809Mark Andrews ifndef KERN_INCL
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley KERN_INCL = $(KERN_DIR)/include
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley $(error Error: unable to find the include directory for your current Linux \
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley kernel. Specify KERN_INCL=<directory> and run Make again)
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley endif
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley # module install dir, only for current kernel
2ba9ea4e1e5ce8d54a24b66ef69e6cdf96cfb667Bob Halley ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
ifndef MODULE_DIR
MODULE_DIR_TST := /lib/modules/$(shell uname -r)
ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
MODULE_DIR := $(MODULE_DIR_TST)/misc
else
$(error Unable to find the folder to install the support driver to)
endif
endif # MODULE_DIR unspecified
endif
else # neq($(KERNELRELEASE),)
#
# building from kbuild (make -C <kernel_directory> M=`pwd`)
#
endif # neq($(KERNELRELEASE),)
# debug - show guesses.
ifdef DEBUG
$(warning dbg: KERN_DIR = $(KERN_DIR))
$(warning dbg: KERN_INCL = $(KERN_INCL))
$(warning dbg: MODULE_DIR = $(MODULE_DIR))
endif
KBUILD_VERBOSE ?= 1
#
# Compiler options
#
ifndef INCL
INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
ifndef KBUILD_EXTMOD
KBUILD_EXTMOD := $(shell pwd)
endif
INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxdrv,/ /include /r0drv/linux)
export INCL
endif
KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
ifdef VBOX_REDHAT_KABI
KFLAGS += -DVBOX_REDHAT_KABI
endif
ifndef CONFIG_VBOXDRV_FIXEDMAJOR
KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
endif
ifeq ($(BUILD_TARGET_ARCH),amd64)
KFLAGS += -DRT_ARCH_AMD64
else
KFLAGS += -DRT_ARCH_X86
endif
# must be consistent with Config.kmk!
KFLAGS += -DVBOX_WITH_64_BITS_GUESTS
ifeq ($(BUILD_TYPE),debug)
KFLAGS += -DDEBUG -DDEBUG_$(USER) -g
# IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
#KFLAGS += -DIPRT_DEBUG_SEMS
endif
# 2.6 and later
MODULE_EXT := ko
$(MODULE)-y := $(OBJS)
# build defs
EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
all: $(MODULE)
obj-m += $(MODULE).o
$(MODULE):
$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
install: $(MODULE)
@mkdir -p $(MODULE_DIR); \
install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
PATH="$(PATH):/bin:/sbin" depmod -a; \
rm -f /etc/vbox/module_not_compiled
install_rpm: $(MODULE)
@mkdir -p $(MODULE_DIR); \
install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
endif # eq($(MAKECMDGOALS),clean)
clean:
for f in . linux r0drv r0drv/generic r0drv/linux VBox common/err common/string common/log generic math/gcc; \
do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
rm -rf .vboxdrv* .tmp_ver* vboxdrv.* Module.symvers Modules.symvers modules.order