Makefile revision e43535ace2499e7f8ef8822186047979bd58d464
1633838b8255282d10af15c5c84cee5a51466712Bob Halley# $Revision$
1ca2cf024391992fe14b2df7d3ae0f575d074452Evan Hunt## @file
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Makefile for the VirtualBox Linux Host Driver.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews#
1633838b8255282d10af15c5c84cee5a51466712Bob Halley#
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley# Copyright (C) 2006-2007 Sun Microsystems, Inc.
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews#
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein# This file is part of VirtualBox Open Source Edition (OSE), as
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein# available from http://www.virtualbox.org. This file is free software;
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# you can redistribute it and/or modify it under the terms of the GNU
d25afd60ee2286cb171c4960a790f3d7041b6f85Bob Halley# General Public License (GPL) as published by the Free Software
d25afd60ee2286cb171c4960a790f3d7041b6f85Bob Halley# Foundation, in version 2 as it comes in the "COPYING" file of the
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
801dceea23d11975f5a5ae6ccbdf1dbde6b7af13David Lawrence# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley#
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff# The contents of this file may alternatively be used under the terms
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence# of the Common Development and Distribution License Version 1.0
fc9e755ba340607d76c7de897ee2d985d3b24505David Lawrence# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
9cd6d409b78a6f833b681c13a68fbdc7c024fe66David Lawrence# VirtualBox OSE distribution, in which case the provisions of the
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt# CDDL are applicable instead of those of the GPL.
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington#
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# You may elect to license modified versions of this file under the
c23f524c073bbee5cba0388f3f45bcde59bacdc5David Lawrence# terms and conditions of either the GPL or the CDDL or both.
801dceea23d11975f5a5ae6ccbdf1dbde6b7af13David Lawrence#
c403d3f7d6cb17406e9be03a330ed5cf91619abcDavid Lawrence# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley# Clara, CA 95054 USA or visit http://www.sun.com if you need
440be4c866f6935ac069db79a414304507a664c2Michael Graff# additional information or have any questions.
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley#
8b78c993cb475cc94e88560941b28c37684789d9Francis Dupont
8b78c993cb475cc94e88560941b28c37684789d9Francis Dupont#
8b78c993cb475cc94e88560941b28c37684789d9Francis Dupont# First, figure out which architecture we're targeting and the build type.
8b78c993cb475cc94e88560941b28c37684789d9Francis Dupont# (We have to support basic cross building (ARCH=i386|x86_64).)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉# While at it, warn about BUILD_* vars found to help with user problems.
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉#
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 BUILD_TARGET_ARCH_DEF := amd64
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉else
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 BUILD_TARGET_ARCH_DEF := x86
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉endif
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 BUILD_TARGET_ARCH :=
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellingtonendif
5f74ac33a07148f2f28b26870c5beccb778b4bd3Bob Halleyifeq ($(BUILD_TARGET_ARCH),)
371147fdc5e7982a0c37adad60c728eeeaf228cfMichael Graff ifeq ($(ARCH),x86_64)
371147fdc5e7982a0c37adad60c728eeeaf228cfMichael Graff BUILD_TARGET_ARCH := amd64
371147fdc5e7982a0c37adad60c728eeeaf228cfMichael Graff else
c09dae9683f7fb55564d117bf7dcfcd74674b68eBob Halley ifeq ($(ARCH),i386)
371147fdc5e7982a0c37adad60c728eeeaf228cfMichael Graff BUILD_TARGET_ARCH := x86
371147fdc5e7982a0c37adad60c728eeeaf228cfMichael Graff else
371147fdc5e7982a0c37adad60c728eeeaf228cfMichael Graff BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
c09dae9683f7fb55564d117bf7dcfcd74674b68eBob Halley endif
c09dae9683f7fb55564d117bf7dcfcd74674b68eBob Halley endif
c09dae9683f7fb55564d117bf7dcfcd74674b68eBob Halleyelse
c09dae9683f7fb55564d117bf7dcfcd74674b68eBob Halley ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
c09dae9683f7fb55564d117bf7dcfcd74674b68eBob Halley $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
371147fdc5e7982a0c37adad60c728eeeaf228cfMichael Graff endif
c09dae9683f7fb55564d117bf7dcfcd74674b68eBob Halleyendif
5f74ac33a07148f2f28b26870c5beccb778b4bd3Bob Halley
c09dae9683f7fb55564d117bf7dcfcd74674b68eBob Halleyifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence BUILD_TYPE :=
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrenceendif
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉ifeq ($(BUILD_TYPE),)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 BUILD_TYPE := release
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉else
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 ifneq ($(BUILD_TYPE),release)
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 endif
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉endif
bf6d2e39124ab3d51c253f7acad9a4abef059be6Bob Halley
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein# override is required by the Debian guys
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halleyoverride MODULE = vboxdrv
3740b569ae76295b941d57a724a43beb75b533baBob HalleyOBJS = \
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein linux/SUPDrv-linux.o \
5f74ac33a07148f2f28b26870c5beccb778b4bd3Bob Halley SUPDrv.o \
3740b569ae76295b941d57a724a43beb75b533baBob Halley SUPDrvSem.o \
3740b569ae76295b941d57a724a43beb75b533baBob Halley r0drv/alloc-r0drv.o \
3740b569ae76295b941d57a724a43beb75b533baBob Halley r0drv/initterm-r0drv.o \
c92ba071011bbc09e7146729606fd9e89a9be02cBob Halley r0drv/memobj-r0drv.o \
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley r0drv/mpnotification-r0drv.o \
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley r0drv/powernotification-r0drv.o \
3740b569ae76295b941d57a724a43beb75b533baBob Halley r0drv/linux/assert-r0drv-linux.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 r0drv/linux/alloc-r0drv-linux.o \
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley r0drv/linux/initterm-r0drv-linux.o \
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley r0drv/linux/memobj-r0drv-linux.o \
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence r0drv/linux/memuserkernel-r0drv-linux.o \
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence r0drv/linux/mp-r0drv-linux.o \
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley r0drv/linux/mpnotification-r0drv-linux.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 r0drv/linux/process-r0drv-linux.o \
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley r0drv/linux/semevent-r0drv-linux.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 r0drv/linux/semeventmulti-r0drv-linux.o \
8dcce6f92254680aaa9b66afb927a30316b9e46eBob Halley r0drv/linux/semfastmutex-r0drv-linux.o \
bf6d2e39124ab3d51c253f7acad9a4abef059be6Bob Halley r0drv/linux/spinlock-r0drv-linux.o \
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley r0drv/linux/thread-r0drv-linux.o \
f47bb8d1f3a2e3edae11942d0d7e62e96caa5720Bob Halley r0drv/linux/thread2-r0drv-linux.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 r0drv/linux/time-r0drv-linux.o \
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley r0drv/linux/timer-r0drv-linux.o \
3740b569ae76295b941d57a724a43beb75b533baBob Halley r0drv/generic/semspinmutex-r0drv-generic.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/alloc/alloc.o \
bf6d2e39124ab3d51c253f7acad9a4abef059be6Bob Halley common/checksum/ipv4.o \
bf6d2e39124ab3d51c253f7acad9a4abef059be6Bob Halley common/checksum/ipv6.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/err/RTErrConvertFromErrno.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/err/RTErrConvertToErrno.o \
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington common/log/log.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/log/logellipsis.o \
3740b569ae76295b941d57a724a43beb75b533baBob Halley common/log/logrel.o \
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley common/log/logrelellipsis.o \
4c7d0f3c386a609d596152a6956d1fd5f1d43aa4Bob Halley common/log/logcom.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/log/logformat.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt common/misc/RTAssertMsg1Weak.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt common/misc/RTAssertMsg2.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt common/misc/RTAssertMsg2Add.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/misc/RTAssertMsg2AddWeak.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/misc/RTAssertMsg2AddWeakV.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt common/misc/RTAssertMsg2Weak.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/misc/RTAssertMsg2WeakV.o \
27809a2ee5db141b684e53bf1d94da26e9f92d3aMark Andrews common/misc/assert.o \
618053b8bec1dea3e9486c3b427b123c4093d56aMark Andrews common/misc/handletable.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/misc/handletablectx.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt common/string/strformat.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/string/strformatrt.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt common/string/strformattype.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 common/string/strprintf.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt common/string/strtonum.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt generic/RTAssertShouldPanic-generic.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 generic/RTLogWriteStdErr-stub-generic.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt generic/RTLogWriteStdOut-stub-generic.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 generic/RTLogWriteUser-generic.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt generic/uuid-generic.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 VBox/log-vbox.o
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Huntifeq ($(BUILD_TARGET_ARCH),x86)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉OBJS += math/gcc/divdi3.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt math/gcc/moddi3.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt math/gcc/qdivrem.o \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt math/gcc/udivdi3.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 math/gcc/divdi3.o \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 math/gcc/umoddi3.o
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉endif
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉ifeq ($(BUILD_TARGET_ARCH),amd64)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉OBJS += common/alloc/heapsimple.o
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉endif
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉ifneq ($(MAKECMDGOALS),clean)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉ifeq ($(KERNELRELEASE),)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 #
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 # building from this directory
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 #
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt # kernel base directory
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt ifndef KERN_DIR
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 # build for the current kernel, version check
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 KERN_DIR := /lib/modules/$(shell uname -r)/build
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 KERN_DIR := /usr/src/linux
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 $(error Error: unable to find the sources of your current Linux kernel. \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 Specify KERN_DIR=<directory> and run Make again)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 endif
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 $(warning Warning: using /usr/src/linux as the source directory of your \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt Linux kernel. If this is not correct, specify \
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt KERN_DIR=<directory> and run Make again.)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 endif
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 # check if versions match -- works only for later 2.6 kernels
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein ifneq ($(VBOX_KERN_VER),)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 ifneq ($(VBOX_KERN_VER),$(shell uname -r))
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington $(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 the current kernel (version $(shell uname -r)))
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 endif
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington endif
a2a072eb23b0d0167bf573625ce41a65fe135afdBob Halley else
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 # build for a dedicated kernel, no version check
a2a072eb23b0d0167bf573625ce41a65fe135afdBob Halley ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 $(error Error: KERN_DIR does not point to a directory)
3740b569ae76295b941d57a724a43beb75b533baBob Halley endif
225c880310c7ff8ada24bc40ba2a0373a163b9e2Bob Halley endif
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff # includes
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff ifndef KERN_INCL
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley KERN_INCL = $(KERN_DIR)/include
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein endif
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley $(error Error: unable to find the include directory for your current Linux \
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley kernel. Specify KERN_INCL=<directory> and run Make again)
d13284da19d30159424b2f726cc403eda23a1e01Bob Halley endif
d13284da19d30159424b2f726cc403eda23a1e01Bob Halley
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 # module install dir, only for current kernel
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 ifndef MODULE_DIR
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington MODULE_DIR_TST := /lib/modules/$(shell uname -r)
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff MODULE_DIR := $(MODULE_DIR_TST)/misc
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 else
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein $(error Unable to find the folder to install the support driver to)
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff endif
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff endif # MODULE_DIR unspecified
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff endif
c0c9d2b566cb40b96cb7b471450c3b47eeb0fe0cMark Andrews
c0c9d2b566cb40b96cb7b471450c3b47eeb0fe0cMark Andrewselse # neq($(KERNELRELEASE),)
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graff #
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley # building from kbuild (make -C <kernel_directory> M=`pwd`)
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley #
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley
9234d92d4e274791eff42cc4ea5766ed7a281b17Mark Andrewsendif # neq($(KERNELRELEASE),)
60e412971ec8865ff5ab90a1a1128e86e5794299David Lawrence
60e412971ec8865ff5ab90a1a1128e86e5794299David Lawrence# debug - show guesses.
60e412971ec8865ff5ab90a1a1128e86e5794299David Lawrenceifdef DEBUG
9234d92d4e274791eff42cc4ea5766ed7a281b17Mark Andrews$(warning dbg: KERN_DIR = $(KERN_DIR))
9234d92d4e274791eff42cc4ea5766ed7a281b17Mark Andrews$(warning dbg: KERN_INCL = $(KERN_INCL))
9234d92d4e274791eff42cc4ea5766ed7a281b17Mark Andrews$(warning dbg: MODULE_DIR = $(MODULE_DIR))
60e412971ec8865ff5ab90a1a1128e86e5794299David Lawrenceendif
5cc3e0c38f47352bcfd7791af1c006eec6164e5aBob Halley
225c880310c7ff8ada24bc40ba2a0373a163b9e2Bob HalleyKBUILD_VERBOSE ?= 1
5cc3e0c38f47352bcfd7791af1c006eec6164e5aBob Halley
225c880310c7ff8ada24bc40ba2a0373a163b9e2Bob Halley#
bf6d2e39124ab3d51c253f7acad9a4abef059be6Bob Halley# Compiler options
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley#
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halleyifndef INCL
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley ifndef KBUILD_EXTMOD
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence KBUILD_EXTMOD := $(shell pwd)
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley endif
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
5291519dba9e3b8c6e624b7c6d4b001f1d137c60Bob Halley export INCL
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graffendif
298523461941e171ce97ea8b76892ac01bb7a49fBob HalleyKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
298523461941e171ce97ea8b76892ac01bb7a49fBob Halleyifdef VBOX_REDHAT_KABI
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley KFLAGS += -DVBOX_REDHAT_KABI
298523461941e171ce97ea8b76892ac01bb7a49fBob Halleyendif
bf6d2e39124ab3d51c253f7acad9a4abef059be6Bob Halleyifndef CONFIG_VBOXDRV_FIXEDMAJOR
225c880310c7ff8ada24bc40ba2a0373a163b9e2Bob Halley KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
225c880310c7ff8ada24bc40ba2a0373a163b9e2Bob Halleyendif
298523461941e171ce97ea8b76892ac01bb7a49fBob Halleyifeq ($(BUILD_TARGET_ARCH),amd64)
f47bb8d1f3a2e3edae11942d0d7e62e96caa5720Bob Halley KFLAGS += -DRT_ARCH_AMD64
298523461941e171ce97ea8b76892ac01bb7a49fBob Halleyelse
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley KFLAGS += -DRT_ARCH_X86
f47bb8d1f3a2e3edae11942d0d7e62e96caa5720Bob Halleyendif
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley# must be consistent with Config.kmk!
298523461941e171ce97ea8b76892ac01bb7a49fBob HalleyKFLAGS += -DVBOX_WITH_64_BITS_GUESTS
298523461941e171ce97ea8b76892ac01bb7a49fBob Halleyifeq ($(BUILD_TYPE),debug)
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley KFLAGS += -DDEBUG -DDEBUG_$(USER) -g
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley # IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley KFLAGS += -DIPRT_DEBUG_SEMS
225c880310c7ff8ada24bc40ba2a0373a163b9e2Bob Halleyendif
f47bb8d1f3a2e3edae11942d0d7e62e96caa5720Bob Halley
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley# 2.6 and later
298523461941e171ce97ea8b76892ac01bb7a49fBob HalleyMODULE_EXT := ko
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley$(MODULE)-y := $(OBJS)
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley# build defs
298523461941e171ce97ea8b76892ac01bb7a49fBob HalleyEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
225c880310c7ff8ada24bc40ba2a0373a163b9e2Bob Halley
9cd6d409b78a6f833b681c13a68fbdc7c024fe66David Lawrenceall: $(MODULE)
9cd6d409b78a6f833b681c13a68fbdc7c024fe66David Lawrence
298523461941e171ce97ea8b76892ac01bb7a49fBob Halleyobj-m += $(MODULE).o
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington$(MODULE):
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellington
8ec174ad4e570842495b2f1f3836160af90f69afBrian Wellingtoninstall: $(MODULE)
298523461941e171ce97ea8b76892ac01bb7a49fBob Halley @mkdir -p $(MODULE_DIR); \
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff PATH="$(PATH):/bin:/sbin" depmod -a; \
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff rm -f /etc/vbox/module_not_compiled
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graffinstall_rpm: $(MODULE)
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff @mkdir -p $(MODULE_DIR); \
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graffendif # eq($(MAKECMDGOALS),clean)
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff
de6aca419d84183a8ce15efd7104ebe6b39317f4Michael Graffclean:
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff for f in . linux r0drv r0drv/generic r0drv/linux VBox common/err common/string common/log generic math/gcc; \
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff rm -rf .vboxdrv* .tmp_ver* vboxdrv.* Module.symvers Modules.symvers modules.order
e5242f042b968e316bb775c0dea4eb230fc4f6a4Michael Graff