Makefile.kmk revision e3e17b12a8230cd32c6ff2b7c36c467a75909726
# $Id$
## @file
# Top-level makefile for the VMM.
#
#
# Copyright (C) 2006-2012 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
SUB_DEPTH = ../../..
include $(KBUILD_PATH)/subheader.kmk
# Include sub-makefiles.
ifndef VBOX_ONLY_EXTPACKS
include $(PATH_SUB_CURRENT)/Preload/Makefile.kmk
endif
include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
#
# Globals
#
## DEFS variable that is picked up by all three VMM targets.
# Can be prepended to by setting it in LocalConfig.kmk
VMM_COMMON_DEFS ?= VBOX_IN_VMM
ifdef VBOX_WITH_RAW_MODE
VMM_COMMON_DEFS += VBOX_WITH_RAW_MODE
endif
ifdef VBOX_WITH_IEM
VMM_COMMON_DEFS += VBOX_WITH_IEM
endif
ifdef VBOX_WITH_REM
VMM_COMMON_DEFS += VBOX_WITH_REM
endif
ifdef VBOX_WITH_MULTI_CORE
VMM_COMMON_DEFS += VBOX_WITH_MULTI_CORE
endif
ifdef VBOX_WITH_R0_LOGGING
VMM_COMMON_DEFS += VBOX_WITH_R0_LOGGING
endif
ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
VMM_COMMON_DEFS += VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
endif
ifdef VBOX_WITH_PCI_PASSTHROUGH
VMM_COMMON_DEFS += VBOX_WITH_PCI_PASSTHROUGH
endif
ifdef VBOX_WITH_DTRACE_RC
VMM_COMMON_DEFS += VBOX_WITH_DTRACE_RC
endif
# VMM_COMMON_DEFS += VBOX_WITH_NS_ACCOUNTING_STATS
# Special IEM debug mode which compares the result with REM.
ifdef IEM_VERIFICATION_MODE
VMM_COMMON_DEFS += IEM_VERIFICATION_MODE
endif
#
# The VMM DLL.
#
ifndef VBOX_ONLY_EXTPACKS_USE_IMPLIBS
DLLS += VBoxVMM
endif
VBoxVMM_TEMPLATE = VBoxR3DllNoPic
VBoxVMM_DEFS = IN_VMM_R3 IN_DIS IN_GMM_R3 IN_DBG $(VMM_COMMON_DEFS)
## @todo eliminate IN_GMM_R3
ifdef VBOX_WITH_PREALLOC_RAM_BY_DEFAULT
VBoxVMM_DEFS += VBOX_WITH_PREALLOC_RAM_BY_DEFAULT
endif
ifdef VBOX_WITH_VUSB
VBoxVMM_DEFS += VBOX_WITH_USB
endif
ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
VBoxVMM_DEFS += VBOX_WITH_PDM_ASYNC_COMPLETION
endif
ifdef VBOX_WITH_NETSHAPER
VBoxVMM_DEFS += VBOX_WITH_NETSHAPER
endif
VBoxVMM_DEFS.darwin = VMM_R0_SWITCH_STACK
VBOX_WITH_2X_4GB_ADDR_SPACE VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R3 \
VBOX_WITH_HYBRID_32BIT_KERNEL VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R3
VBoxVMM_INCS = \
include \
PATM
VBoxVMM_ASINCS = .
VBoxVMM_SOURCES = \
ifdef VBOX_WITH_VUSB
VBoxVMM_SOURCES += VMMR3/PDMUsb.cpp
endif
ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
VBoxVMM_SOURCES += \
endif
ifdef VBOX_WITH_NETSHAPER
VBoxVMM_SOURCES += \
endif
ifdef VBOX_WITH_RAW_MODE
VBoxVMM_SOURCES.x86 += \
VMMSwitcher/32BitTo32Bit.asm \
VMMSwitcher/32BitToPAE.asm \
VMMSwitcher/32BitToAMD64.asm \
endif
VBoxVMM_LIBS = \
$(PATH_STAGE_LIB)/DisasmR3$(VBOX_SUFF_LIB)
ifdef VBOX_WITH_DEBUGGER
VBoxVMM_LIBS += \
$(PATH_STAGE_LIB)/Debugger$(VBOX_SUFF_LIB)
endif
VBoxVMM_LIBS += \
$(LIB_REM) \
$(LIB_RUNTIME)
VBoxVMM_LIBS.win = $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib
VBoxVMM_LDFLAGS.win = /DELAYLOAD:dbghelp.dll
VBoxVMM_LDFLAGS.linux = -Wl,--no-undefined
VBoxVMM_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxVMM.dylib
VBoxVMM_LDFLAGS.solaris = -mimpure-text
# SSM wish to know the build type, host os and arch.
VMMR3/SSM.cpp_DEFS += \
KBUILD_TYPE=\"$(KBUILD_TYPE)\" \
KBUILD_TARGET=\"$(KBUILD_TARGET)\" \
KBUILD_TARGET_ARCH=\"$(KBUILD_TARGET_ARCH)\"
#ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
# ifeq ($(KBUILD_HOST), linux)
#VBoxVMM_LIBS += aio
# endif
#endif
if defined(VBOX_WITH_RAW_MODE) && $(intersects $(VBOX_LDR_FMT32), pe lx)
#
#
LIBRARIES += VMMRCBuiltin
VMMRCBuiltin_TEMPLATE = VBoxRc
ifeq ($(VBOX_LDR_FMT32),pe)
VMMRCBuiltin_SOURCES = VMMRC/VMMRCBuiltin.def
endif
ifeq ($(VBOX_LDR_FMT32),lx)
VMMRCBuiltin_SOURCES = $(VMMRCBuiltin_0_OUTDIR)/VMMRCBuiltin.def
$$(VMMRCBuiltin_0_OUTDIR)/VMMRCBuiltin.def: $(PATH_SUB_CURRENT)/VMMRC/VMMRCBuiltin.def | $$(dir $$@)
$(SED) -e '/not-os2/d' -e 's/^[ \t][ \t]*\([a-zA-Z]\)/ _\1/' -e 's/[ \t]DATA[ \t]*/ /' --output $@ $<
endif
#
#
LIBRARIES += VMMRCImp
VMMRCImp_TEMPLATE = VBoxRc
VMMRCImp_SOURCES = $(VMMRCImp_0_OUTDIR)/VMMRC.def
VMMRCImp_CLEAN = $(VMMRCImp_0_OUTDIR)/VMMRC.def
$$(VMMRCImp_0_OUTDIR)/VMMRC.def: $(PATH_SUB_CURRENT)/VMMRC/VMMRC.def | $$(dir $$@)
ifeq ($(VBOX_LDR_FMT32),lx)
$(SED) \
-e '/not-os2/d' \
-e 's/^[ \t][ \t]*\([a-zA-Z]\)/ _\1/' \
-e 's/[ \t]DATA[ \t]*/ /' \
--output $@ \
$<
$(APPEND) "$@" ""
$(APPEND) "$@" " ___ehInit"
else
$(SED) \
-e '/not-win/d' \
-e '/not-$(KBUILD_TARGET_ARCH)/d' \
--output $@ $<
endif
endif # RC && (pe || lx)
if1of ($(VBOX_LDR_FMT), pe lx)
#
#
LIBRARIES += VMMR0Imp
VMMR0Imp_TEMPLATE = VBoxR0
VMMR0Imp_SOURCES = $(VMMR0Imp_0_OUTDIR)/VMMR0.def
VMMR0Imp_CLEAN = $(VMMR0Imp_0_OUTDIR)/VMMR0.def
$$(VMMR0Imp_0_OUTDIR)/VMMR0.def: $(PATH_SUB_CURRENT)/VMMR0/VMMR0.def | $$(dir $$@)
ifeq ($(VBOX_LDR_FMT),lx)
$(SED) \
-e '/not-os2/d' \
-e '/not-amd64/d' \
-e 's/^[ \t][ \t]*\([a-zA-Z]\)/ _\1/' \
-e 's/[ \t]DATA[ \t]*/ /' \
--output $@ $<
$(APPEND) "$@" ""
$(APPEND) "$@" " ___ehInit"
else
$(SED) \
-e '/not-win/d' \
-e '/not-$(KBUILD_TARGET_ARCH)/d' \
--output $@ $<
endif
endif # R0: pe + lx
#
#
IMPORT_LIBS += VMMR3Imp
$(call VBOX_GENERATE_IMPORT_TARGET_FN,VMMR3Imp,VBoxVMM,VMMR3/VMMR3.def)
if defined(VBOX_WITH_RAW_MODE) && !defined(VBOX_ONLY_EXTPACKS)
#
# VMMRC.gc
#
SYSMODS += VMMRC
VMMRC_TEMPLATE = VBoxRc
VMMRC_NAME = VMMGC
VMMRC_SYSSUFF = .gc
VMMRC_DEFS = IN_VMM_RC IN_RT_RC IN_DIS DIS_CORE_ONLY VBOX_WITH_RAW_MODE $(VMM_COMMON_DEFS)
ifeq ($(KBUILD_TARGET_ARCH),x86)
VMMRC_DEFS.darwin = VMM_R0_SWITCH_STACK
VBOX_WITH_2X_4GB_ADDR_SPACE VBOX_WITH_2X_4GB_ADDR_SPACE_IN_RC \
VBOX_WITH_HYBRID_32BIT_KERNEL VBOX_WITH_HYBRID_32BIT_KERNEL_IN_RC
endif
VMMRC_INCS := \
include \
VMMRC \
PATM
VMMRC_LIBS = \
$(PATH_STAGE_LIB)/DisasmRC$(VBOX_SUFF_LIB) \
$(PATH_STAGE_LIB)/RuntimeRC$(VBOX_SUFF_LIB)
ifneq ($(filter pe lx,$(VBOX_LDR_FMT32)),)
VMMRC_LIBS += \
$(PATH_STAGE_LIB)/VMMRCBuiltin$(VBOX_SUFF_LIB)
endif
VMMRC_SOURCES = \
ifeq ($(VBOX_LDR_FMT32),pe)
VMMRC_SOURCES += VMMRC/VMMRC.def
endif
ifeq ($(VBOX_LDR_FMT32),lx)
VMMRC_SOURCES += $(VMMRCImp_0_OUTDIR)/VMMRC.def
endif
ifdef VBOX_WITH_IEM
VMMRC_SOURCES += \
endif
# the very last one.
VMMRC_SOURCES += VMMRC/VMMRC99.asm
VMMRC/VMMRCDeps.cpp_CXXFLAGS.win = -Oi- -TC ## @todo rename VMMRCDeps.cpp to .c
endif # VBOX_WITH_RAW_MODE && !VBOX_ONLY_EXTPACKS
ifndef VBOX_ONLY_EXTPACKS
#
# VMMR0.r0
#
SYSMODS += VMMR0
VMMR0_TEMPLATE = VBoxR0
VMMR0_SYSSUFF = .r0
VMMR0_DEFS = IN_VMM_R0 IN_RT_R0 IN_DIS DIS_CORE_ONLY IN_GVMM_R0 IN_GMM_R0 IN_INTNET_R0 \
$(VMM_COMMON_DEFS) RTASSERT_HAVE_SHOULD_PANIC
## @todo eliminate IN_GVMM_R0 IN_GMM_R0
ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
VMMR0_DEFS += VBOX_WITH_VMMR0_DISABLE_PREEMPTION
endif
ifdef VBOX_WITH_PCI_PASSTHROUGH
VMMR0_DEFS += IN_PCIRAW_R0
endif
ifdef VBOX_WITH_TRIPLE_FAULT_HACK
VMMR0_DEFS += VBOX_WITH_TRIPLE_FAULT_HACK
endif
VMMR0_DEFS.darwin = VMM_R0_SWITCH_STACK
VBOX_WITH_2X_4GB_ADDR_SPACE VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 \
VBOX_WITH_HYBRID_32BIT_KERNEL VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R0
VMMR0_DEFS.win.amd64 = VBOX_WITH_KERNEL_USING_XMM
ifeq ($(VBOX_LDR_FMT),elf)
VMMR0_LDFLAGS = -e VMMR0EntryEx
endif
VMMR0_INCS = \
include \
PATM
VMMR0_SOURCES = \
if1of ($(VBOX_LDR_FMT), pe lx)
VMMR0_SOURCES += $(VMMR0Imp_0_OUTDIR)/VMMR0.def
endif
ifdef VBOX_WITH_TRIPLE_FAULT_HACK
VMMR0_SOURCES += \
endif
ifdef VBOX_WITH_IEM
VMMR0_SOURCES += \
endif
VMMR0_LIBS = \
$(PATH_STAGE_LIB)/ServicesR0$(VBOX_SUFF_LIB) \
$(PATH_STAGE_LIB)/RuntimeR0$(VBOX_SUFF_LIB) \
$(PATH_STAGE_LIB)/DisasmR0$(VBOX_SUFF_LIB)
ifneq ($(filter pe lx,$(VBOX_LDR_FMT)),)
VMMR0_LIBS += \
$(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
endif
endif # !VBOX_ONLY_EXTPACKS
ifndef VBOX_ONLY_EXTPACKS
#
# SSMStandalone.lib/a for linking with VBoxSVC and other executables.
#
LIBRARIES += SSMStandalone
SSMStandalone_TEMPLATE = VBOXR3EXE
SSMStandalone_DEFS = IN_VMM_R3 IN_VMM_STATIC SSM_STANDALONE
SSMStandalone_INCS = include
SSMStandalone_SOURCES = VMMR3/SSM.cpp
endif # !VBOX_ONLY_EXTPACKS
if !defined(VBOX_ONLY_EXTPACKS) \
&& ( defined(VBOX_WITH_DTRACE_R3) \
|| defined(VBOX_WITH_DTRACE_R0) \
|| defined(VBOX_WITH_DTRACE_RC))
#
# Install the dtrace library files.
#
INSTALLS += VMMLibDTrace
VMMLibDTrace_INST = $(VBOX_INST_DTRACE_LIB)$(KBUILD_TARGET_ARCH)/
VMMLibDTrace_SOURCES = \
dtrace/lib/$(KBUILD_TARGET_ARCH)/vbox-arch-types.d \
$(VMMLibDTrace_0_OUTDIR)/vm.d \
$(VMMLibDTrace_0_OUTDIR)/cpumctx.d \
$(VMMLibDTrace_0_OUTDIR)/CPUMInternal.d \
$(VMMLibDTrace_0_OUTDIR)/x86.d \
##
# Turn the header $2 into the DTrace library script $1.
#
define def_vmm_lib_dtrace_preprocess
$$$$(VMMLibDTrace_0_OUTDIR)/$1: $2 $$(VBOX_VBOXCPP) | $$$$(dir $$$$@)
$$(QUIET)$$(call MSG_GENERATE,VMMLibDTrace,$$@,$$<)
$$(QUIET)$(VBOX_VBOXCPP) -d \
-D VBOX_FOR_DTRACE_LIB \
-D VBOX_FOR_DTRACE_LIB_$(toupper $(KBUILD_TARGET_ARCH)) \
-D IN_RING0 \
-D RT_C_DECLS_BEGIN= \
-D RT_C_DECLS_END= \
-D 'RCPTRTYPE(a_Type)=RTRCPTR' \
-D 'R3PTRTYPE(a_Type)=RTR3PTR' \
-D 'R0PTRTYPE(a_Type)=a_Type' \
-D 'AssertCompile(a_Expr)=' \
-D 'AssertCompileSize(a_Stuct, a_Size)=' \
-D 'bool=uint8_t' \
$$(foreach def,\
$$(DEFS) \
$$(DEFS.$$(KBUILD_TARGET)) \
$$(DEFS.$(KBUILD_TARGET_ARCH)) \
$$(VMM_COMMON_DEFS) \
$$(ARCH_BITS_DEFS)\
,-D '$$(def)') \
$$< \
$$@
$$(QUIET)$$(CHMOD) 644 $$@
endef
$(evalcall2 def_vmm_lib_dtrace_preprocess,vm.d,$(PATH_ROOT)/include/VBox/vmm/vm.h)
$(evalcall2 def_vmm_lib_dtrace_preprocess,cpumctx.d,$(PATH_ROOT)/include/VBox/vmm/cpumctx.h)
$(evalcall2 def_vmm_lib_dtrace_preprocess,CPUMInternal.d,$(PATH_SUB_CURRENT)/include/CPUMInternal.h)
$(evalcall2 def_vmm_lib_dtrace_preprocess,x86.d,$(PATH_ROOT)/include/iprt/x86.h)
endif
#
# For vmmGetSvnRev.
#
VMMAll/VMMAll.cpp_DEFS = VBOX_SVN_REV=$(VBOX_SVN_REV)
#
# Disable annoying warnings about array subscript above array bounds in aPages[]
#
ifneq ($(KBUILD_TARGET),win)
VMMR3/PGMPool.cpp_CXXFLAGS = $(VBOX_GCC_Wno-array_bounds)
VMMAll/PGMAllPool.cpp_CXXFLAGS = $(VBOX_GCC_Wno-array_bounds)
VMMAll/PGMAll.cpp_CXXFLAGS = -Wno-unused-function
VMMAll/IEMAll.cpp_CXXFLAGS = -Wno-unused-parameter
endif
#
# Always optimize the interpreter.
#
if1of ($(KBUILD_TARGET), win)
#VMMAll/IEMAll.cpp_CXXFLAGS += TODO
#else if1of ($(KBUILD_TARGET_ARCH), amd64)
# VMMAll/IEMAll.cpp_CXXFLAGS += -O2 -fomit-frame-pointer
else
VMMAll/IEMAll.cpp_CXXFLAGS += -O2
#VMMAll/IEMAll.cpp_CXXFLAGS += -fno-align-functions -fno-align-jumps -fno-align-loops # Saves a few of percents, not worth it.
#VMMAll/IEMAll.cpp_CXXFLAGS += -fno-reorder-blocks # Saves one or two percent ... never mind.
VMMAll/IEMAll.cpp_CXXFLAGS += -fomit-frame-pointer # Omitting the frame pointer results in larger code, but it might be worth it. (esp addressing vs ebp?)
endif
include $(FILE_KBUILD_SUB_FOOTER)
# Alias the PGM templates to the object in which they are defined.
# Alias the IEM templates to the object in which they are instantiated.