VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/module/Makefile.module@ 170

Last change on this file since 170 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1#
2# VirtualBox Guest Additions Module Makefile.
3#
4# (For 2.6.x this file must be 'Makefile'!)
5#
6# Copyright (C) 2006 InnoTek Systemberatung GmbH
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License as published by the Free Software Foundation,
12# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13# distribution. VirtualBox OSE is distributed in the hope that it will
14# be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16# If you received this file as part of a commercial VirtualBox
17# distribution, then only the terms of your commercial VirtualBox
18# license agreement apply instead of the previous paragraph.
19#
20
21#
22MODULE = vboxadd
23OBJS = \
24 cmc.o \
25 vboxmod.o \
26 VBoxGuestLibBaseLinux.a \
27 r0drv/alloc-r0drv.o \
28 r0drv/linux/alloc-r0drv-linux.o \
29 r0drv/linux/semaphore-r0drv-linux.o
30
31#
32# Where is everything?
33#
34ifeq ($(KERN_DIR),)
35KERN_DIR_CUR := /lib/modules/$(shell uname -r)/build
36ifeq ($(shell if test -d $(KERN_DIR_CUR); then echo yes; fi),yes)
37KERN_DIR := $(KERN_DIR_CUR)
38else
39KERN_DIR = /usr/src/linux
40$(warning Warning: defaulting kernel sources to $(KERN_DIR). Specify KERN_DIR=<right-place> if this is not right.)
41endif
42endif
43
44# includes
45ifeq ($(KERN_INCL),)
46ifeq ($(shell if test -d $(KERN_DIR)/include; then echo yes; fi),yes)
47KERN_INCL = $(KERN_DIR)/include
48else
49KERN_INCL = /usr/src/linux/include
50$(warning Warning: defaulting to the includes in $(KERN_INCL). Specify KERN_INCL=<right-place> if this is not right.)
51endif
52endif
53
54# Module install dir.
55ifndef MODULE_DIR
56MODULE_DIR_TST := /lib/modules/$(shell uname -r)
57ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
58MODULE_DIR := $(MODULE_DIR_TST)/misc
59else
60# MODULE_DIR := .
61$(error Unable to find the folder to install the additions driver to)
62endif
63endif # MODULE_DIR unspecified
64
65# guess kernel version (24 or 26)
66ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
67KERN_VERSION := 24
68else
69KERN_VERSION := 26
70endif
71# KERN_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#
83# Compiler options
84#
85ifndef INCL
86INCL := -I$(KERN_INCL) -I$(shell pwd) -I$(shell pwd)/include -I$(shell pwd)/r0drv/linux
87export INCL
88endif
89KFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -D_X86_ -DIN_RT_R0 -DIN_SUP_R0 -DVBGL_VBOXGUEST -DVBGL_HGCM -DVBOX_HGCM
90#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
91#KFLAGS += -DDEBUG
92#endif
93
94ifeq ($(KERN_VERSION), 24)
95#
96# 2.4
97#
98
99CFLAGS := -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
100MODULE_EXT := o
101
102# 2.4 Module linking
103$(MODULE).o: $(OBJS)
104 $(LD) -o $@ -r $(OBJS)
105
106.PHONY: $(MODULE)
107all: $(MODULE)
108$(MODULE): $(MODULE).o
109
110else
111#
112# 2.6 and later
113#
114
115MODULE_EXT := ko
116
117$(MODULE)-y := $(OBJS)
118
119# build defs
120EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
121
122all: $(MODULE)
123
124obj-m += $(MODULE).o
125
126$(MODULE):
127 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
128
129endif
130
131install: $(MODULE)
132 @mkdir -p $(MODULE_DIR); \
133 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
134 PATH="$(PATH):/bin:/sbin" depmod -ae;
135
136clean:
137 rm -rf *.o .*.cmd .*.flags
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