1 | # $Id: Makefile.kmk 93322 2022-01-18 15:23:38Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # Sub-Makefile for the stub installer.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009-2022 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 |
|
---|
18 | SUB_DEPTH = ../../../../..
|
---|
19 | include $(KBUILD_PATH)/subheader.kmk
|
---|
20 |
|
---|
21 | TEMPLATE_VBOXSTUB = Drop the signing, we will sign it later.
|
---|
22 | TEMPLATE_VBOXSTUB_EXTENDS = VBOXR3STATIC
|
---|
23 | TEMPLATE_VBOXSTUB_POST_CMDS = $(NO_SUCH_VARIABLE)
|
---|
24 |
|
---|
25 | #
|
---|
26 | # Installer stub program
|
---|
27 | #
|
---|
28 | PROGRAMS += VBoxStub
|
---|
29 | VBoxStub_TEMPLATE= VBOXSTUB
|
---|
30 | VBoxStub_BLD_TRG_ARCH = x86
|
---|
31 | VBoxStub_DEFS = _WIN32_WINNT=0x0501 IN_RT_R3
|
---|
32 |
|
---|
33 | VBoxStub_SOURCES = \
|
---|
34 | VBoxStub.cpp \
|
---|
35 | VBoxStub.rc
|
---|
36 |
|
---|
37 | VBoxStub_SDKS += \
|
---|
38 | VBOX_NTDLL
|
---|
39 | ifeq ($(KBUILD_TARGET_ARCH),x86)
|
---|
40 | VBoxStub_LIBS += \
|
---|
41 | $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib \
|
---|
42 | $(VBOX_LIB_RUNTIME_STATIC)
|
---|
43 | else
|
---|
44 | VBoxStub_LIBS += \
|
---|
45 | $(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)X86_LIB)/delayimp.lib \
|
---|
46 | $(PATH_STAGE_LIB)/RuntimeR3-x86.lib
|
---|
47 | endif
|
---|
48 |
|
---|
49 | VBoxStub_LDFLAGS = \
|
---|
50 | -DelayLoad:comctl32.dll
|
---|
51 | VBoxStub_POST_CMDS = $(VBOX_CHECK_IMPORTS) --image $(out) ntdll.dll kernel32.dll
|
---|
52 | ifeq ($(KBUILD_TYPE),asan)
|
---|
53 | VBoxStub_POST_CMDS += advapi32.dll
|
---|
54 | endif
|
---|
55 | VBoxStub_LNK_DEPS = $(VBOX_CHECK_IMPORTS)
|
---|
56 |
|
---|
57 | VBoxStub.cpp_DEFS += VBOX_SVN_REV=$(VBOX_SVN_REV)
|
---|
58 | VBoxStub.cpp_DEPS = $(VBOX_SVN_REV_KMK)
|
---|
59 |
|
---|
60 | # If signing mode is enabled, then add the possibility to install the code
|
---|
61 | # signing certificates (public key only) automatically in /silent mode.
|
---|
62 | ifdef VBOX_SIGNING_MODE
|
---|
63 |
|
---|
64 | VBoxStub_SOURCES += VBoxStubCertUtil.cpp
|
---|
65 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
|
---|
66 | VBoxStub.cpp_DEPS += $(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
|
---|
67 | VBoxStub.cpp_INCS += $(VBoxStub_0_OUTDIR)
|
---|
68 | VBoxStub.cpp_DEFS += VBOX_WITH_CODE_SIGNING
|
---|
69 |
|
---|
70 | $$(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h: | $$(dir $$@) $(VBOX_RTSIGNTOOL) $(PATH_STAGE_SYS)/VBoxSup.sys
|
---|
71 | $(RM) -f -- "$@" "$@.cer0" "$@.cer1" "$@.cer2" "$@.array"
|
---|
72 |
|
---|
73 | $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 0 --exe "$(PATH_STAGE_SYS)/VBoxSup.sys" --output "$@.cer0" --der
|
---|
74 | $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert0 "$@.cer0" $@
|
---|
75 | $(APPEND) "$@.array" " { g_abVBoxStubTrustedCert0, sizeof(g_abVBoxStubTrustedCert0) }, "
|
---|
76 | if defined(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME) || $(intersects win all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
|
---|
77 | $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 1 --exe "$(PATH_STAGE_SYS)/VBoxSup.sys" --output "$@.cer1" --der
|
---|
78 | $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert1 "$@.cer1" $@
|
---|
79 | $(APPEND) "$@.array" " { g_abVBoxStubTrustedCert1, sizeof(g_abVBoxStubTrustedCert1) }, "
|
---|
80 | endif
|
---|
81 | if $(intersects win_planb,$(VBOX_WITH_CORP_CODE_SIGNING))
|
---|
82 | $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 1 --exe "$(VBOX_RTSIGNTOOL)" --output "$@.cer2" --der
|
---|
83 | $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert2 "$@.cer2" $@
|
---|
84 | $(APPEND) "$@.array" " { g_abVBoxStubTrustedCert2, sizeof(g_abVBoxStubTrustedCert2) }, "
|
---|
85 | endif
|
---|
86 | $(APPEND) -n "$@" \
|
---|
87 | "" \
|
---|
88 | "struct { uint8_t const *pab; uint32_t cb; }" "g_aVBoxStubTrustedCerts[] = " \
|
---|
89 | "{"
|
---|
90 | $(SED) --append "$@" -e "" "$@.array"
|
---|
91 | $(APPEND) -n "$@" \
|
---|
92 | "};"
|
---|
93 | $(RM) -f -- "$@.cer0" "$@.cer1" "$@.cer2" "$@.array"
|
---|
94 |
|
---|
95 | VBoxStubPublicCert.h:: $$(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
|
---|
96 |
|
---|
97 | endif
|
---|
98 |
|
---|
99 | # The icon location is configurable.
|
---|
100 | VBoxStub.rc_INCS += $(VBoxStub_0_OUTDIR)
|
---|
101 | VBoxStub.rc_DEPS += \
|
---|
102 | $(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc \
|
---|
103 | $(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc
|
---|
104 | VBoxStub_CLEAN += \
|
---|
105 | $(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc \
|
---|
106 | $(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc
|
---|
107 |
|
---|
108 | # Icon include file.
|
---|
109 | $$(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc: $(VBOX_WINDOWS_ICON_FILE) $(MAKEFILE_CURRENT) | $$(dir $$@)
|
---|
110 | $(APPEND) -t $@ 'IDI_VIRTUALBOX ICON DISCARDABLE "$(subst /,\\,$(VBOX_WINDOWS_ICON_FILE))"'
|
---|
111 |
|
---|
112 | # Manifest.
|
---|
113 | VBOX_STUB_MANIFEST_FILE := $(PATH_SUB_CURRENT)/VBoxStub.manifest
|
---|
114 | $$(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc: $(VBOX_STUB_MANIFEST_FILE) $(MAKEFILE_CURRENT) | $$(dir $$@)
|
---|
115 | $(APPEND) -t $@ 'APP_MANIFEST RT_MANIFEST "$(subst /,\\,$(VBOX_STUB_MANIFEST_FILE))"'
|
---|
116 |
|
---|
117 | # Dynamic import no. 1: MSI.DLL
|
---|
118 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm
|
---|
119 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm
|
---|
120 | $$(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm: $(PATH_SUB_CURRENT)/msi.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
121 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
122 | $(QUIET)$(RM) -f -- "$@"
|
---|
123 | $(VBOX_DEF_2_LAZY_LOAD) --system --library MSI.DLL --output "$@" $(filter %.def, $^)
|
---|
124 |
|
---|
125 | # Dynamic import no. 2: CRYPTO32.DLL
|
---|
126 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm
|
---|
127 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm
|
---|
128 | $$(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm: $(PATH_SUB_CURRENT)/crypt32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
129 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
130 | $(QUIET)$(RM) -f -- "$@"
|
---|
131 | $(VBOX_DEF_2_LAZY_LOAD) --system --library CRYPT32.DLL --output "$@" $(filter %.def, $^)
|
---|
132 |
|
---|
133 | # Dynamic import no. 3: WS2_32.DLL
|
---|
134 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm
|
---|
135 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm
|
---|
136 | $$(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm: $(PATH_SUB_CURRENT)/ws2_32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
137 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
138 | $(QUIET)$(RM) -f -- "$@"
|
---|
139 | $(VBOX_DEF_2_LAZY_LOAD) --system --library WS2_32.DLL --output "$@" $(filter %.def, $^)
|
---|
140 |
|
---|
141 | # Dynamic import no. 4: USER32.DLL
|
---|
142 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/User32LazyLoad.asm
|
---|
143 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/User32LazyLoad.asm
|
---|
144 | $$(VBoxStub_0_OUTDIR)/User32LazyLoad.asm: $(PATH_SUB_CURRENT)/user32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
145 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
146 | $(QUIET)$(RM) -f -- "$@"
|
---|
147 | $(VBOX_DEF_2_LAZY_LOAD) --system --library USER32.DLL --output "$@" $(filter %.def, $^)
|
---|
148 |
|
---|
149 | # Dynamic import no. 5: SHELL32.DLL
|
---|
150 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm
|
---|
151 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm
|
---|
152 | $$(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm: $(PATH_SUB_CURRENT)/shell32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
153 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
154 | $(QUIET)$(RM) -f -- "$@"
|
---|
155 | $(VBOX_DEF_2_LAZY_LOAD) --system --library SHELL32.DLL --output "$@" $(filter %.def, $^)
|
---|
156 |
|
---|
157 | include $(FILE_KBUILD_SUB_FOOTER)
|
---|
158 |
|
---|