1 | #
|
---|
2 | # VirtualBox Guest Additions Module Makefile.
|
---|
3 | #
|
---|
4 | # (For 2.6.x this file must be 'Makefile'!)
|
---|
5 | #
|
---|
6 | # Copyright (C) 2006-2007 innotek 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 | #
|
---|
17 | MODULE = vboxadd
|
---|
18 | OBJS = \
|
---|
19 | cmc.o \
|
---|
20 | hgcmcall.o \
|
---|
21 | vboxmod.o \
|
---|
22 | GenericRequest.o \
|
---|
23 | PhysHeap.o \
|
---|
24 | SysHlp.o \
|
---|
25 | Init.o \
|
---|
26 | VMMDev.o \
|
---|
27 | HGCMInternal.o \
|
---|
28 | r0drv/alloc-r0drv.o \
|
---|
29 | r0drv/linux/alloc-r0drv-linux.o \
|
---|
30 | r0drv/linux/semaphore-r0drv-linux.o
|
---|
31 |
|
---|
32 | ifneq ($(MAKECMDGOALS),clean)
|
---|
33 |
|
---|
34 | # kernel base directory
|
---|
35 | ifndef KERN_DIR
|
---|
36 | KERN_DIR := /lib/modules/$(shell uname -r)/build
|
---|
37 | ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
|
---|
38 | KERN_DIR := /usr/src/linux
|
---|
39 | ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
|
---|
40 | $(error Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.)
|
---|
41 | endif
|
---|
42 | $(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.)
|
---|
43 | endif
|
---|
44 | else
|
---|
45 | ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
|
---|
46 | $(error Error: KERN_DIR does not point to a directory.)
|
---|
47 | endif
|
---|
48 | endif
|
---|
49 |
|
---|
50 | # includes
|
---|
51 | ifndef KERN_INCL
|
---|
52 | KERN_INCL = $(KERN_DIR)/include
|
---|
53 | endif
|
---|
54 | ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
|
---|
55 | $(error Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.)
|
---|
56 | endif
|
---|
57 |
|
---|
58 | # module install dir.
|
---|
59 | ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
|
---|
60 | ifndef MODULE_DIR
|
---|
61 | MODULE_DIR_TST := /lib/modules/$(shell uname -r)
|
---|
62 | ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
|
---|
63 | MODULE_DIR := $(MODULE_DIR_TST)/misc
|
---|
64 | else
|
---|
65 | $(error Unable to find the folder to install the additions driver to)
|
---|
66 | endif
|
---|
67 | endif # MODULE_DIR unspecified
|
---|
68 | endif
|
---|
69 |
|
---|
70 | # guess kernel version (24 or 26)
|
---|
71 | ifeq ($(shell if grep '"2.4.' $(KERN_INCL)/linux/version.h > /dev/null; then echo yes; fi),yes)
|
---|
72 | KERN_VERSION := 24
|
---|
73 | else
|
---|
74 | KERN_VERSION := 26
|
---|
75 | endif
|
---|
76 | # KERN_VERSION := $(if $(wildcard $(KERN_DIR)/Rules.make),24,26)
|
---|
77 |
|
---|
78 | # debug - show guesses.
|
---|
79 | ifdef DEBUG
|
---|
80 | $(warning dbg: KERN_DIR = $(KERN_DIR))
|
---|
81 | $(warning dbg: KERN_INCL = $(KERN_INCL))
|
---|
82 | $(warning dbg: MODULE_DIR = $(MODULE_DIR))
|
---|
83 | $(warning dbg: KERN_VERSION = $(KERN_VERSION))
|
---|
84 | endif
|
---|
85 |
|
---|
86 |
|
---|
87 | #
|
---|
88 | # Compiler options
|
---|
89 | #
|
---|
90 | ifndef INCL
|
---|
91 | INCL := -I$(KERN_INCL) $(addprefix -I, $(EXTRA_INCL))
|
---|
92 | ifndef KBUILD_EXTMOD
|
---|
93 | KBUILD_EXTMOD := $(shell pwd)
|
---|
94 | endif
|
---|
95 | INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
|
---|
96 | export INCL
|
---|
97 | endif
|
---|
98 | KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -D_X86_ -DIN_RT_R0 -DIN_SUP_R0 \
|
---|
99 | -DVBGL_VBOXGUEST -DVBOX_HGCM -DLOG_TO_BACKDOOR
|
---|
100 | #ifeq ($(BUILD_TYPE),debug) - you'll have to enable this manually to get debug stuff.
|
---|
101 | #KFLAGS += -DDEBUG
|
---|
102 | #endif
|
---|
103 |
|
---|
104 | ifeq ($(KERN_VERSION), 24)
|
---|
105 | #
|
---|
106 | # 2.4
|
---|
107 | #
|
---|
108 |
|
---|
109 | CFLAGS := -DVBOX_LINUX_2_4 -DEXPORT_SYMTAB $(INCL) $(KFLAGS) $(KDEBUG)
|
---|
110 | MODULE_EXT := o
|
---|
111 |
|
---|
112 | # 2.4 Module linking
|
---|
113 | $(MODULE).o: $(OBJS)
|
---|
114 | $(LD) -o $@ -r $(OBJS)
|
---|
115 |
|
---|
116 | .PHONY: $(MODULE)
|
---|
117 | all: $(MODULE)
|
---|
118 | $(MODULE): $(MODULE).o
|
---|
119 |
|
---|
120 | else
|
---|
121 | #
|
---|
122 | # 2.6 and later
|
---|
123 | #
|
---|
124 |
|
---|
125 | MODULE_EXT := ko
|
---|
126 |
|
---|
127 | $(MODULE)-y := $(OBJS)
|
---|
128 |
|
---|
129 | # build defs
|
---|
130 | EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
|
---|
131 |
|
---|
132 | all: $(MODULE)
|
---|
133 |
|
---|
134 | obj-m += $(MODULE).o
|
---|
135 |
|
---|
136 | $(MODULE):
|
---|
137 | $(MAKE) KBUILD_VERBOSE=1 -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) modules
|
---|
138 |
|
---|
139 | endif
|
---|
140 |
|
---|
141 | install: $(MODULE)
|
---|
142 | @mkdir -p $(MODULE_DIR); \
|
---|
143 | install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
|
---|
144 | PATH="$(PATH):/bin:/sbin" depmod -ae;
|
---|
145 |
|
---|
146 | endif # eq($(MAKECMDGOALS),clean)
|
---|
147 |
|
---|
148 | clean:
|
---|
149 | for f in . linux r0drv r0drv/linux; do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
|
---|
150 | rm -rf .vboxadd* .tmp_ver* vboxadd.* Module.symvers Modules.symvers
|
---|