Makefile.module revision fa8e26644bdce3fe8590a2fd82433dc8bdf55414
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# VirtualBox Guest Additions Module Makefile.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# (For 2.6.x this file must be 'Makefile'!)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync# Copyright (C) 2006-2007 innotek GmbH
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync#
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync# available from http://www.virtualbox.org. This file is free software;
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync# you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync# General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
565c6b62913edd14704b060e3172bba10b1fe12evboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
fa8e26644bdce3fe8590a2fd82433dc8bdf55414vboxsync# override is required by the Debian guys
fa8e26644bdce3fe8590a2fd82433dc8bdf55414vboxsyncoverride MODULE = vboxvfs
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncOBJS = \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync vfsmod.o \
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync dirops.o \
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync regops.o \
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync utils.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync GenericRequest.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync SysHlp.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync PhysHeap.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync Init.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync VMMDev.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync HGCM.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync VBoxCalls.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync r0drv/alloc-r0drv.o \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync r0drv/linux/alloc-r0drv-linux.o \
565c6b62913edd14704b060e3172bba10b1fe12evboxsync r0drv/linux/semevent-r0drv-linux.o \
565c6b62913edd14704b060e3172bba10b1fe12evboxsync r0drv/linux/semfastmutex-r0drv-linux.o \
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync divdi3.o \
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync moddi3.o \
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync udivdi3.o \
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync umoddi3.o \
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync qdivrem.o
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncEXTRA_CFLAGS = -fshort-wchar
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifneq ($(MAKECMDGOALS),clean)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsyncifeq ($(KERNELRELEASE),)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync #
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync # building from this directory
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync #
6ba8963f8a097b33938cd6fbcd6b63faf6d26889vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync # kernel base directory
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifndef KERN_DIR
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync KERN_DIR := /lib/modules/$(shell uname -r)/build
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync KERN_DIR := /usr/src/linux
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync $(error Error: unable to find the sources of your current Linux kernel. \
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync Specify KERN_DIR=<directory> and run Make again)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync endif
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync $(warning Warning: using /usr/src/linux as the source directory of your \
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync Linux kernel. If this is not correct, specify \
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync KERN_DIR=<directory> and run Make again.)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync endif
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync else
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync $(error Error: KERN_DIR does not point to a directory)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync endif
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync endif
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync # includes
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifndef KERN_INCL
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync KERN_INCL = $(KERN_DIR)/include
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync endif
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync $(error Error: unable to find the include directory for your current Linux \
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync kernel. Specify KERN_INCL=<directory> and run Make again)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync endif
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync # module install dir.
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifndef MODULE_DIR
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync MODULE_DIR_TST := /lib/modules/$(shell uname -r)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync MODULE_DIR := $(MODULE_DIR_TST)/misc
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync else
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync $(error Unable to find the folder to install the shared folders driver to)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync endif
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync endif # MODULE_DIR unspecified
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync endif
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync # guess kernel version (24 or 26)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync KERN_VERSION := 24
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync else
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync KERN_VERSION := 26
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync endif
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync # KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsyncelse # neq($(KERNELRELEASE),)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync #
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync # building from Linux-2.6-kbuild (make -C <kernel_directory> M=`pwd`)
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync #
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync KERN_VERSION := 26
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync
9868c07279330f31ed91aa986bec707b7e8635a3vboxsyncendif # neq($(KERNELRELEASE),)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# debug - show guesses.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifdef DEBUG
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(warning dbg: KERN_DIR = $(KERN_DIR))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(warning dbg: KERN_INCL = $(KERN_INCL))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(warning dbg: MODULE_DIR = $(MODULE_DIR))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(warning dbg: KERN_VERSION = $(KERN_VERSION))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncendif
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# Compiler options
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifndef INCL
6e9e03fceb2e76b576905c4d3faa55ca31555956vboxsync INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync ifndef KBUILD_EXTMOD
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync KBUILD_EXTMOD := $(shell pwd)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync endif
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync export INCL
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncendif
e62e26b69d90d1f29ad146c68606d95cf47340a4vboxsyncKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -D_X86_ -DIN_RT_R0 \
7e7e2d15030a41a97b964b4dff6d61c84395d687vboxsync -DIN_SUP_R0 -DVBOX -DVBOX_HGCM -DLOG_TO_BACKDOOR -DIN_MODULE \
7e7e2d15030a41a97b964b4dff6d61c84395d687vboxsync -DIN_GUEST_R0
e62e26b69d90d1f29ad146c68606d95cf47340a4vboxsyncifeq ($(BUILD_TYPE),debug)
e62e26b69d90d1f29ad146c68606d95cf47340a4vboxsyncKFLAGS += -DDEBUG
e62e26b69d90d1f29ad146c68606d95cf47340a4vboxsyncendif
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifeq ($(KERN_VERSION), 24)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# 2.4
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
0fd850701c4b07dd4cc9074734b8d98f6184055cvboxsyncCFLAGS := -O2 -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncMODULE_EXT := o
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# 2.4 Module linking
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(MODULE).o: $(OBJS)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(LD) -o $@ -r $(OBJS)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync.PHONY: $(MODULE)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncall: $(MODULE)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(MODULE): $(MODULE).o
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncelse
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# 2.6 and later
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync#
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncMODULE_EXT := ko
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(MODULE)-y := $(OBJS)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# detect FC6 2.6.18
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncKFLAGS += $(foreach inc,$(KERN_INCL),\
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(if $(wildcard $(inc)/linux/utsrelease.h),\
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(if $(shell if grep -q '"2.6.18.*fc6.*"' $(inc)/linux/utsrelease.h;\
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync then echo yes; fi),-DKERNEL_FC6,),))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# detect rhel5 2.6.18
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncKFLAGS += $(foreach inc,$(KERN_INCL),\
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(if $(wildcard $(inc)/linux/utsrelease.h),\
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(if $(shell if grep -q '"2.6.18.*el5.*"' $(inc)/linux/utsrelease.h;\
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync then echo yes; fi),-DKERNEL_FC6,),))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# build defs
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncall: $(MODULE)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncobj-m += $(MODULE).o
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(MODULE):
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncendif
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncinstall: $(MODULE)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync @mkdir -p $(MODULE_DIR); \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync PATH="$(PATH):/bin:/sbin" depmod -ae;
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncendif # eq($(MAKECMDGOALS),clean)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncclean:
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
8161020821499b941febdacc7d42e994b84630ddvboxsync rm -rf .vboxvfs* .tmp_ver* vboxvfs.* Module.symvers Modules.symvers