Makefile revision 5b018141f78fdc3b01c113e0d529599ce75867d7
2035N/A#
2035N/A# Makefile for the VirtualBox Linux Host Driver.
2035N/A# (For 2.6.x this file must be called 'Makefile'!)
2035N/A#
2035N/A
2035N/A#
2035N/A#
2035N/A# Copyright (C) 2006 InnoTek Systemberatung GmbH
2035N/A#
2035N/A# This file is part of VirtualBox Open Source Edition (OSE), as
2035N/A# available from http://www.virtualbox.org. This file is free software;
2035N/A# you can redistribute it and/or modify it under the terms of the GNU
2035N/A# General Public License as published by the Free Software Foundation,
2035N/A# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
2035N/A# distribution. VirtualBox OSE is distributed in the hope that it will
2035N/A# be useful, but WITHOUT ANY WARRANTY of any kind.
2035N/A#
2035N/A# If you received this file as part of a commercial VirtualBox
2035N/A# distribution, then only the terms of your commercial VirtualBox
2035N/A# license agreement apply instead of the previous paragraph.
3998N/A#
3998N/A
5403N/AMODULE = vboxdrv
2035N/AOBJS = \
3817N/A linux/SUPDrv-linux.o \
3817N/A SUPDRVShared.o \
3817N/A r0drv/alloc-r0drv.o \
2035N/A r0drv/linux/alloc-r0drv-linux.o \
2035N/A r0drv/linux/semaphore-r0drv-linux.o \
2035N/A r0drv/linux/spinlock-r0drv-linux.o \
5403N/A r0drv/linux/thread-r0drv-linux.o \
2035N/A
2035N/Aifneq ($(MAKECMDGOALS),clean)
2035N/A
5403N/A# kernel base directory
2035N/Aifndef $(KERN_DIR)
2035N/A KERN_DIR := /lib/modules/$(shell uname -r)/build
2035N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2035N/A KERN_DIR := /usr/src/linux
5403N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2818N/A $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
3817N/A endif
3817N/A $(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.)
3817N/A endif
2035N/Aelse
2035N/A ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
2035N/A $(error Error: KERN_DIR does not point to a directory.)
2232N/A endif
2035N/Aendif
2035N/A
2035N/A# includes
2035N/Aifndef $(KERN_INCL)
3497N/A KERN_INCL = $(KERN_DIR)/include
3497N/A $(info Info: using $(KERN_INCL) as the include directory of your Linux kernel. If this is not correct, specify KERN_INCL=<directory> and run Make again.)
2035N/Aendif
3998N/Aifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
2035N/A $(error Error: unable to find the include directory for your current Linux kernel. Specify $KERN_INCL=<directory> and run Make again.)
2035N/Aendif
2035N/A
2035N/A# module install dir.
2035N/Aifndef MODULE_DIR
2035N/A MODULE_DIR_TST := /lib/modules/$(shell uname -r)
2035N/A ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
2035N/A MODULE_DIR := $(MODULE_DIR_TST)/misc
2035N/A else
2035N/A $(error Error: could not find the module directory for your current Linux kernel)
2035N/A endif
2035N/Aendif # MODULE_DIR unspecified
2035N/A
4337N/A# guess kernel version (24 or 26)
4337N/AKERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
3998N/A
3817N/A# debug - show guesses.
ifdef DEBUG
$(warning dbg: KERN_DIR = $(KERN_DIR))
$(warning dbg: KERN_INCL = $(KERN_INCL))
$(warning dbg: MODULE_DIR = $(MODULE_DIR))
$(warning dbg: KERN_VERSION = $(KERN_VERSION))
endif
#
# Compiler options
#
ifndef INCL
INCL := -I$(KERN_INCL) -I$(shell pwd) -I$(shell pwd)/include -I$(shell pwd)/r0drv/linux
export INCL
endif
KFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0
ifndef CONFIG_VBOXDRV_FIXEDMAJOR
KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
endif
ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
KFLAGS += -D__AMD64__
else
KFLAGS += -D__X86__
endif
#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
#KFLAGS += -DDEBUG
#endif
ifeq ($(KERN_VERSION), 24)
# 2.4
TOPDIR = $(KERN_DIR)
MODULE_EXT := o
EXTRA_CFLAGS := -DVBOX_LINUX_2_4
$(MODULE)-objs = $(OBJS)
else
# 2.6 and later
MODULE_EXT := ko
$(MODULE)-y := $(OBJS)
endif
# build defs
EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
all: $(MODULE)
obj-m += $(MODULE).o
$(MODULE):
$(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
ifeq ($(KERN_VERSION), 24)
#
# 2.4 Module linking
#
$(MODULE).o: $(OBJS)
$(LD) -o $@ -r $(OBJS)
include $(KERN_DIR)/Rules.make
endif
install: $(MODULE)
@mkdir -p $(MODULE_DIR); \
install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
PATH="$(PATH):/bin:/sbin" depmod -ae; \
rm -f /etc/vbox/module_not_compiled
endif # eq($(MAKECMDGOALS),clean)
clean:
for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
rm -rf .vboxdrv* .tmp_ver* vboxdrv.* Module.symvers Modules.symvers