Makefile.module revision d5970636432753b4744f46c4da07184be36d2c5a
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# VirtualBox Guest Additions Module Makefile.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync# (For 2.6.x this file must be 'Makefile'!)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# Copyright (C) 2006 InnoTek Systemberatung GmbH
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# available from http://www.virtualbox.org. This file is free software;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# you can redistribute it and/or modify it under the terms of the GNU
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# General Public License as published by the Free Software Foundation,
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# distribution. VirtualBox OSE is distributed in the hope that it will
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# be useful, but WITHOUT ANY WARRANTY of any kind.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# If you received this file as part of a commercial VirtualBox
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# distribution, then only the terms of your commercial VirtualBox
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# license agreement apply instead of the previous paragraph.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncMODULE = vboxadd
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync# Where is everything?
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsyncifeq ($(KERN_DIR),)
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsyncKERN_DIR_CUR := /lib/modules/$(shell uname -r)/build
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsyncifeq ($(shell if test -d $(KERN_DIR_CUR); then echo yes; fi),yes)
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsyncKERN_DIR := $(KERN_DIR_CUR)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync$(warning Warning: defaulting kernel sources to $(KERN_DIR). Specify KERN_DIR=<right-place> if this is not right.)
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncifeq ($(KERN_INCL),)
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ifeq ($(shell if test -d $(KERN_DIR)/include; then echo yes; fi),yes)
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync KERN_INCL = $(KERN_DIR)/include
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync# Instead of sticking to the standards, OpenSUSE 10.2 only puts a few include
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync# files in /lib/modules/$(uname -r)/build/include, and puts the rest in
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync# /lib/modules/$(uname -r)/source/include, which points into the kernel sources
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync EXTRA_INCL = /lib/modules/$(shell uname -r)/source/include
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync $(warning Warning: defaulting to the includes in $(KERN_INCL). Specify KERN_INCL=<right-place> if this is not right.)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync# Module install dir.
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncifndef MODULE_DIR
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncMODULE_DIR_TST := /lib/modules/$(shell uname -r)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncMODULE_DIR := $(MODULE_DIR_TST)/misc
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync# MODULE_DIR := .
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync$(error Unable to find the folder to install the additions driver to)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncendif # MODULE_DIR unspecified
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync# guess kernel version (24 or 26)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncKERN_VERSION := 24
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncKERN_VERSION := 26
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync# KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync# debug - show guesses.
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync$(warning dbg: KERN_DIR = $(KERN_DIR))
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync$(warning dbg: KERN_INCL = $(KERN_INCL))
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync$(warning dbg: MODULE_DIR = $(MODULE_DIR))
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync$(warning dbg: KERN_VERSION = $(KERN_VERSION))
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync# Compiler options
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync ifndef KBUILD_EXTMOD
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync KBUILD_EXTMOD := $(shell pwd)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync export INCL
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncKFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -D_X86_ -DIN_RT_R0 -DIN_SUP_R0 -DVBGL_VBOXGUEST -DVBGL_HGCM -DVBOX_HGCM
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync#KFLAGS += -DDEBUG
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncifeq ($(KERN_VERSION), 24)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncCFLAGS := -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncMODULE_EXT := o
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync# 2.4 Module linking
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync$(MODULE).o: $(OBJS)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync $(LD) -o $@ -r $(OBJS)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync.PHONY: $(MODULE)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncall: $(MODULE)
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync$(MODULE): $(MODULE).o
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync# 2.6 and later
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncMODULE_EXT := ko
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync$(MODULE)-y := $(OBJS)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync# build defs
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncEXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncall: $(MODULE)
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncobj-m += $(MODULE).o
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncinstall: $(MODULE)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync @mkdir -p $(MODULE_DIR); \
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync PATH="$(PATH):/bin:/sbin" depmod -ae;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync rm -rf *.o .*.cmd .*.flags