0N/A# VirtualBox Guest Additions Module Makefile.
0N/A# (For
2.6.x this file must be 'Makefile'!)
0N/A# Copyright (C) 2006-2007 Sun Microsystems, Inc.
0N/A# This file is part of VirtualBox Open Source Edition (OSE), as
0N/A# you can redistribute it
and/or modify it under the terms of the GNU
0N/A# General Public License (GPL) as published by the Free Software
0N/A# Foundation, in version 2 as it comes in the "COPYING" file of the
0N/A# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0N/A# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0N/A# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0N/A# additional information or have any questions.
0N/A# First, figure out which architecture we're targeting and the build type.
0N/A# (We have to support basic cross building (ARCH=i386|x86_64).)
0N/A# While at it, warn about BUILD_* vars found to help with user problems.
0N/Aifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
0N/A BUILD_TARGET_ARCH_DEF := amd64
0N/A BUILD_TARGET_ARCH_DEF := x86
0N/Aifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
0N/A $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
0N/A BUILD_TARGET_ARCH :=
0N/Aifeq ($(BUILD_TARGET_ARCH),)
0N/A ifeq ($(ARCH),x86_64)
0N/A BUILD_TARGET_ARCH := amd64
0N/A BUILD_TARGET_ARCH := x86
0N/A BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
0N/A ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
0N/A $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
0N/Aifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
0N/A $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
0N/Aifeq ($(BUILD_TYPE),)
0N/A BUILD_TYPE := release
0N/A ifneq ($(BUILD_TYPE),release)
0N/A $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
0N/A# override is required by the Debian guys
0N/Aoverride MODULE = vboxvfs
0N/Aifeq ($(BUILD_TARGET_ARCH),x86)
0N/AEXTRA_CFLAGS = -fshort-wchar
0N/Aifneq ($(MAKECMDGOALS),clean)
0N/Aifeq ($(KERNELRELEASE),)
0N/A # building from this directory
0N/A # kernel base directory
0N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
0N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
0N/A $(error Error: unable to find the sources of your current Linux kernel. \
0N/A Specify KERN_DIR=<directory> and run Make again)
0N/A Linux kernel. If this is not correct, specify \
0N/A KERN_DIR=<directory> and run Make again.)
0N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
0N/A $(error Error: KERN_DIR does not point to a directory)
0N/A KERN_INCL = $(KERN_DIR)/include
0N/A ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
0N/A $(error Error: unable to find the include directory for your current Linux \
54N/A kernel. Specify KERN_INCL=<directory> and run Make again)
54N/A # module install dir.
0N/A ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
0N/A ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
0N/A MODULE_DIR := $(MODULE_DIR_TST)/misc
0N/A $(error Unable to find the folder to install the shared folders driver to)
0N/A endif # MODULE_DIR unspecified
0N/A # guess kernel version (24 or 26)
0N/Aelse # neq($(KERNELRELEASE),)
0N/A # building from kbuild (make -C <kernel_directory> M=`pwd`)
0N/A # guess kernel version (24 or 26)
0N/A ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' >
/dev/null; then echo yes; fi),yes)
0N/Aendif # neq($(KERNELRELEASE),)
0N/A# debug - show guesses.
0N/A$(warning dbg: KERN_DIR = $(KERN_DIR))
0N/A$(warning dbg: KERN_INCL = $(KERN_INCL))
0N/A$(warning dbg: MODULE_DIR = $(MODULE_DIR))
0N/A$(warning dbg: KERN_VERSION = $(KERN_VERSION))
0N/A INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
0N/A ifndef KBUILD_EXTMOD
0N/A KBUILD_EXTMOD := $(shell pwd)
0N/AKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
0N/A -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DIN_MODULE -DIN_GUEST_R0
0N/A# our module does not export any symbol
0N/AKFLAGS += -DRT_NO_EXPORT_SYMBOL
0N/Aifeq ($(BUILD_TARGET_ARCH),amd64)
0N/A KFLAGS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
25N/A KFLAGS += -DRT_ARCH_X86
0N/Aifeq ($(BUILD_TYPE),debug)
0N/Aifeq ($(KERN_VERSION), 24)
0N/Aifeq ($(BUILD_TARGET_ARCH),amd64)
0N/A KFLAGS += -mcmodel=kernel
0N/ACFLAGS := -O2 -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
1N/A $(LD) -o $@ -r $(OBJS)
1N/A$(MODULE): $(MODULE).o
0N/A$(MODULE)-y := $(OBJS)
0N/A# special hack for Fedora Core 6 2.6.18 (fc6), rhel5 2.6.18 (el5),
25N/A# ClarkConnect 4.3 (cc4) and ClarkConnect 5 (v5)
25N/Aifeq ($(KERNELRELEASE),)
25N/A KFLAGS += $(foreach inc,$(KERN_INCL),\
KFLAGS += $(if $(shell echo "$(KERNELRELEASE)"|grep '2.6.18.*fc6.*';\
echo "$(KERNELRELEASE)"|grep '2.6.18.*el5.*';\
echo "$(KERNELRELEASE)"|grep '2.6.18.*v5.*';\
echo "$(KERNELRELEASE)"|grep '2.6.18.*cc4.*'),\
EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
@mkdir -p $(MODULE_DIR); \
install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
PATH="$(PATH):/bin:/sbin" depmod -a;
endif # eq($(MAKECMDGOALS),clean)
# important: Don't remove
Module.symvers! DKMS does 'make clean' before building ...
for f in . linux r0drv
r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done