Makefile.module revision f1630a6818621238c9c2338394b44995e318e108
0N/A#
0N/A# VirtualBox Guest Additions Module Makefile.
0N/A#
0N/A# (For 2.6.x this file must be 'Makefile'!)
0N/A#
0N/A# Copyright (C) 2006-2007 Sun Microsystems, Inc.
0N/A#
0N/A# This file is part of VirtualBox Open Source Edition (OSE), as
0N/A# available from http://www.virtualbox.org. This file is free software;
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#
0N/A# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0N/A# Clara, CA 95054 USA or visit http://www.sun.com if you need
0N/A# additional information or have any questions.
0N/A#
0N/A
0N/A#
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/A#
0N/Aifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
0N/A BUILD_TARGET_ARCH_DEF := amd64
0N/Aelse
0N/A BUILD_TARGET_ARCH_DEF := x86
0N/Aendif
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/Aendif
0N/Aifeq ($(BUILD_TARGET_ARCH),)
0N/A ifeq ($(ARCH),x86_64)
0N/A BUILD_TARGET_ARCH := amd64
0N/A else
0N/A ifeq ($(ARCH),i386)
0N/A BUILD_TARGET_ARCH := x86
0N/A else
0N/A BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
0N/A endif
0N/A endif
0N/Aelse
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/A endif
0N/Aendif
0N/A
0N/Aifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
0N/A $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
0N/A BUILD_TYPE :=
0N/Aendif
0N/Aifeq ($(BUILD_TYPE),)
0N/A BUILD_TYPE := release
0N/Aelse
0N/A ifneq ($(BUILD_TYPE),release)
0N/A $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
0N/A endif
0N/Aendif
0N/A
0N/A
0N/A# override is required by the Debian guys
0N/Aoverride MODULE = vboxvfs
0N/AOBJS = \
0N/A vfsmod.o \
0N/A dirops.o \
0N/A regops.o \
0N/A utils.o \
0N/A GenericRequest.o \
0N/A SysHlp.o \
0N/A PhysHeap.o \
0N/A Init.o \
0N/A VMMDev.o \
0N/A HGCM.o \
0N/A VBoxCalls.o \
0N/A VbglR0CanUsePhysPageList.o
0N/Aifeq ($(BUILD_TARGET_ARCH),x86)
0N/AOBJS += \
0N/A divdi3.o \
0N/A moddi3.o \
0N/A udivdi3.o \
0N/A umoddi3.o \
0N/A qdivrem.o
0N/Aendif
0N/A
0N/AEXTRA_CFLAGS = -fshort-wchar
0N/A
0N/Aifneq ($(MAKECMDGOALS),clean)
0N/A
0N/Aifeq ($(KERNELRELEASE),)
0N/A
0N/A #
0N/A # building from this directory
0N/A #
0N/A
0N/A # kernel base directory
0N/A ifndef KERN_DIR
0N/A KERN_DIR := /lib/modules/$(shell uname -r)/build
0N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
0N/A KERN_DIR := /usr/src/linux
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 endif
0N/A $(warning Warning: using /usr/src/linux as the source directory of your \
0N/A Linux kernel. If this is not correct, specify \
0N/A KERN_DIR=<directory> and run Make again.)
0N/A endif
0N/A else
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 endif
0N/A endif
0N/A
0N/A # includes
0N/A ifndef KERN_INCL
0N/A KERN_INCL = $(KERN_DIR)/include
0N/A endif
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 endif
54N/A
54N/A # module install dir.
0N/A ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
0N/A ifndef MODULE_DIR
0N/A MODULE_DIR_TST := /lib/modules/$(shell uname -r)
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 else
0N/A $(error Unable to find the folder to install the shared folders driver to)
0N/A endif
0N/A endif # MODULE_DIR unspecified
0N/A endif
0N/A
0N/A # guess kernel version (24 or 26)
0N/A ifeq ($(shell if grep '"2\.4\.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
0N/A KERN_VERSION := 24
0N/A else
0N/A KERN_VERSION := 26
0N/A endif
0N/A
0N/Aelse # neq($(KERNELRELEASE),)
0N/A
0N/A #
0N/A # building from kbuild (make -C <kernel_directory> M=`pwd`)
0N/A #
0N/A
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/A KERN_VERSION := 24
0N/A else
0N/A KERN_VERSION := 26
0N/A endif
0N/A
0N/Aendif # neq($(KERNELRELEASE),)
0N/A
0N/A# debug - show guesses.
0N/Aifdef DEBUG
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/Aendif
0N/A
0N/AKBUILD_VERBOSE ?= 1
0N/A
0N/A#
0N/A# Compiler options
0N/A#
0N/Aifndef INCL
0N/A INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
0N/A ifndef KBUILD_EXTMOD
0N/A KBUILD_EXTMOD := $(shell pwd)
0N/A endif
0N/A INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
0N/A export INCL
0N/Aendif
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
0N/Aelse
25N/A KFLAGS += -DRT_ARCH_X86
0N/Aendif
0N/Aifeq ($(BUILD_TYPE),debug)
0N/A KFLAGS += -DDEBUG
25N/Aendif
0N/A
0N/Aifeq ($(KERN_VERSION), 24)
0N/A#
0N/A# 2.4
0N/A#
0N/A
0N/Aifeq ($(BUILD_TARGET_ARCH),amd64)
0N/A KFLAGS += -mcmodel=kernel
0N/Aendif
0N/A
0N/ACFLAGS := -O2 -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
0N/AMODULE_EXT := o
0N/A
1N/A# 2.4 Module linking
1N/A$(MODULE).o: $(OBJS)
1N/A $(LD) -o $@ -r $(OBJS)
1N/A
1N/A.PHONY: $(MODULE)
1N/Aall: $(MODULE)
1N/A$(MODULE): $(MODULE).o
1N/A
25N/Aelse
0N/A#
0N/A# 2.6 and later
0N/A#
0N/A
0N/AMODULE_EXT := ko
0N/A
0N/A$(MODULE)-y := $(OBJS)
0N/A
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),\
25N/A $(if $(wildcard $(inc)/linux/utsrelease.h),\
25N/A $(if $(shell grep '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h; \
25N/A grep '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h; \
25N/A grep '"2.6.18.*v5.*"' $(inc)/linux/utsrelease.h; \
25N/A grep '"2.6.18.*cc4.*"' $(inc)/linux/utsrelease.h),\
0N/A -DKERNEL_FC6,),))
0N/Aelse
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.*'),\
-DKERNEL_FC6,)
endif
# 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
endif
install: $(MODULE)
@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 ...
clean:
for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
rm -rf .vboxvfs* .tmp_ver* vboxvfs.* Modules.symvers modules.order