1 | # $Id: Makefile-wrapper.gmk 87739 2021-02-12 16:36:17Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # Makefile template for a wrapper module.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006-2020 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 | # The contents of this file may alternatively be used under the terms
|
---|
18 | # of the Common Development and Distribution License Version 1.0
|
---|
19 | # (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | # VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | # CDDL are applicable instead of those of the GPL.
|
---|
22 | #
|
---|
23 | # You may elect to license modified versions of this file under the
|
---|
24 | # terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | #
|
---|
26 |
|
---|
27 | # Check template parameters.
|
---|
28 | ifndef WRAPPED_MODULE_NAME
|
---|
29 | $(error WRAPPED_MODULE_NAME not defined)
|
---|
30 | endif
|
---|
31 | ifndef VBOXMOD_NAME
|
---|
32 | $(error VBOXMOD_NAME not defined)
|
---|
33 | endif
|
---|
34 |
|
---|
35 |
|
---|
36 | # Linux kbuild sets this to our source directory if we are called from there
|
---|
37 | ifndef VBOX_MODULE_SRC_DIR
|
---|
38 | VBOX_MODULE_SRC_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))/
|
---|
39 | endif
|
---|
40 | VBOXDRV_DIR := $(abspath $(VBOX_MODULE_SRC_DIR)../vboxdrv/)/
|
---|
41 | VBOX_VMMR0_DIR := $(abspath $(VBOX_MODULE_SRC_DIR)../vbox_vmmr0/)/
|
---|
42 | include $(VBOXDRV_DIR)Makefile-header.gmk
|
---|
43 |
|
---|
44 | # All of these wrappers depend on
|
---|
45 | ifndef KBUILD_EXTRA_SYMBOLS
|
---|
46 | KBUILD_EXTRA_SYMBOLS := $(VBOXDRV_DIR)Module.symvers
|
---|
47 | ifdef WRAPPER_NEED_VMMR0
|
---|
48 | KBUILD_EXTRA_SYMBOLS += $(VBOX_VMMR0_DIR)Module.symvers
|
---|
49 | endif
|
---|
50 | endif
|
---|
51 |
|
---|
52 | VBOXMOD_OBJS = \
|
---|
53 | SUPWrapperMod-linux.o \
|
---|
54 | $(WRAPPED_MODULE_NAME).o
|
---|
55 |
|
---|
56 | VBOXMOD_INCL = \
|
---|
57 | $(VBOXDRV_DIR) \
|
---|
58 | $(VBOXDRV_DIR)include \
|
---|
59 | $(VBOXDRV_DIR)r0drv/linux
|
---|
60 |
|
---|
61 | VBOXMOD_DEFS += \
|
---|
62 | RT_OS_LINUX \
|
---|
63 | IN_RING0 \
|
---|
64 | IN_RT_R0 \
|
---|
65 | IN_SUP_R0 \
|
---|
66 | VBOX \
|
---|
67 | \
|
---|
68 | WRAPPED_MODULE_NAME=\"$(WRAPPED_MODULE_NAME).r0\" \
|
---|
69 | WRAPPED_MODULE_SYMBOL_INCLUDE=\"$(WRAPPED_MODULE_NAME)-symbols.h\"
|
---|
70 | ifdef WRAPPED_MODULE_FLAGS
|
---|
71 | VBOXMOD_DEFS += WRAPPED_MODULE_FLAGS="$(WRAPPED_MODULE_FLAGS)"
|
---|
72 | endif
|
---|
73 | ifdef WRAPPED_MODULE_LINUX_EXPORTS
|
---|
74 | VBOXMOD_DEFS += WRAPPED_MODULE_LINUX_EXPORTS
|
---|
75 | endif
|
---|
76 | ifdef WRAPPED_MODULE_SRV_REQ_HANDLER
|
---|
77 | VBOXMOD_DEFS += WRAPPED_MODULE_SRV_REQ_HANDLER="$(WRAPPED_MODULE_SRV_REQ_HANDLER)"
|
---|
78 | endif
|
---|
79 | ifdef WRAPPED_MODULE_IS_VMMR0
|
---|
80 | VBOXMOD_DEFS += WRAPPED_MODULE_VMMR0_ENTRY_FAST=VMMR0EntryFast
|
---|
81 | VBOXMOD_DEFS += WRAPPED_MODULE_VMMR0_ENTRY_EX=VMMR0EntryEx
|
---|
82 | endif
|
---|
83 | ifdef WRAPPED_MODULE_NO_INIT
|
---|
84 | VBOXMOD_DEFS += WRAPPED_MODULE_INIT=NULL
|
---|
85 | endif
|
---|
86 | ifdef WRAPPED_MODULE_NO_TERM
|
---|
87 | VBOXMOD_DEFS += WRAPPED_MODULE_TERM=NULL
|
---|
88 | endif
|
---|
89 | ifdef WRAPPED_MODULE_LICENSE_PROPRIETARY
|
---|
90 | VBOXMOD_DEFS += WRAPPED_MODULE_LICENSE_PROPRIETARY
|
---|
91 | endif
|
---|
92 |
|
---|
93 | VBOXMOD_CFLAGS = -include $(VBOXDRV_DIR)include/VBox/SUPDrvMangling.h \
|
---|
94 | -fno-omit-frame-pointer -fno-pie -Wno-declaration-after-statement
|
---|
95 |
|
---|
96 | ## @todo cleanup
|
---|
97 |
|
---|
98 | include $(VBOXDRV_DIR)Makefile-footer.gmk
|
---|
99 |
|
---|
100 |
|
---|
101 | #
|
---|
102 | # Custom rules (some of this could later be done before install).
|
---|
103 | #
|
---|
104 | SUPWrapperMod-linux.c \
|
---|
105 | $(VBOX_MODULE_SRC_DIR)SUPWrapperMod-linux.c \
|
---|
106 | $(VBOX_MODULE_SRC_DIR)SUPWrapperMod-linux.o \
|
---|
107 | : $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME)-symbols.h
|
---|
108 |
|
---|
109 | $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME)-symbols.h: \
|
---|
110 | $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).r0 \
|
---|
111 | $(VBOX_MODULE_SRC_DIR)Makefile-wrapper.gmk \
|
---|
112 | $(VBOX_MODULE_SRC_DIR)Makefile
|
---|
113 | rm -f -- "$@" "$@-tmp1" "$@-tmp2"
|
---|
114 | objdump --syms "$<" > "$@-tmp1"
|
---|
115 | sed -e '/[[:space:]].hidden[[:space:]]/d' \
|
---|
116 | -e '/[[:space:]]\*UND\*[[:space:]]/d' \
|
---|
117 | -e '/[[:space:]]vboxr0mod_/d' \
|
---|
118 | -e '/^[[:xdigit:]][[:xdigit:]]*[[:space:]][gu]/!d' \
|
---|
119 | -e 's/^\([[:xdigit:]]*\)[[:space:]].*000[[:xdigit:]]*[[:space:]]\([_a-zA-Z].*\)$$/SYMBOL_ENTRY(\2)/' \
|
---|
120 | -e '/SYMBOL_ENTRY(ModuleInit)/d' \
|
---|
121 | -e '/SYMBOL_ENTRY(ModuleTerm)/d' \
|
---|
122 | "$@-tmp1" > "$@-tmp2"
|
---|
123 | sort "$@-tmp2" > "$@"
|
---|
124 | rm -f -- "$@-tmp1" "$@-tmp2"
|
---|
125 |
|
---|
126 |
|
---|
127 | $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).mangle-symbols: \
|
---|
128 | $(VBOXDRV_DIR)Module.symvers \
|
---|
129 | $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME)-symbols.h \
|
---|
130 | $(VBOX_MODULE_SRC_DIR)Makefile-wrapper.gmk \
|
---|
131 | $(VBOX_MODULE_SRC_DIR)Makefile
|
---|
132 | sed -e 's/SYMBOL_ENTRY(\([^)]*\))/\/\1 VBoxHost_\1\/d/' \
|
---|
133 | "$(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME)-symbols.h" \
|
---|
134 | > "$@-ignore.sed"
|
---|
135 | sed -e '/[[:space:]]VBoxHost_/!d' \
|
---|
136 | -e 's/^0x[[:xdigit:]]*[[:space:]]VBoxHost_\([^[:space:]]*\)[[:space:]].*$$/\1 VBoxHost_\1/' \
|
---|
137 | -f "$@-ignore.sed" \
|
---|
138 | "$<" \
|
---|
139 | > "$@"
|
---|
140 |
|
---|
141 | $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).o: \
|
---|
142 | $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).r0 \
|
---|
143 | $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).debug \
|
---|
144 | $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).mangle-symbols \
|
---|
145 | $(VBOX_MODULE_SRC_DIR)Makefile-wrapper.gmk \
|
---|
146 | $(VBOX_MODULE_SRC_DIR)Makefile \
|
---|
147 | $(if $(CONFIG_UNWINDER_ORC),$(objtool_dep),)
|
---|
148 | rm -f -- "$@" "$@-tmp"
|
---|
149 | eu-unstrip -o "$@-tmp" $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).r0 $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).debug
|
---|
150 | objcopy --redefine-syms=$(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).mangle-symbols "$@-tmp" "$@"
|
---|
151 | rm -f -- "$@-tmp"
|
---|
152 | ifdef CONFIG_UNWINDER_ORC # Must generate the ORC sections.
|
---|
153 | $(__objtool_obj) $(objtool_args) $@
|
---|
154 | endif
|
---|
155 | touch $(VBOX_MODULE_SRC_DIR).$(WRAPPED_MODULE_NAME).o.cmd
|
---|
156 |
|
---|