Makefile.include.footer revision 6831f283dbc5c27bde8a8f8bea179b84a5741697
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# VirtualBox Guest Additions kernel module Makefile, common parts.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# (For 2.6.x, the main file must be called 'Makefile'!)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# Copyright (C) 2006-2007 Sun Microsystems, Inc.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# available from http://www.virtualbox.org. This file is free software;
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# you can redistribute it and/or modify it under the terms of the GNU
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# General Public License (GPL) as published by the Free Software
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# additional information or have any questions.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# These file should be included by the Makefiles for any kernel modules we
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# build as part of the Guest Additions. The intended way of doing this is as
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# follows:
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# include Makefile.include
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# MOD_NAME = <name of the module to be built, without extension>
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# MOD_OBJS = <list of object files which should be included>
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# MOD_FLAGS = <any additional CFLAGS which this module needs>
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# The kmk kBuild define KBUILD_TARGET_ARCH is available.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# @todo the shared folders module Makefile also includes the following bits.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# Integrate them if necessary.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# MOD_FLAGS += -DEXPORT_SYMTAB -DVBGL_VBOXGUEST -DRT_WITH_VBOX
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# # special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# # ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# ifeq ($(KERNELRELEASE),)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# KFLAGS += $(foreach inc,$(KERN_INCL),\
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# $(if $(wildcard $(inc)/linux/utsrelease.h),\
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# grep '"2.6.18.*v5.*"' $(inc)/linux/utsrelease.h; \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# -DKERNEL_FC6,),))
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# else
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# -DKERNEL_FC6,)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync## important: Don't remove Module.symvers! DKMS does 'make clean' before building ...
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# rm -rf .vboxvfs* .tmp_ver* vboxvfs.* Modules.symvers modules.order
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# override is required by the Debian guys
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncoverride MODULE = $(MOD_NAME)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncOBJS = $(MOD_OBJS)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncifneq ($(MAKECMDGOALS),clean)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncifeq ($(KERNELRELEASE),)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync #
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync # building from this directory
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync #
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync # kernel base directory
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifndef KERN_DIR
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KERN_DIR := /lib/modules/$(shell uname -r)/build
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KERN_DIR := /usr/src/linux
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync $(error Error: unable to find the sources of your current Linux kernel. \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync Specify KERN_DIR=<directory> and run Make again)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync $(warning Warning: using /usr/src/linux as the source directory of your \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync Linux kernel. If this is not correct, specify \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KERN_DIR=<directory> and run Make again.)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync else
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync $(error Error: KERN_DIR does not point to a directory)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync # includes
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifndef KERN_INCL
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KERN_INCL = $(KERN_DIR)/include
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync $(error Error: unable to find the include directory for your current Linux \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync kernel. Specify KERN_INCL=<directory> and run Make again)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync # module install dir, only for current kernel
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifndef MODULE_DIR
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync MODULE_DIR_TST := /lib/modules/$(shell uname -r)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync MODULE_DIR := $(MODULE_DIR_TST)/misc
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync else
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync $(error Unable to find the folder to install the driver ($(MOD_NAME)) to)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif # MODULE_DIR unspecified
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync # guess kernel version (24 or 26)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KERN_VERSION := 24
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync else
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KERN_VERSION := 26
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncelse # neq($(KERNELRELEASE),)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync #
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync # building from kbuild (make -C <kernel_directory> M=`pwd`)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync #
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync # guess kernel version (24 or 26)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KERN_VERSION := 24
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync else
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KERN_VERSION := 26
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncendif # neq($(KERNELRELEASE),)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# debug - show guesses.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncifdef DEBUG
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync$(warning dbg: KERN_DIR = $(KERN_DIR))
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync$(warning dbg: KERN_INCL = $(KERN_INCL))
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync$(warning dbg: MODULE_DIR = $(MODULE_DIR))
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync$(warning dbg: KERN_VERSION = $(KERN_VERSION))
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncendif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncKBUILD_VERBOSE ?= 1
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# Compiler options
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncifndef INCL
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync ifndef KBUILD_EXTMOD
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KBUILD_EXTMOD := $(shell pwd)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync endif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync export INCL
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncendif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync -DLOG_TO_BACKDOOR -DRT_WITH_VBOX -DIN_MODULE -DIN_GUEST_R0
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncifeq ($(BUILD_TARGET_ARCH),amd64)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncelse
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync KFLAGS += -DRT_ARCH_X86
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncendif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncifeq ($(BUILD_TYPE),debug)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncKFLAGS += -DDEBUG
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncendif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncifeq ($(KERN_VERSION), 24)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# 2.4
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncCFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncMODULE_EXT := o
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# 2.4 Module linking
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync$(MODULE).o: $(OBJS)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync $(LD) -o $@ -r $(OBJS)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync.PHONY: $(MODULE)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncall: $(MODULE)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync$(MODULE): $(MODULE).o
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncelse
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# 2.6 and later
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync#
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncMODULE_EXT := ko
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync$(MODULE)-y := $(OBJS)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync# build defs
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncall: $(MODULE)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncobj-m += $(MODULE).o
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync$(MODULE):
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncendif
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncinstall: $(MODULE)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync @mkdir -p $(MODULE_DIR); \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync PATH="$(PATH):/bin:/sbin" depmod -a;
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncendif # eq($(MAKECMDGOALS),clean)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync
4328e87247f4a96449677e199c7e99ef516fc1cevboxsyncclean:
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync rm -rf .$(MOD_NAME)* .tmp_ver* $(MOD_NAME).* Module.symvers Modules.symvers modules.order
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync