VirtualBox

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

Last change on this file since 2676 was 2099, checked in by vboxsync, 17 years ago

Fixed a typo in the Linux kernel module makefiles

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 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 Systemberatung 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# If you received this file as part of a commercial VirtualBox
19# distribution, then only the terms of your commercial VirtualBox
20# license agreement apply instead of the previous paragraph.
21#
22
23#
24# First, figure out which architecture we're targeting.
25# (We have to support basic cross building (ARCH=i386|x86_64).)
26#
27ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
28 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
29 BUILD_TARGET_ARCH :=
30endif
31ifeq ($(BUILD_TARGET_ARCH),)
32 ifeq ($(ARCH),x86_64)
33 BUILD_TARGET_ARCH := amd64
34 else
35 ifeq ($(ARCH),i386)
36 BUILD_TARGET_ARCH := x86
37 else
38 ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
39 BUILD_TARGET_ARCH := amd64
40 else
41 BUILD_TARGET_ARCH := x86
42 endif
43 endif
44 endif
45endif
46
47
48MODULE = vboxdrv
49OBJS = \
50 linux/SUPDrv-linux.o \
51 SUPDRVShared.o \
52 r0drv/alloc-r0drv.o \
53 r0drv/initterm-r0drv.o \
54 r0drv/linux/alloc-r0drv-linux.o \
55 r0drv/linux/initterm-r0drv-linux.o \
56 r0drv/linux/process-r0drv-linux.o \
57 r0drv/linux/semaphore-r0drv-linux.o \
58 r0drv/linux/spinlock-r0drv-linux.o \
59 r0drv/linux/thread-r0drv-linux.o
60ifeq ($(BUILD_TARGET_ARCH),amd64)
61OBJS += alloc/heapsimple.o
62endif
63
64
65ifneq ($(MAKECMDGOALS),clean)
66
67# kernel base directory
68ifndef KERN_DIR
69 KERN_DIR := /lib/modules/$(shell uname -r)/build
70 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
71 KERN_DIR := /usr/src/linux
72 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
73 $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
74 endif
75 $(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.)
76 endif
77else
78 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
79 $(error Error: KERN_DIR does not point to a directory.)
80 endif
81endif
82
83# includes
84ifndef KERN_INCL
85 KERN_INCL = $(KERN_DIR)/include
86endif
87ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
88 $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
89endif
90
91# module install dir.
92ifndef MODULE_DIR
93 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
94 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
95 MODULE_DIR := $(MODULE_DIR_TST)/misc
96 else
97 $(error Unable to find the folder to install the support driver to)
98 endif
99endif # MODULE_DIR unspecified
100
101# guess kernel version (24 or 26)
102KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
103
104# debug - show guesses.
105ifdef DEBUG
106$(warning dbg: KERN_DIR = $(KERN_DIR))
107$(warning dbg: KERN_INCL = $(KERN_INCL))
108$(warning dbg: MODULE_DIR = $(MODULE_DIR))
109$(warning dbg: KERN_VERSION = $(KERN_VERSION))
110endif
111
112#
113# Compiler options
114#
115ifndef INCL
116 INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
117 ifndef KBUILD_EXTMOD
118 KBUILD_EXTMOD := $(shell pwd)
119 endif
120 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
121 export INCL
122endif
123KFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0
124ifndef CONFIG_VBOXDRV_FIXEDMAJOR
125 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
126endif
127ifeq ($(BUILD_TARGET_ARCH),amd64)
128 KFLAGS += -D__AMD64__
129else
130 KFLAGS += -D__X86__
131endif
132#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
133#KFLAGS += -DDEBUG
134#endif
135
136ifeq ($(KERN_VERSION), 24)
137# 2.4
138TOPDIR = $(KERN_DIR)
139MODULE_EXT := o
140EXTRA_CFLAGS := -DVBOX_LINUX_2_4
141$(MODULE)-objs = $(OBJS)
142else
143# 2.6 and later
144MODULE_EXT := ko
145$(MODULE)-y := $(OBJS)
146endif
147
148# build defs
149EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
150
151all: $(MODULE)
152
153obj-m += $(MODULE).o
154
155$(MODULE):
156 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
157
158ifeq ($(KERN_VERSION), 24)
159#
160# 2.4 Module linking
161#
162$(MODULE).o: $(OBJS)
163 $(LD) -o $@ -r $(OBJS)
164
165include $(KERN_DIR)/Rules.make
166
167endif
168
169install: $(MODULE)
170 @mkdir -p $(MODULE_DIR); \
171 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
172 PATH="$(PATH):/bin:/sbin" depmod -ae; \
173 rm -f /etc/vbox/module_not_compiled
174
175install_rpm: $(MODULE)
176 @mkdir -p $(MODULE_DIR); \
177 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
178
179endif # eq($(MAKECMDGOALS),clean)
180
181clean:
182 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
183 rm -rf .vboxdrv* .tmp_ver* vboxdrv.* Module.symvers Modules.symvers
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use