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 | #
|
---|
22 | MODULE = vboxadd
|
---|
23 | OBJS = \
|
---|
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 | #
|
---|
34 | ifeq ($(KERN_DIR),)
|
---|
35 | KERN_DIR_CUR := /lib/modules/$(shell uname -r)/build
|
---|
36 | ifeq ($(shell if test -d $(KERN_DIR_CUR); then echo yes; fi),yes)
|
---|
37 | KERN_DIR := $(KERN_DIR_CUR)
|
---|
38 | else
|
---|
39 | KERN_DIR = /usr/src/linux
|
---|
40 | $(warning Warning: defaulting kernel sources to $(KERN_DIR). Specify KERN_DIR=<right-place> if this is not right.)
|
---|
41 | endif
|
---|
42 | endif
|
---|
43 |
|
---|
44 | # includes
|
---|
45 | ifeq ($(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
|
---|
56 | endif
|
---|
57 |
|
---|
58 | # Module install dir.
|
---|
59 | ifndef MODULE_DIR
|
---|
60 | MODULE_DIR_TST := /lib/modules/$(shell uname -r)
|
---|
61 | ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
|
---|
62 | MODULE_DIR := $(MODULE_DIR_TST)/misc
|
---|
63 | else
|
---|
64 | # MODULE_DIR := .
|
---|
65 | $(error Unable to find the folder to install the additions driver to)
|
---|
66 | endif
|
---|
67 | endif # MODULE_DIR unspecified
|
---|
68 |
|
---|
69 | # guess kernel version (24 or 26)
|
---|
70 | ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
|
---|
71 | KERN_VERSION := 24
|
---|
72 | else
|
---|
73 | KERN_VERSION := 26
|
---|
74 | endif
|
---|
75 | # KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
|
---|
76 |
|
---|
77 | # debug - show guesses.
|
---|
78 | ifdef 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))
|
---|
83 | endif
|
---|
84 |
|
---|
85 |
|
---|
86 | #
|
---|
87 | # Compiler options
|
---|
88 | #
|
---|
89 | ifndef 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
|
---|
96 | endif
|
---|
97 | KFLAGS := -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 |
|
---|
102 | ifeq ($(KERN_VERSION), 24)
|
---|
103 | #
|
---|
104 | # 2.4
|
---|
105 | #
|
---|
106 |
|
---|
107 | CFLAGS := -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
|
---|
108 | MODULE_EXT := o
|
---|
109 |
|
---|
110 | # 2.4 Module linking
|
---|
111 | $(MODULE).o: $(OBJS)
|
---|
112 | $(LD) -o $@ -r $(OBJS)
|
---|
113 |
|
---|
114 | .PHONY: $(MODULE)
|
---|
115 | all: $(MODULE)
|
---|
116 | $(MODULE): $(MODULE).o
|
---|
117 |
|
---|
118 | else
|
---|
119 | #
|
---|
120 | # 2.6 and later
|
---|
121 | #
|
---|
122 |
|
---|
123 | MODULE_EXT := ko
|
---|
124 |
|
---|
125 | $(MODULE)-y := $(OBJS)
|
---|
126 |
|
---|
127 | # build defs
|
---|
128 | EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
|
---|
129 |
|
---|
130 | all: $(MODULE)
|
---|
131 |
|
---|
132 | obj-m += $(MODULE).o
|
---|
133 |
|
---|
134 | $(MODULE):
|
---|
135 | $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
|
---|
136 |
|
---|
137 | endif
|
---|
138 |
|
---|
139 | install: $(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 |
|
---|
144 | clean:
|
---|
145 | rm -rf *.o .*.cmd .*.flags
|
---|