1 | #
|
---|
2 | # Makefile for the VirtualBox Linux Host Drivers.
|
---|
3 | #
|
---|
4 |
|
---|
5 | #
|
---|
6 | # Copyright (C) 2008-2019 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 vboxdrv vboxnetflt vboxnetadp \
|
---|
49 | vboxpci
|
---|
50 |
|
---|
51 | all: vboxdrv vboxnetflt vboxnetadp vboxpci
|
---|
52 |
|
---|
53 | # We want to build on Linux 2.6.18 and later kernels.
|
---|
54 | ifneq ($(filter-out 1.% 2.0.% 2.1.% 2.2.% 2.3.% 2.4.% 2.5.%,$(KERN_VER)),)
|
---|
55 |
|
---|
56 | vboxdrv:
|
---|
57 | @echo "=== Building 'vboxdrv' module ==="
|
---|
58 | @$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv
|
---|
59 | @cp vboxdrv/vboxdrv.ko .
|
---|
60 | @echo
|
---|
61 |
|
---|
62 | vboxnetflt: vboxdrv
|
---|
63 | @if [ -d vboxnetflt ]; then \
|
---|
64 | if [ -f vboxdrv/Module.symvers ]; then \
|
---|
65 | cp vboxdrv/Module.symvers vboxnetflt; \
|
---|
66 | fi; \
|
---|
67 | echo "=== Building 'vboxnetflt' module ==="; \
|
---|
68 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt || exit 1; \
|
---|
69 | cp vboxnetflt/vboxnetflt.ko .; \
|
---|
70 | echo; \
|
---|
71 | fi
|
---|
72 |
|
---|
73 | vboxnetadp: vboxdrv
|
---|
74 | @if [ -d vboxnetadp ]; then \
|
---|
75 | if [ -f vboxdrv/Module.symvers ]; then \
|
---|
76 | cp vboxdrv/Module.symvers vboxnetadp; \
|
---|
77 | fi; \
|
---|
78 | echo "=== Building 'vboxnetadp' module ==="; \
|
---|
79 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetadp || exit 1; \
|
---|
80 | cp vboxnetadp/vboxnetadp.ko .; \
|
---|
81 | echo; \
|
---|
82 | fi
|
---|
83 |
|
---|
84 | vboxpci: vboxdrv
|
---|
85 | @if [ -d vboxpci ]; then \
|
---|
86 | if [ -f vboxdrv/Module.symvers ]; then \
|
---|
87 | cp vboxdrv/Module.symvers vboxpci; \
|
---|
88 | fi; \
|
---|
89 | echo "=== Building 'vboxpci' module ==="; \
|
---|
90 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxpci || exit 1; \
|
---|
91 | cp vboxpci/vboxpci.ko .; \
|
---|
92 | echo; \
|
---|
93 | fi
|
---|
94 |
|
---|
95 | install:
|
---|
96 | @$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv install
|
---|
97 | @if [ -d vboxnetflt ]; then \
|
---|
98 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt install; \
|
---|
99 | fi
|
---|
100 | @if [ -d vboxnetadp ]; then \
|
---|
101 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetadp install; \
|
---|
102 | fi
|
---|
103 | @if [ -d vboxpci ]; then \
|
---|
104 | $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxpci install; \
|
---|
105 | fi
|
---|
106 |
|
---|
107 | else
|
---|
108 |
|
---|
109 | vboxdrv:
|
---|
110 | vboxnetflt:
|
---|
111 | vboxnetadp:
|
---|
112 | vboxpci:
|
---|
113 | install:
|
---|
114 |
|
---|
115 | endif
|
---|
116 |
|
---|
117 | clean:
|
---|
118 | @$(MAKE) -C vboxdrv clean
|
---|
119 | @if [ -d vboxnetflt ]; then \
|
---|
120 | $(MAKE) -C vboxnetflt clean; \
|
---|
121 | fi
|
---|
122 | @if [ -d vboxnetadp ]; then \
|
---|
123 | $(MAKE) -C vboxnetadp clean; \
|
---|
124 | fi
|
---|
125 | @if [ -d vboxpci ]; then \
|
---|
126 | $(MAKE) -C vboxpci clean; \
|
---|
127 | fi
|
---|
128 | rm -f vboxdrv.ko vboxnetflt.ko vboxnetadp.ko vboxpci.ko
|
---|
129 |
|
---|
130 | check:
|
---|
131 | @$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv check
|
---|
132 |
|
---|
133 | unload:
|
---|
134 | @for module in vboxpci vboxnetadp vboxnetflt vboxdrv; do \
|
---|
135 | if grep "^$$module " /proc/modules >/dev/null; then \
|
---|
136 | echo "Removing previously installed $$module module"; \
|
---|
137 | /sbin/rmmod $$module; \
|
---|
138 | fi; \
|
---|
139 | done
|
---|
140 |
|
---|
141 | load: unload
|
---|
142 | @for module in vboxdrv vboxnetflt vboxnetadp vboxpci; do \
|
---|
143 | if test -f $$module.ko; then \
|
---|
144 | echo "Installing $$module module"; \
|
---|
145 | /sbin/insmod $$module.ko; \
|
---|
146 | fi; \
|
---|
147 | done
|
---|
148 |
|
---|
149 | endif # ! KERNELRELEASE
|
---|