VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/linux/Makefile-wrapper.gmk@ 103789

Last change on this file since 103789 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette