VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/linux/Makefile@ 4920

Last change on this file since 4920 was 4829, checked in by vboxsync, 17 years ago

inverted VBOX_WITHOUT_IDT_PATCHING.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1#
2# Makefile for the VirtualBox Linux Host Driver.
3# (For 2.6.x this file must be called 'Makefile'!)
4#
5
6#
7#
8# Copyright (C) 2006 innotek GmbH
9#
10# This file is part of VirtualBox Open Source Edition (OSE), as
11# available from http://www.virtualbox.org. This file is free software;
12# you can redistribute it and/or modify it under the terms of the GNU
13# General Public License as published by the Free Software Foundation,
14# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15# distribution. VirtualBox OSE is distributed in the hope that it will
16# be useful, but WITHOUT ANY WARRANTY of any kind.
17
18#
19# First, figure out which architecture we're targeting.
20# (We have to support basic cross building (ARCH=i386|x86_64).)
21#
22ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
23 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
24 BUILD_TARGET_ARCH :=
25endif
26ifeq ($(BUILD_TARGET_ARCH),)
27 ifeq ($(ARCH),x86_64)
28 BUILD_TARGET_ARCH := amd64
29 else
30 ifeq ($(ARCH),i386)
31 BUILD_TARGET_ARCH := x86
32 else
33 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
34 BUILD_TARGET_ARCH := amd64
35 else
36 BUILD_TARGET_ARCH := x86
37 endif
38 endif
39 endif
40endif
41
42
43MODULE = vboxdrv
44OBJS = \
45 linux/SUPDrv-linux.o \
46 SUPDRVShared.o \
47 r0drv/alloc-r0drv.o \
48 r0drv/initterm-r0drv.o \
49 r0drv/linux/alloc-r0drv-linux.o \
50 r0drv/linux/initterm-r0drv-linux.o \
51 r0drv/linux/process-r0drv-linux.o \
52 r0drv/linux/semaphore-r0drv-linux.o \
53 r0drv/linux/spinlock-r0drv-linux.o \
54 r0drv/linux/thread-r0drv-linux.o
55ifeq ($(BUILD_TARGET_ARCH),amd64)
56OBJS += alloc/heapsimple.o
57endif
58
59ifneq ($(MAKECMDGOALS),clean)
60
61# kernel base directory
62ifndef KERN_DIR
63 KERN_DIR := /lib/modules/$(shell uname -r)/build
64 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
65 KERN_DIR := /usr/src/linux
66 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
67 $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
68 endif
69 $(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.)
70 endif
71else
72 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
73 $(error Error: KERN_DIR does not point to a directory.)
74 endif
75endif
76
77# includes
78ifndef KERN_INCL
79 KERN_INCL = $(KERN_DIR)/include
80endif
81ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
82 $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
83endif
84
85# module install dir.
86ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
87 ifndef MODULE_DIR
88 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
89 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
90 MODULE_DIR := $(MODULE_DIR_TST)/misc
91 else
92 $(error Unable to find the folder to install the support driver to)
93 endif
94 endif # MODULE_DIR unspecified
95endif
96
97# guess kernel version (24 or 26)
98KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
99
100# debug - show guesses.
101ifdef DEBUG
102$(warning dbg: KERN_DIR = $(KERN_DIR))
103$(warning dbg: KERN_INCL = $(KERN_INCL))
104$(warning dbg: MODULE_DIR = $(MODULE_DIR))
105$(warning dbg: KERN_VERSION = $(KERN_VERSION))
106endif
107
108#
109# Compiler options
110#
111ifndef INCL
112 INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
113 ifndef KBUILD_EXTMOD
114 KBUILD_EXTMOD := $(shell pwd)
115 endif
116 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
117 export INCL
118endif
119KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX_WITH_IDT_PATCHING
120ifndef CONFIG_VBOXDRV_FIXEDMAJOR
121 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
122endif
123ifeq ($(BUILD_TARGET_ARCH),amd64)
124 KFLAGS += -DRT_ARCH_AMD64
125else
126 KFLAGS += -DRT_ARCH_X86
127endif
128#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
129#KFLAGS += -DDEBUG
130#endif
131
132#
133# Use the RTR0MemObj API - testing.
134# If this makes testboxes crash/burn/leak disable it and add a comment to defect #2116.
135#
136KFLAGS += -DUSE_NEW_OS_INTERFACE_FOR_MM
137OBJS += r0drv/memobj-r0drv.o \
138 r0drv/linux/memobj-r0drv-linux.o
139ifeq ($(BUILD_TARGET_ARCH),x86) # Some gcc versions ends up needing __divdi3.
140OBJS += math/gcc/qdivrem.o \
141 math/gcc/divdi3.o
142endif
143
144ifeq ($(KERN_VERSION), 24)
145# 2.4
146TOPDIR = $(KERN_DIR)
147MODULE_EXT := o
148EXTRA_CFLAGS := -DVBOX_LINUX_2_4
149$(MODULE)-objs = $(OBJS)
150else
151# 2.6 and later
152MODULE_EXT := ko
153$(MODULE)-y := $(OBJS)
154endif
155
156# build defs
157EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
158
159all: $(MODULE)
160
161obj-m += $(MODULE).o
162
163$(MODULE):
164 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
165
166ifeq ($(KERN_VERSION), 24)
167#
168# 2.4 Module linking
169#
170$(MODULE).o: $(OBJS)
171 $(LD) -o $@ -r $(OBJS)
172
173include $(KERN_DIR)/Rules.make
174
175endif
176
177install: $(MODULE)
178 @mkdir -p $(MODULE_DIR); \
179 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
180 PATH="$(PATH):/bin:/sbin" depmod -ae; \
181 rm -f /etc/vbox/module_not_compiled
182
183install_rpm: $(MODULE)
184 @mkdir -p $(MODULE_DIR); \
185 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
186
187endif # eq($(MAKECMDGOALS),clean)
188
189clean:
190 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
191 rm -rf .vboxdrv* .tmp_ver* vboxdrv.* Module.symvers Modules.symvers
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette