Makefile.module revision 9868c07279330f31ed91aa986bec707b7e8635a3
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# VirtualBox Guest Additions Module Makefile.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# (For 2.6.x this file must be 'Makefile'!)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# Copyright (C) 2006-2007 innotek GmbH
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# available from http://www.virtualbox.org. This file is free software;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# you can redistribute it and/or modify it under the terms of the GNU
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# General Public License (GPL) as published by the Free Software
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncMODULE = vboxadd
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncOBJS = \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync cmc.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync hgcmcall.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync vboxmod.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync GenericRequest.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync HGCMInternal.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync Init.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync PhysHeap.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync SysHlp.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync VMMDev.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync r0drv/alloc-r0drv.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync r0drv/linux/alloc-r0drv-linux.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync r0drv/linux/semevent-r0drv-linux.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync r0drv/linux/semfastmutex-r0drv-linux.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync RTErrConvertToErrno.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync divdi3.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync moddi3.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync udivdi3.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync umoddi3.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync qdivrem.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync assert.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync logbackdoor.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync logformat.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync strformat.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync strformatrt.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync strformat-vbox.o
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifneq ($(MAKECMDGOALS),clean)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifeq ($(KERNELRELEASE),)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync #
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync # building from this directory
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync #
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync # kernel base directory
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifndef KERN_DIR
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KERN_DIR := /lib/modules/$(shell uname -r)/build
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KERN_DIR := /usr/src/linux
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(error Error: unable to find the sources of your current Linux kernel. \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync Specify KERN_DIR=<directory> and run Make again)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(warning Warning: using /usr/src/linux as the source directory of your \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync Linux kernel. If this is not correct, specify \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KERN_DIR=<directory> and run Make again.)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync else
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(error Error: KERN_DIR does not point to a directory)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync # includes
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifndef KERN_INCL
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KERN_INCL = $(KERN_DIR)/include
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(error Error: unable to find the include directory for your current Linux \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync kernel. Specify KERN_INCL=<directory> and run Make again)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync # module install dir.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifndef MODULE_DIR
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync MODULE_DIR_TST := /lib/modules/$(shell uname -r)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync MODULE_DIR := $(MODULE_DIR_TST)/misc
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync else
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(error Unable to find the folder to install the additions driver to)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync endif # MODULE_DIR unspecified
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync endif
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync # guess kernel version (24 or 26)
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KERN_VERSION := 24
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync else
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KERN_VERSION := 26
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync # KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncelse # neq($(KERNELRELEASE),)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync #
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync # building from Linux-2.6-kbuild (make -C <kernel_directory> M=`pwd`)
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync #
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KERN_VERSION := 26
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif # neq($(KERNELRELEASE),)
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# debug - show guesses.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifdef DEBUG
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync$(warning dbg: KERN_DIR = $(KERN_DIR))
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync$(warning dbg: KERN_INCL = $(KERN_INCL))
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync$(warning dbg: MODULE_DIR = $(MODULE_DIR))
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync$(warning dbg: KERN_VERSION = $(KERN_VERSION))
dc45a8f3e936581748c248e00ce572cfe3ea331evboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# Compiler options
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifndef INCL
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ifndef KBUILD_EXTMOD
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KBUILD_EXTMOD := $(shell pwd)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync export INCL
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -D_X86_ \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DVBGL_VBOXGUEST -DVBOX_HGCM \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync -DLOG_TO_BACKDOOR -DRT_WITH_VBOX -DIN_MODULE -DIN_GUEST_R0
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifeq ($(BUILD_TYPE),debug)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncKFLAGS += -DDEBUG
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifeq ($(KERN_VERSION), 24)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# 2.4
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncCFLAGS := -O2 -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncMODULE_EXT := o
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync# 2.4 Module linking
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync$(MODULE).o: $(OBJS)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(LD) -o $@ -r $(OBJS)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync.PHONY: $(MODULE)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncall: $(MODULE)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync$(MODULE): $(MODULE).o
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncelse
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# 2.6 and later
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync#
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncMODULE_EXT := ko
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync$(MODULE)-y := $(OBJS)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync# build defs
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncall: $(MODULE)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncobj-m += $(MODULE).o
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync$(MODULE):
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncendif
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncinstall: $(MODULE)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync @mkdir -p $(MODULE_DIR); \
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync PATH="$(PATH):/bin:/sbin" depmod -ae;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncendif # eq($(MAKECMDGOALS),clean)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncclean:
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync rm -rf .vboxadd* .tmp_ver* vboxadd.* Module.symvers Modules.symvers
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync