VirtualBox

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

Last change on this file since 4071 was 4071, checked in by vboxsync, 18 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 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
59
60ifneq ($(MAKECMDGOALS),clean)
61
62# kernel base directory
63ifndef KERN_DIR
64 KERN_DIR := /lib/modules/$(shell uname -r)/build
65 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
66 KERN_DIR := /usr/src/linux
67 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
68 $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
69 endif
70 $(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.)
71 endif
72else
73 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
74 $(error Error: KERN_DIR does not point to a directory.)
75 endif
76endif
77
78# includes
79ifndef KERN_INCL
80 KERN_INCL = $(KERN_DIR)/include
81endif
82ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
83 $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
84endif
85
86# module install dir.
87ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
88 ifndef MODULE_DIR
89 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
90 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
91 MODULE_DIR := $(MODULE_DIR_TST)/misc
92 else
93 $(error Unable to find the folder to install the support driver to)
94 endif
95 endif # MODULE_DIR unspecified
96endif
97
98# guess kernel version (24 or 26)
99KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
100
101# debug - show guesses.
102ifdef DEBUG
103$(warning dbg: KERN_DIR = $(KERN_DIR))
104$(warning dbg: KERN_INCL = $(KERN_INCL))
105$(warning dbg: MODULE_DIR = $(MODULE_DIR))
106$(warning dbg: KERN_VERSION = $(KERN_VERSION))
107endif
108
109#
110# Compiler options
111#
112ifndef INCL
113 INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
114 ifndef KBUILD_EXTMOD
115 KBUILD_EXTMOD := $(shell pwd)
116 endif
117 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
118 export INCL
119endif
120KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0
121ifndef CONFIG_VBOXDRV_FIXEDMAJOR
122 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
123endif
124ifeq ($(BUILD_TARGET_ARCH),amd64)
125 KFLAGS += -DRT_ARCH_AMD64
126else
127 KFLAGS += -DRT_ARCH_X86
128endif
129#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
130#KFLAGS += -DDEBUG
131#endif
132
133ifeq ($(KERN_VERSION), 24)
134# 2.4
135TOPDIR = $(KERN_DIR)
136MODULE_EXT := o
137EXTRA_CFLAGS := -DVBOX_LINUX_2_4
138$(MODULE)-objs = $(OBJS)
139else
140# 2.6 and later
141MODULE_EXT := ko
142$(MODULE)-y := $(OBJS)
143endif
144
145# build defs
146EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
147
148all: $(MODULE)
149
150obj-m += $(MODULE).o
151
152$(MODULE):
153 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
154
155ifeq ($(KERN_VERSION), 24)
156#
157# 2.4 Module linking
158#
159$(MODULE).o: $(OBJS)
160 $(LD) -o $@ -r $(OBJS)
161
162include $(KERN_DIR)/Rules.make
163
164endif
165
166install: $(MODULE)
167 @mkdir -p $(MODULE_DIR); \
168 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
169 PATH="$(PATH):/bin:/sbin" depmod -ae; \
170 rm -f /etc/vbox/module_not_compiled
171
172install_rpm: $(MODULE)
173 @mkdir -p $(MODULE_DIR); \
174 install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
175
176endif # eq($(MAKECMDGOALS),clean)
177
178clean:
179 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
180 rm -rf .vboxdrv* .tmp_ver* vboxdrv.* Module.symvers Modules.symvers
Note: See TracBrowser for help on using the repository browser.

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