Makefile.module revision e62e26b69d90d1f29ad146c68606d95cf47340a4
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# VirtualBox Guest Additions Module Makefile.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# (For 2.6.x this file must be 'Makefile'!)
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync# Copyright (C) 2006-2007 innotek GmbH
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync# available from http://www.virtualbox.org. This file is free software;
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync# you can redistribute it and/or modify it under the terms of the GNU
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync# General Public License as published by the Free Software Foundation,
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync# distribution. VirtualBox OSE is distributed in the hope that it will
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync# be useful, but WITHOUT ANY WARRANTY of any kind.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncMODULE = vboxvfs
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncEXTRA_CFLAGS = -fshort-wchar
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifneq ($(MAKECMDGOALS),clean)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# kernel base directory
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifndef KERN_DIR
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync KERN_DIR := /lib/modules/$(shell uname -r)/build
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(warning Warning: using /usr/src/linux as the source directory of your Linux kernel. If this is not correct, specify KERN_DIR=<directory> and run Make again.)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(error Error: KERN_DIR does not point to a directory.)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifndef KERN_INCL
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync KERN_INCL = $(KERN_DIR)/include
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# module install dir.
667e79989a17e0065952c518a4582839e60234c6vboxsyncifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
667e79989a17e0065952c518a4582839e60234c6vboxsync ifndef MODULE_DIR
667e79989a17e0065952c518a4582839e60234c6vboxsync MODULE_DIR_TST := /lib/modules/$(shell uname -r)
667e79989a17e0065952c518a4582839e60234c6vboxsync ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
667e79989a17e0065952c518a4582839e60234c6vboxsync MODULE_DIR := $(MODULE_DIR_TST)/misc
667e79989a17e0065952c518a4582839e60234c6vboxsync $(error Unable to find the folder to install the shared folders driver to)
667e79989a17e0065952c518a4582839e60234c6vboxsync endif # MODULE_DIR unspecified
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# guess kernel version (24 or 26)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncKERN_VERSION := 24
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncKERN_VERSION := 26
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# debug - show guesses.
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))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# Compiler options
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync ifndef KBUILD_EXTMOD
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync KBUILD_EXTMOD := $(shell pwd)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync export INCL
e62e26b69d90d1f29ad146c68606d95cf47340a4vboxsyncKFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -D_X86_ -DIN_RT_R0 \
e62e26b69d90d1f29ad146c68606d95cf47340a4vboxsync -DIN_SUP_R0 -DVBOX -DVBOX_HGCM -DLOG_TO_BACKDOOR -DIN_MODULE
e62e26b69d90d1f29ad146c68606d95cf47340a4vboxsyncifeq ($(BUILD_TYPE),debug)
e62e26b69d90d1f29ad146c68606d95cf47340a4vboxsyncKFLAGS += -DDEBUG
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncifeq ($(KERN_VERSION), 24)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncCFLAGS := -DVBOX_LINUX_2_4 $(INCL) $(KFLAGS) $(KDEBUG)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncMODULE_EXT := o
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# 2.4 Module linking
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(MODULE).o: $(OBJS)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(LD) -o $@ -r $(OBJS)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync.PHONY: $(MODULE)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncall: $(MODULE)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(MODULE): $(MODULE).o
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync# 2.6 and later
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncMODULE_EXT := ko
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync$(MODULE)-y := $(OBJS)
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# build defs
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncall: $(MODULE)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncobj-m += $(MODULE).o
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
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;
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncendif # eq($(MAKECMDGOALS),clean)
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