VirtualBox

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

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

Additional Linux installer makefile fixes

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 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),)
46 ifeq ($(shell if test -d $(KERN_DIR)/include; then echo yes; fi),yes)
47 KERN_INCL = $(KERN_DIR)/include
48# Instead of sticking to the standards, OpenSUSE 10.2 only puts a few include
49# files in /lib/modules/$(uname -r)/build/include, and puts the rest in
50# /lib/modules/$(uname -r)/source/include, which points into the kernel sources
51 EXTRA_INCL = /lib/modules/$(shell uname -r)/source/include
52 else
53 KERN_INCL = /usr/src/linux/include
54 $(warning Warning: defaulting to the includes in $(KERN_INCL). Specify KERN_INCL=<right-place> if this is not right.)
55 endif
56endif
57
58# Module install dir.
59ifndef MODULE_DIR
60MODULE_DIR_TST := /lib/modules/$(shell uname -r)
61ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
62MODULE_DIR := $(MODULE_DIR_TST)/misc
63else
64# MODULE_DIR := .
65$(error Unable to find the folder to install the additions driver to)
66endif
67endif # MODULE_DIR unspecified
68
69# guess kernel version (24 or 26)
70ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
71KERN_VERSION := 24
72else
73KERN_VERSION := 26
74endif
75# KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
76
77# debug - show guesses.
78ifdef DEBUG
79$(warning dbg: KERN_DIR = $(KERN_DIR))
80$(warning dbg: KERN_INCL = $(KERN_INCL))
81$(warning dbg: MODULE_DIR = $(MODULE_DIR))
82$(warning dbg: KERN_VERSION = $(KERN_VERSION))
83endif
84
85
86#
87# Compiler options
88#
89ifndef INCL
90 INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
91 ifndef KBUILD_EXTMOD
92 KBUILD_EXTMOD := $(shell pwd)
93 endif
94 INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
95 export INCL
96endif
97KFLAGS := -D__KERNEL__ -DMODULE -D__LINUX__ -DIN_RING0 -D_X86_ -DIN_RT_R0 -DIN_SUP_R0 -DVBGL_VBOXGUEST -DVBGL_HGCM -DVBOX_HGCM
98#ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
99#KFLAGS += -DDEBUG
100#endif
101
102ifeq ($(KERN_VERSION), 24)
103#
104# 2.4
105#
106
107CFLAGS := -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
108MODULE_EXT := o
109
110# 2.4 Module linking
111$(MODULE).o: $(OBJS)
112 $(LD) -o $@ -r $(OBJS)
113
114.PHONY: $(MODULE)
115all: $(MODULE)
116$(MODULE): $(MODULE).o
117
118else
119#
120# 2.6 and later
121#
122
123MODULE_EXT := ko
124
125$(MODULE)-y := $(OBJS)
126
127# build defs
128EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
129
130all: $(MODULE)
131
132obj-m += $(MODULE).o
133
134$(MODULE):
135 $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
136
137endif
138
139install: $(MODULE)
140 @mkdir -p $(MODULE_DIR); \
141 install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
142 PATH="$(PATH):/bin:/sbin" depmod -ae;
143
144clean:
145 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