1 | #
|
---|
2 | # Makefile for the VirtualBox Linux Host Drivers.
|
---|
3 | #
|
---|
4 |
|
---|
5 | #
|
---|
6 | # Copyright (C) 2008-2020 Oracle Corporation
|
---|
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 (GPL) as published by the Free Software
|
---|
12 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | #
|
---|
16 | # The contents of this file may alternatively be used under the terms
|
---|
17 | # of the Common Development and Distribution License Version 1.0
|
---|
18 | # (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | # VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | # CDDL are applicable instead of those of the GPL.
|
---|
21 | #
|
---|
22 | # You may elect to license modified versions of this file under the
|
---|
23 | # terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | #
|
---|
25 |
|
---|
26 | ifneq ($(KERNELRELEASE),)
|
---|
27 |
|
---|
28 | # Building from kBuild (make -C <kernel_directory> M=`pwd`),
|
---|
29 | # or inside a kernel source tree.
|
---|
30 |
|
---|
31 | obj-m = vboxdrv/
|
---|
32 | ifneq ($(wildcard $(CURDIR)/vboxnetflt/Makefile),)
|
---|
33 | obj-m += vboxnetflt/
|
---|
34 | endif
|
---|
35 | ifneq ($(wildcard $(CURDIR)/vboxnetadp/Makefile),)
|
---|
36 | obj-m += vboxnetadp/
|
---|
37 | endif
|
---|
38 | ifneq ($(wildcard $(CURDIR)/vboxpci/Makefile),)
|
---|
39 | obj-m += vboxpci/
|
---|
40 | endif
|
---|
41 |
|
---|
42 | else # ! KERNELRELEASE
|
---|
43 |
|
---|
44 | # convenience Makefile without KERNELRELEASE
|
---|
45 |
|
---|
46 | KBUILD_VERBOSE ?=
|
---|
47 | KERN_VER ?= $(shell uname -r)
|
---|
48 | .PHONY: all install clean check unload load \
|
---|
49 | vboxdrv vboxnetflt vboxnetadp vboxpci \
|
---|
50 | install-vboxdrv install-vboxnetflt install-vboxnetadp install-vboxpci \
|
---|
51 | clean-vboxdrv clean-vboxnetflt clean-vboxnetadp clean-vboxpci
|
---|
52 |
|
---|
53 | all: vboxdrv vboxnetflt vboxnetadp vboxpci
|
---|
54 |
|
---|
55 | # We want to build on Linux 2.6.18 and later kernels.
|
---|
56 | ifneq ($(filter-out 1.% 2.0.% 2.1.% 2.2.% 2.3.% 2.4.% 2.5.%,$(KERN_VER)),)
|
---|
57 |
|
---|
58 | vboxdrv:
|
---|
59 | @echo "=== Building 'vboxdrv' module ==="
|
---|
60 | +@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv
|
---|
61 | @cp vboxdrv/vboxdrv.ko .
|
---|
62 | @echo
|
---|
63 |
|
---|
64 | vboxnetflt: vboxdrv
|
---|
65 | +@if [ -d vboxnetflt ]; then \
|
---|
66 | if [ -f vboxdrv/Module.symvers ]; then \
|
---|
67 | cp vboxdrv/Module.symvers vboxnetflt; \
|
---|
68 | fi; \
|
---|
69 | echo "=== Building 'vboxnetflt' module ==="; \
|
---|
70 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) KBUILD_EXTRA_SYMBOLS=$(abspath vboxnetflt/Module.symvers) -C vboxnetflt || exit 1; \
|
---|
71 | cp vboxnetflt/vboxnetflt.ko .; \
|
---|
72 | echo; \
|
---|
73 | fi
|
---|
74 |
|
---|
75 | vboxnetadp: vboxdrv
|
---|
76 | +@if [ -d vboxnetadp ]; then \
|
---|
77 | if [ -f vboxdrv/Module.symvers ]; then \
|
---|
78 | cp vboxdrv/Module.symvers vboxnetadp; \
|
---|
79 | fi; \
|
---|
80 | echo "=== Building 'vboxnetadp' module ==="; \
|
---|
81 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) KBUILD_EXTRA_SYMBOLS=$(abspath vboxnetadp/Module.symvers) -C vboxnetadp || exit 1; \
|
---|
82 | cp vboxnetadp/vboxnetadp.ko .; \
|
---|
83 | echo; \
|
---|
84 | fi
|
---|
85 |
|
---|
86 | vboxpci: vboxdrv
|
---|
87 | +@if [ -d vboxpci ]; then \
|
---|
88 | if [ -f vboxdrv/Module.symvers ]; then \
|
---|
89 | cp vboxdrv/Module.symvers vboxpci; \
|
---|
90 | fi; \
|
---|
91 | echo "=== Building 'vboxpci' module ==="; \
|
---|
92 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) KBUILD_EXTRA_SYMBOLS=$(abspath vboxpci/Module.symvers) -C vboxpci || exit 1; \
|
---|
93 | cp vboxpci/vboxpci.ko .; \
|
---|
94 | echo; \
|
---|
95 | fi
|
---|
96 |
|
---|
97 | install-vboxdrv:
|
---|
98 | +@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv install
|
---|
99 |
|
---|
100 | install-vboxnetflt:
|
---|
101 | +@if [ -d vboxnetflt ]; then \
|
---|
102 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt install; \
|
---|
103 | fi
|
---|
104 |
|
---|
105 | install-vboxnetadp:
|
---|
106 | +@if [ -d vboxnetadp ]; then \
|
---|
107 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetadp install; \
|
---|
108 | fi
|
---|
109 |
|
---|
110 | install-vboxpci:
|
---|
111 | +@if [ -d vboxpci ]; then \
|
---|
112 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxpci install; \
|
---|
113 | fi
|
---|
114 |
|
---|
115 | install: install-vboxdrv install-vboxnetflt install-vboxnetadp install-vboxpci
|
---|
116 |
|
---|
117 | else
|
---|
118 |
|
---|
119 | vboxdrv:
|
---|
120 | vboxnetflt:
|
---|
121 | vboxnetadp:
|
---|
122 | vboxpci:
|
---|
123 | install:
|
---|
124 |
|
---|
125 | endif
|
---|
126 |
|
---|
127 | clean-vboxdrv:
|
---|
128 | +@$(MAKE) -C vboxdrv clean
|
---|
129 | rm -rf vboxdrv.ko
|
---|
130 |
|
---|
131 | clean-vboxnetflt:
|
---|
132 | +@if [ -d vboxnetflt ]; then \
|
---|
133 | $(MAKE) -C vboxnetflt clean; \
|
---|
134 | fi
|
---|
135 | rm -rf vboxnetflt.ko
|
---|
136 |
|
---|
137 | clean-vboxnetadp:
|
---|
138 | +@if [ -d vboxnetadp ]; then \
|
---|
139 | $(MAKE) -C vboxnetadp clean; \
|
---|
140 | fi
|
---|
141 | rm -rf vboxnetadp.ko
|
---|
142 |
|
---|
143 | clean-vboxpci:
|
---|
144 | +@if [ -d vboxpci ]; then \
|
---|
145 | $(MAKE) -C vboxpci clean; \
|
---|
146 | fi
|
---|
147 | rm -f vboxpci.ko
|
---|
148 |
|
---|
149 | clean: clean-vboxdrv clean-vboxnetflt clean-vboxnetadp clean-vboxpci
|
---|
150 |
|
---|
151 | check:
|
---|
152 | +@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv check
|
---|
153 |
|
---|
154 | unload:
|
---|
155 | @for module in vboxpci vboxnetadp vboxnetflt vboxdrv; do \
|
---|
156 | if grep "^$$module " /proc/modules >/dev/null; then \
|
---|
157 | echo "Removing previously installed $$module module"; \
|
---|
158 | /sbin/rmmod $$module; \
|
---|
159 | fi; \
|
---|
160 | done
|
---|
161 |
|
---|
162 | load: unload
|
---|
163 | @for module in vboxdrv vboxnetflt vboxnetadp vboxpci; do \
|
---|
164 | if test -f $$module.ko; then \
|
---|
165 | echo "Installing $$module module"; \
|
---|
166 | /sbin/insmod $$module.ko; \
|
---|
167 | fi; \
|
---|
168 | done
|
---|
169 |
|
---|
170 | endif # ! KERNELRELEASE
|
---|