Makefile revision 228952e4dd4c991e27dbd718bc2f3a48bd547df8
9b2bd54c98edb185a3985410367754ab33217362bnicholes# Makefile for the VirtualBox Linux Host Driver.
9b2bd54c98edb185a3985410367754ab33217362bnicholes# (For 2.6.x this file must be called 'Makefile'!)
9b2bd54c98edb185a3985410367754ab33217362bnicholes# Copyright (C) 2006 innotek GmbH
9b2bd54c98edb185a3985410367754ab33217362bnicholes# This file is part of VirtualBox Open Source Edition (OSE), as
9b2bd54c98edb185a3985410367754ab33217362bnicholes# available from http://www.virtualbox.org. This file is free software;
9b2bd54c98edb185a3985410367754ab33217362bnicholes# you can redistribute it and/or modify it under the terms of the GNU
9b2bd54c98edb185a3985410367754ab33217362bnicholes# General Public License as published by the Free Software Foundation,
9b2bd54c98edb185a3985410367754ab33217362bnicholes# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
9b2bd54c98edb185a3985410367754ab33217362bnicholes# distribution. VirtualBox OSE is distributed in the hope that it will
9b2bd54c98edb185a3985410367754ab33217362bnicholes# be useful, but WITHOUT ANY WARRANTY of any kind.
9b2bd54c98edb185a3985410367754ab33217362bnicholes# First, figure out which architecture we're targeting.
9b2bd54c98edb185a3985410367754ab33217362bnicholes# (We have to support basic cross building (ARCH=i386|x86_64).)
9b2bd54c98edb185a3985410367754ab33217362bnicholesifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
9b2bd54c98edb185a3985410367754ab33217362bnicholes ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
9b2bd54c98edb185a3985410367754ab33217362bnicholes# kernel base directory
9b2bd54c98edb185a3985410367754ab33217362bnicholes ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9b2bd54c98edb185a3985410367754ab33217362bnicholes ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9b2bd54c98edb185a3985410367754ab33217362bnicholes $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
be06f010941d039a422f1bbd7e321a1a0e92e291bnicholes $(warning Warning: using /usr/src/linux as the source directory of your Linux kernel. If this is not correct, specify KERN_DIR=<directory> and run Make again.)
9b2bd54c98edb185a3985410367754ab33217362bnicholes ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9b2bd54c98edb185a3985410367754ab33217362bnicholes $(error Error: KERN_DIR does not point to a directory.)
9b2bd54c98edb185a3985410367754ab33217362bnicholesifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
9b2bd54c98edb185a3985410367754ab33217362bnicholes $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
9b2bd54c98edb185a3985410367754ab33217362bnicholes# module install dir.
9b2bd54c98edb185a3985410367754ab33217362bnicholesifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
9b2bd54c98edb185a3985410367754ab33217362bnicholes ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
9b2bd54c98edb185a3985410367754ab33217362bnicholes $(error Unable to find the folder to install the support driver to)
9b2bd54c98edb185a3985410367754ab33217362bnicholes# guess kernel version (24 or 26)
9b2bd54c98edb185a3985410367754ab33217362bnicholesKERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
9b2bd54c98edb185a3985410367754ab33217362bnicholes# debug - show guesses.
9b2bd54c98edb185a3985410367754ab33217362bnicholes# Compiler options
9b2bd54c98edb185a3985410367754ab33217362bnicholes INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
be06f010941d039a422f1bbd7e321a1a0e92e291bnicholes INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
9b2bd54c98edb185a3985410367754ab33217362bnicholesKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0
9b2bd54c98edb185a3985410367754ab33217362bnicholes#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
9b2bd54c98edb185a3985410367754ab33217362bnicholes#KFLAGS += -DDEBUG
9b2bd54c98edb185a3985410367754ab33217362bnicholes# Use the RTR0MemObj API - testing.
9b2bd54c98edb185a3985410367754ab33217362bnicholes# If this makes testboxes crash/burn/leak disable it and add a comment to defect #2116.
9b2bd54c98edb185a3985410367754ab33217362bnicholes# 2.6 and later
9b2bd54c98edb185a3985410367754ab33217362bnicholes $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
9b2bd54c98edb185a3985410367754ab33217362bnicholes# 2.4 Module linking
9b2bd54c98edb185a3985410367754ab33217362bnicholes install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
9b2bd54c98edb185a3985410367754ab33217362bnicholes install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
9b2bd54c98edb185a3985410367754ab33217362bnicholes for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done