Makefile.kmk revision fb4eeb4417e94ff895361a56fea0b134da245a02
# $Id$
## @file
# Sub-Makefile for the VMM testcases.
#
#
# Copyright (C) 2006-2007 Sun Microsystems, Inc.
#
# 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.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
# Clara, CA 95054 USA or visit http://www.sun.com if you need
# additional information or have any questions.
#
ifdef VBOX_KBUILD_HACKING
SUB_DEPTH = ../../../..
else
SUB_DEPTH = ..
DEPTH ?= ../../../..
endif
include $(KBUILD_PATH)/subheader.kmk
#
# Target lists.
#
PROGRAMS += tstVMStructSize tstVMStructGC tstAsmStructs tstAsmStructsGC tstVMM tstVMM-HwAccm tstGlobalConfig
ifneq ($(KBUILD_TARGET),win)
PROGRAMS += tstVMMFork
endif
ifdef VBOX_WITH_TESTCASES
PROGRAMS += tstCFGM tstSSM tstMMHyperHeap tstVMM-2 tstVMREQ tstMicro tstCompiler tstVMMR0CallHost-1
ifneq ($(KBUILD_TARGET),l4)
PROGRAMS += tstAnimate
endif
SYSMODS += tstMicroGC
endif # VBOX_WITH_TESTCASES
ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
PROGRAMS += tstPDMAsyncCompletion
endif
#
# We setup two 'other' targets for executing the two structure & alignment
# validation testcases. Perhaps a bit hackish, but extremely useful.
#
ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
ifeq ($(filter-out x86.x86 amd64.amd64 x86.amd64, $(KBUILD_TARGET_ARCH).$(KBUILD_HOST_ARCH)),)
OTHERS += \
$(PATH_TARGET)/tstAsmStructs.run \
$(PATH_TARGET)/tstVMStructSize.run
endif
endif
# The normal testing pass.
TESTING += \
$(PATH_TARGET)/tstAsmStructs.run \
$(PATH_TARGET)/tstVMStructSize.run
OTHER_CLEAN += \
$(PATH_TARGET)/tstAsmStructs.run \
$(PATH_TARGET)/tstVMStructSize.run \
$(PATH_TARGET)/tstAsmStructs.h \
$(PATH_TARGET)/tstAsmStructsAsm.o \
$(PATH_TARGET)/tstAsmStructsAsm.mac \
$(PATH_TARGET)/tstAsmStructsAsm.mac.o \
$(PATH_TARGET)/tstAsmStructsAsm.mac.lst \
$(PATH_TARGET)/tstAsmStructs.h.dump \
$(PATH_TARGET)/tstAsmStructsGC.h \
$(PATH_TARGET)/tstAsmStructsHC.h \
$(PATH_TARGET)/tstVMStructGC.h
#
# Globals
#
VBOX_PATH_VMM_SRC = $(PATH_ROOT)/src/VBox/VMM
#
# Targets
#
tstVMStructGC_TEMPLATE = VBOXGCEXE
tstVMStructGC_DEFS = IN_VMM_GC IN_PDM_GC IN_CFGM_GC IN_IOM_GC IN_VM_GC IN_CPUM_GC IN_SELM_GC IN_PGM_GC IN_TRPM_GC IN_MM_GC IN_PDM_GC IN_DBGF_GC IN_PATM_GC IN_DIS_GC IN_STAM_GC IN_VGADEVICE_GC IN_CSAM_GC IN_SSM_GC IN_REM_GC IN_RRM_GC
ifdef VBOX_WITH_IDT_PATCHING
tstVMStructGC_DEFS += VBOX_WITH_IDT_PATCHING
endif
tstVMStructGC_SOURCES = tstVMStructGC.cpp
tstVMStructGC_INCS = $(VBOX_PATH_VMM_SRC) $(VBOX_PATH_VMM_SRC)/PATM
tstVMStructSize_TEMPLATE= VBOXR3TSTEXE
tstVMStructSize_DEFS = IN_VMM_R3 IN_PDM_R3 IN_CFGM_R3 IN_IOM_R3 IN_VM_R3 IN_CPUM_R3 IN_SELM_R3 IN_PGM_R3 IN_TRPM_R3 IN_MM_R3 IN_PDM_R3 IN_DBGF_R3 IN_PATM_R3 IN_DIS_R3 IN_STAM_R3 IN_VGADEVICE_R3 IN_CSAM_R3 IN_SSM_R3 IN_REM_R3
ifdef VBOX_WITH_IDT_PATCHING
tstVMStructSize_DEFS += VBOX_WITH_IDT_PATCHING
endif
tstVMStructSize_INCS = $(VBOX_PATH_VMM_SRC) $(VBOX_PATH_VMM_SRC)/PATM $(PATH_TARGET)
tstVMStructSize_SOURCES = tstVMStructSize.cpp
tstVMStructSize_LIBS.l4 = $(LIB_RUNTIME)
tstVMStructSize.cpp_DEPS= $(PATH_TARGET)/tstVMStructGC.h
tstAsmStructs_TEMPLATE = VBOXR3TSTEXE
tstAsmStructs_DEFS = IN_VMM_R3 IN_PDM_R3 IN_CFGM_R3 IN_IOM_R3 IN_VM_R3 IN_CPUM_R3 IN_SELM_R3 IN_PGM_R3 IN_TRPM_R3 IN_MM_R3 IN_PDM_R3 IN_DBGF_R3 IN_PATM_R3 IN_DIS_R3 IN_STAM_R3 IN_VGADEVICE_R3 IN_CSAM_R3 IN_SSM_R3
ifdef VBOX_WITH_IDT_PATCHING
tstAsmStructs_DEFS += VBOX_WITH_IDT_PATCHING
endif
tstAsmStructs_INCS = $(VBOX_PATH_VMM_SRC) $(PATH_TARGET)
tstAsmStructs_SOURCES = tstAsmStructs.cpp
tstAsmStructs_LIBS.l4 = $(LIB_RUNTIME)
tstAsmStructsGC_TEMPLATE= VBOXGCEXE
tstAsmStructsGC_DEFS = IN_VMM_GC IN_PDM_GC IN_CFGM_GC IN_IOM_GC IN_VM_GC IN_CPUM_GC IN_SELM_GC IN_PGM_GC IN_TRPM_GC IN_MM_GC IN_PDM_GC IN_DBGF_GC IN_PATM_GC IN_DIS_GC IN_STAM_GC IN_VGADEVICE_GC IN_CSAM_GC IN_SSM_GC IN_RRM_GC
ifdef VBOX_WITH_IDT_PATCHING
tstAsmStructsGC_DEFS += VBOX_WITH_IDT_PATCHING
endif
tstAsmStructsGC_INCS = $(VBOX_PATH_VMM_SRC) $(PATH_TARGET)
tstAsmStructsGC_SOURCES = tstAsmStructs.cpp
tstAsmStructs.cpp_DEPS = $(PATH_TARGET)/tstAsmStructsHC.h $(PATH_TARGET)/tstAsmStructsGC.h
tstGlobalConfig_TEMPLATE= VBOXR3TSTEXE
tstGlobalConfig_SOURCES = tstGlobalConfig.cpp
tstGlobalConfig_LIBS = $(LIB_RUNTIME)
tstMMHyperHeap_TEMPLATE = VBOXR3TSTEXE
tstMMHyperHeap_SOURCES = tstMMHyperHeap.cpp
tstMMHyperHeap_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstSSM_TEMPLATE = VBOXR3TSTEXE
tstSSM_SOURCES = tstSSM.cpp
tstSSM_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstCFGM_TEMPLATE = VBOXR3TSTEXE
tstCFGM_SOURCES = tstCFGM.cpp
tstCFGM_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMM_TEMPLATE = VBOXR3EXE
tstVMM_SOURCES = tstVMM.cpp
tstVMM_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMM-HwAccm_TEMPLATE = VBOXR3EXE
tstVMM-HwAccm_SOURCES = tstVMM-HwAccm.cpp
tstVMM-HwAccm_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMMFork_TEMPLATE = VBOXR3EXE
tstVMMFork_SOURCES = tstVMMFork.cpp
tstVMMFork_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMM-2_TEMPLATE = VBOXR3EXE
tstVMM-2_SOURCES = tstVMM-2.cpp
tstVMM-2_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMMR0CallHost-1_TEMPLATE = VBOXR3EXE
tstVMMR0CallHost-1_INCS = $(VBOX_PATH_VMM_SRC)
tstVMMR0CallHost-1_SOURCES = \
tstVMMR0CallHost-1.cpp \
$(VBOX_PATH_VMM_SRC)/VMMR0/VMMR0A.asm
tstVMMR0CallHost-1_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMREQ_TEMPLATE = VBOXR3EXE
tstVMREQ_SOURCES = tstVMREQ.cpp
tstVMREQ_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstAnimate_TEMPLATE = VBOXR3EXE
tstAnimate_SOURCES = tstAnimate.cpp
tstAnimate_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstCompiler_TEMPLATE = VBOXR3TSTEXE
tstCompiler_SOURCES = tstCompiler.cpp
tstCompiler_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstMicro_TEMPLATE = VBOXR3EXE
tstMicro_SOURCES = tstMicro.cpp
tstMicro_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
# tstMicroGC.gc
tstMicroGC_TEMPLATE = VBOXGC
tstMicroGC_SOURCES = tstMicroGC.cpp tstMicroGCA.asm
tstMicroGC_DEFS =
tstMicroGC_INCS = $(VBOX_PATH_VMM_SRC)/testcase
ifeq ($(VBOX_LDR_FMT32),pe)
tstMicroGC_LDFLAGS = -Entry:tstMicroGC
endif
tstMicroGC_SYSSUFF = .gc
tstMicroGC_LIBS = \
$(PATH_LIB)/DisasmGC$(VBOX_SUFF_LIB) \
$(PATH_LIB)/RuntimeGC$(VBOX_SUFF_LIB)
ifeq ($(filter-out pe lx,$(VBOX_LDR_FMT32)),)
tstMicroGC_LIBS += \
$(PATH_LIB)/VMMGCBuiltin$(VBOX_SUFF_LIB) \
$(LIB_VMMGC)
endif
tstMicroGC_SOURCES.win = tstMicroGC.def
ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
tstPDMAsyncCompletion_TEMPLATE = VBOXR3EXE
tstPDMAsyncCompletion_SOURCES = tstPDMAsyncCompletion.cpp
tstPDMAsyncCompletion_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
endif
include $(KBUILD_PATH)/subfooter.kmk
#
# Some handcrafted support targets for tstAsmStructs.
#
ifeq ($(KBUILD_HOST),win)
include $(KBUILD_PATH)/tools/MINGW32.kmk
VBOX_NM ?= $(PATH_TOOL_MINGW32)/bin/nm.exe -p
else
VBOX_NM ?= nm -p
endif
MY_ASA_ASM_STUFF = \
$(addprefix -D, \
$(DEFS) \
$(DEFS.$(KBUILD_TYPE)) \
$(DEFS.$(KBUILD_TARGET)) \
IN_RING3 $(ARCH_BITS_DEFS) \
$(DEFS.$(KBUILD_TARGET_ARCH)) \
$(DEFS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
) \
-f $(if $(eq $(KBUILD_TARGET),darwin),macho,elf) \
$(foreach inc,$(INCS) $(VBOX_PATH_VMM_SRC)/testcase $(PATH_TARGET),-I$(inc)/)
# 1a. make a header file which makes all the structures+members globals.
$(PATH_TARGET)/tstAsmStructsAsm.mac: \
$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm.asm \
$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm-lst.sed \
$(DEPTH)/include/iprt/asmdefs.mac \
$(DEPTH)/include/VBox/cpum.mac \
$(DEPTH)/include/VBox/sup.mac \
$(DEPTH)/include/VBox/vm.mac \
$(VBOX_PATH_VMM_SRC)/CPUMInternal.mac \
$(VBOX_PATH_VMM_SRC)/TRPMInternal.mac \
$(VBOX_PATH_VMM_SRC)/VMMInternal.mac \
$(VBOX_PATH_VMM_SRC)/testcase/Makefile.kmk \
$(PATH_ROOT)/Config.kmk $(LOCALCFG) $(AUTOCFG) \
| $(call DIRDEP,$(PATH_TARGET))
$(call MSG_GENERATE,tstVMStructSize,$@,$<)
ifndef DONT_USE_YASM
$(QUIET)$(TOOL_YASM_AS) $(MY_ASA_ASM_STUFF) -o $@.o -l $@.lst $<
$(SED) -f $(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm-lst.sed --output $@ $@.lst
else
$(QUIET)$(TOOL_NASM_AS) -g $(MY_ASA_ASM_STUFF) -o $@.o -l $@.lst $<
$(VBOX_NM) $@.o | $(SED) \
-e '/[0-9a-fA-F][0-9a-fA-F]* [^a] /d' \
-e 's/[0-9a-fA-F][0-9a-fA-F]* a \([^ ]*\)/global \1/' \
> $@
endif
# 1b. make an elf/macho object containing the offsets.
$(PATH_TARGET)/tstAsmStructsAsm.o: \
$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm.asm \
$(PATH_TARGET)/tstAsmStructsAsm.mac \
$(VBOX_PATH_VMM_SRC)/testcase/Makefile.kmk \
| $(call DIRDEP,$(PATH_TARGET))
$(call MSG_COMPILE,tstAsmStructsasm,$<,$@,AS)
ifndef DONT_USE_YASM
$(QUIET)$(TOOL_YASM_AS) $(MY_ASA_ASM_STUFF) -DDO_GLOBALS -o $@ $<
else
$(QUIET)$(TOOL_NASM_AS) $(MY_ASA_ASM_STUFF) -DDO_GLOBALS -o $@ $<
endif
# 2. use nm and sed to transform this into the header we want.
$(PATH_TARGET)/tstAsmStructsHC.h: $(PATH_TARGET)/tstAsmStructsAsm.o
$(call MSG_GENERATE,tstVMStructSize,$@,$<)
$(QUIET)$(RM) -f $@ $@.dump $@.tmp
$(QUIET)$(REDIRECT) -wo $@.dump -- $(VBOX_NM) $<
$(QUIET)$(SED) -e '/STAMPROFILEADV/d' \
-e '/00[0-9a-fA-F]* [aA] [^_.]*\./!d' -e 's/\(00[0-9a-fA-F]*\) [aA] \([^.]*\)\.\(.*$$\)/ CHECK_OFF(\2, 0x0\1, \3);/' \
--output $@.tmp $@.dump
$(QUIET)$(SED) -e '/VM_size$$/d' \
-e '/00[0-9a-fA-F]* [aA] [^_.]*_size$$/!d' -e 's/\(00[0-9a-fA-F]*\) [aA] \([^_.]*\)_size/ CHECK_SIZE(\2, 0x0\1);/' \
--append $@.tmp $@.dump
$(QUIET)$(MV) -f $@.tmp $@
$(QUIET)$(RM) -f $@.dump
# 3. transform the HC header into a GC one by omitting some HC only structures.
$(PATH_TARGET)/tstAsmStructsGC.h: $(PATH_TARGET)/tstAsmStructsHC.h
$(call MSG_GENERATE,tstVMStructSize,$@,$<)
$(QUIET)$(SED) -e '/VMMSWITCHERDEF/d' --output $@ $^
## @todo make this default kBuild behaviour.
.SECONDEXPANSION:
# 4. run it.
$(PATH_TARGET)/tstAsmStructs.run: $$(INSTARGET_tstAsmStructs) $$(INSTARGET_tstAsmStructsGC)
$(QUIET)$(RM) -f $@
$(INSTARGET_tstAsmStructs)
$(INSTARGET_tstAsmStructsGC)
$(QUIET)$(APPEND) "$@" "done"
#
# Run rule for tstVMStructSize.
#
# 1. Manually dump selected structures and members.
$(PATH_TARGET)/tstVMStructGC.h: $$(INSTARGET_tstVMStructGC)
$(call MSG_GENERATE,tstVMStructSize,$@)
$(QUIET)$(REDIRECT) -wo $@ -- $(INSTARGET_tstVMStructGC)
# 2. run it.
$(PATH_TARGET)/tstVMStructSize.run: $$(INSTARGET_tstVMStructSize)
$(QUIET)$(RM) -f $@
$^
$(QUIET)$(APPEND) "$@" "done"
# alias for the two struct tests.
run-struct-tests: $(PATH_TARGET)/tstAsmStructs.run $(PATH_TARGET)/tstVMStructSize.run