Makefile.module revision 667e79989a17e0065952c518a4582839e60234c6
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 as published by the Free Software Foundation,
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# distribution. VirtualBox OSE is distributed in the hope that it will
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# be useful, but WITHOUT ANY WARRANTY of any kind.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# If you received this file as part of a commercial VirtualBox
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# distribution, then only the terms of your commercial VirtualBox
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# license agreement apply instead of the previous paragraph.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncMODULE = vboxadd
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncOBJS = \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync cmc.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync hgcmcall.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync vboxmod.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync GenericRequest.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync PhysHeap.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync SysHlp.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync Init.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync VMMDev.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync HGCMInternal.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync r0drv/alloc-r0drv.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync r0drv/linux/alloc-r0drv-linux.o \
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync r0drv/linux/semaphore-r0drv-linux.o
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifneq ($(MAKECMDGOALS),clean)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# kernel base directory
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifndef 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. Specify KERN_DIR=<directory> and run Make again.)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(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.)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncelse
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
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# includes
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifndef KERN_INCL
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KERN_INCL = $(KERN_DIR)/include
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# module install dir.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifneq ($(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
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync endif # MODULE_DIR unspecified
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# guess kernel version (24 or 26)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncKERN_VERSION := 24
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncelse
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncKERN_VERSION := 26
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
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))
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync#
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync# Compiler options
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
87c5113417e917cdf64545d4f8e0a27047cea783vboxsyncifndef INCL
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync ifndef KBUILD_EXTMOD
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync KBUILD_EXTMOD := $(shell pwd)
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync export INCL
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncendif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncKFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -D_X86_ -DIN_RT_R0 -DIN_SUP_R0 \
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync -DVBGL_VBOXGUEST -DVBOX_HGCM -DLOG_TO_BACKDOOR
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync#KFLAGS += -DDEBUG
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#endif
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncifeq ($(KERN_VERSION), 24)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
476493afbafe452ee52b3b3b2bb77e07e5e56285vboxsync# 2.4
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncCFLAGS := -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncMODULE_EXT := o
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# 2.4 Module linking
dc45a8f3e936581748c248e00ce572cfe3ea331evboxsync$(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
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncMODULE_EXT := ko
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync$(MODULE)-y := $(OBJS)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync# build defs
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncall: $(MODULE)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncobj-m += $(MODULE).o
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync$(MODULE):
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncendif
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncinstall: $(MODULE)
476493afbafe452ee52b3b3b2bb77e07e5e56285vboxsync @mkdir -p $(MODULE_DIR); \
81c6115ff3bb02e166ee8f762d30c4ba5e3db08avboxsync install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
81c6115ff3bb02e166ee8f762d30c4ba5e3db08avboxsync PATH="$(PATH):/bin:/sbin" depmod -ae;
81c6115ff3bb02e166ee8f762d30c4ba5e3db08avboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncendif # eq($(MAKECMDGOALS),clean)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncclean:
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync rm -rf .vboxadd* .tmp_ver* vboxadd.* Module.symvers Modules.symvers
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync