VirtualBox

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

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

Fixed the kernel module makefiles for OpenSUSE's non-standard build system

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