VirtualBox

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

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

make 'make -C <linux> M=$(pwd)' work

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 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
23MODULE = vboxdrv
24OBJS = \
25 linux/SUPDrv-linux.o \
26 SUPDRVShared.o \
27 r0drv/alloc-r0drv.o \
28 r0drv/linux/alloc-r0drv-linux.o \
29 r0drv/linux/semaphore-r0drv-linux.o \
30 r0drv/linux/spinlock-r0drv-linux.o \
31 r0drv/linux/thread-r0drv-linux.o \
32
33ifneq ($(MAKECMDGOALS),clean)
34
35# kernel base directory
36ifndef $(KERN_DIR)
37 KERN_DIR := /lib/modules/$(shell uname -r)/build
38 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
39 KERN_DIR := /usr/src/linux
40 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
41 $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
42 endif
43 $(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.)
44 endif
45else
46 ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
47 $(error Error: KERN_DIR does not point to a directory.)
48 endif
49endif
50
51# includes
52ifndef $(KERN_INCL)
53 KERN_INCL = $(KERN_DIR)/include
54 $(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.)
55endif
56ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
57 $(error Error: unable to find the include directory for your current Linux kernel. Specify $KERN_INCL=<directory> and run Make again.)
58endif
59
60# module install dir.
61ifndef MODULE_DIR
62 MODULE_DIR_TST := /lib/modules/$(shell uname -r)
63 ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
64 MODULE_DIR := $(MODULE_DIR_TST)/misc
65 else
66 $(error Error: could not find the module directory for your current Linux kernel)
67 endif
68endif # MODULE_DIR unspecified
69
70# guess kernel version (24 or 26)
71KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
72
73# debug - show guesses.
74ifdef DEBUG
75$(warning dbg: KERN_DIR = $(KERN_DIR))
76$(warning dbg: KERN_INCL = $(KERN_INCL))
77$(warning dbg: MODULE_DIR = $(MODULE_DIR))
78$(warning dbg: KERN_VERSION = $(KERN_VERSION))
79endif
80
81#
82# Compiler options
83#
84ifndef INCL
85 INCL := -I$(KERN_INCL)
86 ifndef KBUILD_EXTMOD
87 KBUILD_EXTMOD := $(shell pwd)
88 endif
89 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
90 export INCL
91endif
92KFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0
93ifndef CONFIG_VBOXDRV_FIXEDMAJOR
94 KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
95endif
96ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
97 KFLAGS += -D__AMD64__
98else
99 KFLAGS += -D__X86__
100endif
101#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
102#KFLAGS += -DDEBUG
103#endif
104
105ifeq ($(KERN_VERSION), 24)
106# 2.4
107TOPDIR = $(KERN_DIR)
108MODULE_EXT := o
109EXTRA_CFLAGS := -DVBOX_LINUX_2_4
110$(MODULE)-objs = $(OBJS)
111else
112# 2.6 and later
113MODULE_EXT := ko
114$(MODULE)-y := $(OBJS)
115endif
116
117# build defs
118EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
119
120all: $(MODULE)
121
122obj-m += $(MODULE).o
123
124$(MODULE):
125 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
126
127ifeq ($(KERN_VERSION), 24)
128#
129# 2.4 Module linking
130#
131$(MODULE).o: $(OBJS)
132 $(LD) -o $@ -r $(OBJS)
133
134include $(KERN_DIR)/Rules.make
135
136endif
137
138install: $(MODULE)
139 @mkdir -p $(MODULE_DIR); \
140 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
141 PATH="$(PATH):/bin:/sbin" depmod -ae; \
142 rm -f /etc/vbox/module_not_compiled
143
144endif # eq($(MAKECMDGOALS),clean)
145
146clean:
147 for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
148 rm -rf .vboxdrv* .tmp_ver* vboxdrv.* Module.symvers Modules.symvers
149
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