# $Id$
## @file
# kBuild Configuration file for the VirtualBox Validation Kit.
#
#
# Copyright (C) 2010-2014 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.
#
# The contents of this file may alternatively be used under the terms
# of the Common Development and Distribution License Version 1.0
# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
# VirtualBox OSE distribution, in which case the provisions of the
# CDDL are applicable instead of those of the GPL.
#
# You may elect to license modified versions of this file under the
# terms and conditions of either the GPL or the CDDL or both.
#
VBOX_VALIDATIONKIT_CONFIG_KMK_INCLUDED = 1
# Include the top-level configure file.
ifndef VBOX_ROOT_CONFIG_KMK_INCLUDED
include $(PATH_ROOT)/Config.kmk
endif
#
# Globals
#
VBOX_PATH_VALIDATIONKIT_SRC := $(PATH_ROOT)/src/VBox/ValidationKit
#
# Base template that drops the -static flag since we only want to use the
# static version of our own libraries and not the system libs.
#
TEMPLATE_VBoxValidationKitR3Base = VBox Validation Kit ring-3 program base, both guest and host.
TEMPLATE_VBoxValidationKitR3Base_EXTENDS = VBoxR3Static
ifn1of ($(KBUILD_TARGET), darwin solaris win)
TEMPLATE_VBoxValidationKitR3Base_CFLAGS = $(filter-out -static, $(TEMPLATE_VBoxR3Static_CFLAGS))
TEMPLATE_VBoxValidationKitR3Base_CXXFLAGS = $(filter-out -static, $(TEMPLATE_VBoxR3Static_CXXFLAGS))
TEMPLATE_VBoxValidationKitR3Base_OBJCFLAGS = $(filter-out -static, $(TEMPLATE_VBoxR3Static_OBJCFLAGS))
TEMPLATE_VBoxValidationKitR3Base_LDFLAGS = $(filter-out -static, $(TEMPLATE_VBoxR3Static_LDFLAGS))
endif
TEMPLATE_VBoxValidationKitR3Base_LIBS = $(TEMPLATE_VBoxR3Static_LIBS)
if1of ($(KBUILD_TARGET), linux)
TEMPLATE_VBoxValidationKitR3Base_LIBS += supc++ crypt
TEMPLATE_VBoxValidationKitR3Base_LDTOOL = $(subst GXX,GCC,$(TEMPLATE_VBoxR3Static_TOOL))
endif
TEMPLATE_VBoxValidationKitR3Base_LDFLAGS.darwin = $(TEMPLATE_VBoxR3Static_LDFLAGS.darwin) -framework IOKit
#
# Template for building ring-3 progams for the Validation Kit.
# These programs can run on any host or guest.
#
TEMPLATE_VBoxValidationKitR3 = VBox Validation Kit ring-3 program, both guest and host.
TEMPLATE_VBoxValidationKitR3_EXTENDS = VBoxValidationKitR3Base
TEMPLATE_VBoxValidationKitR3_EXTENDS_BY = appending
TEMPLATE_VBoxValidationKitR3_INST = $(INST_VALIDATIONKIT)$(KBUILD_TARGET)/$(KBUILD_TARGET_ARCH)/
TEMPLATE_VBoxValidationKitR3_SDKS.win = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK) VBOX_NTDLL
TEMPLATE_VBoxValidationKitR3_DEFS = IN_RT_R3
TEMPLATE_VBoxValidationKitR3_LIBS.darwin = iconv
TEMPLATE_VBoxValidationKitR3_LIBS.freebsd = iconv
TEMPLATE_VBoxValidationKitR3_LIBS = \
$(PATH_STAGE_LIB)/RuntimeR3$(VBOX_SUFF_LIB)
ifdef IPRT_WITH_KSTUFF
TEMPLATE_VBoxValidationKitR3_LIBS += \
$(PATH_STAGE_LIB)/VBox-kStuffStatic$(VBOX_SUFF_LIB) \
$(PATH_STAGE_LIB)/RuntimeR3$(VBOX_SUFF_LIB)
endif
ifeq ($(KBUILD_TARGET),solaris)
TEMPLATE_VBoxValidationKitR3_LIBS += \
kstat \
nsl \
contract
if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
TEMPLATE_VBoxValidationKitR3_LIBS += \
smbios
endif
endif
ifneq ($(KBUILD_TARGET),win)
TEMPLATE_VBoxValidationKitR3_LIBS += \
$(SDK_VBOX_ZLIB_LIBS)
endif
# Make VCC100 output work on NT4, W2K, XP and W2K3.
TEMPLATE_VBoxValidationKitR3_LIBS.win.x86 = \
$(PATH_TOOL_$(TEMPLATE_VBoxValidationKitR3_TOOL.win.x86)_LIB)/oldnames.lib \
$(PATH_TOOL_$(TEMPLATE_VBoxValidationKitR3_TOOL.win.x86)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
$(PATH_TOOL_$(TEMPLATE_VBoxValidationKitR3_TOOL.win.x86)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib \
$(PATH_STAGE_LIB)/RuntimeR3VccTricks$(VBOX_SUFF_LIB)
ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),win.x86)
TEMPLATE_VBoxValidationKitR3_POST_CMDS = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) $(out)$$(NLTAB))$(TEMPLATE_VBoxValidationKitR3Base_POST_CMDS)$$(NLTAB)
endif
TEMPLATE_VBoxValidationKitR3_LNK_DEPS.win.x86 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION))
#TODO: TEMPLATE_VBoxValidationKitR3_EXTENDS = VBOXGUESTR3EXE
#
# Template for building ring-3 progams for the Validation Kit.
# These programs can run on the host and may take advantage of the support
# driver when installed.
#
TEMPLATE_VBoxValidationKitR3Host = VBox Validation Kit ring-3 program, mainly host.
TEMPLATE_VBoxValidationKitR3Host_EXTENDS = VBoxValidationKitR3Base
TEMPLATE_VBoxValidationKitR3Host_EXTENDS_BY = appending
TEMPLATE_VBoxValidationKitR3Host_INST = $(INST_VALIDATIONKIT)$(KBUILD_TARGET)/$(KBUILD_TARGET_ARCH)/
TEMPLATE_VBoxValidationKitR3Host_SDKS.win = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK) VBOX_NTDLL
TEMPLATE_VBoxValidationKitR3Host_DEFS = IN_RT_R3 IN_SUP_R3
TEMPLATE_VBoxValidationKitR3Host_LIBS.darwin = iconv
TEMPLATE_VBoxValidationKitR3Host_LIBS.freebsd = iconv
TEMPLATE_VBoxValidationKitR3Host_LIBS = \
$(PATH_STAGE_LIB)/RuntimeR3$(VBOX_SUFF_LIB) \
$(PATH_STAGE_LIB)/SUPR3Static$(VBOX_SUFF_LIB) \
$(PATH_STAGE_LIB)/RuntimeR3$(VBOX_SUFF_LIB)
ifdef IPRT_WITH_KSTUFF
TEMPLATE_VBoxValidationKitR3Host_LIBS += \
$(PATH_STAGE_LIB)/VBox-kStuffStatic$(VBOX_SUFF_LIB) \
$(PATH_STAGE_LIB)/RuntimeR3$(VBOX_SUFF_LIB)
endif
ifeq ($(KBUILD_TARGET),solaris)
TEMPLATE_VBoxValidationKitR3Host_LIBS += \
kstat \
nsl \
contract
if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
TEMPLATE_VBoxValidationKitR3Host_LIBS += \
smbios
endif
endif
#
# Template for building agnostic ring-0 host modules for the Validation Kit.
#
TEMPLATE_VBoxValidationKitR0 = VBox Validation Kit agnostic ring-0 host module.
TEMPLATE_VBoxValidationKitR0_EXTENDS = VBoxR0
TEMPLATE_VBoxValidationKitR0_EXTENDS_BY = appending
TEMPLATE_VBoxValidationKitR0_INST = $(INST_VALIDATIONKIT)$(KBUILD_TARGET)/$(KBUILD_TARGET_ARCH)/
TEMPLATE_VBoxValidationKitR0_DEFS = IN_RT_R0
TEMPLATE_VBoxValidationKitR0_LIBS = \
$(PATH_STAGE_LIB)/RuntimeR0$(VBOX_SUFF_LIB)
if1of ($(KBUILD_TARGET),os2 win)
TEMPLATE_VBoxValidationKitR0_LIBS += \
$(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
endif
#
# List of python sources that should be linted and unittested.
#
VBOX_VALIDATIONKIT_PYTHON_SOURCES :=
VBOX_VALIDATIONKIT_PYLINT_TARGETS :=
VBOX_VALIDATIONKIT_PYUNITTEST_EXCLUDE :=
ifdef VBOX_WITH_PYLINT
TESTING +=
endif
#
# Process python sources.
#
if1of ($(KBUILD_TARGET), win os2)
VBOX_PYTHONPATH_VALIDATIONKIT = $(PYTHONPATH);$(VBOX_PATH_VALIDATIONKIT_SRC);$(VBOX_PATH_VALIDATIONKIT_SRC)/testboxscript;$(VBOX_PATH_VALIDATIONKIT_SRC)/testmanager
else
VBOX_PYTHONPATH_VALIDATIONKIT = $(PYTHONPATH):$(VBOX_PATH_VALIDATIONKIT_SRC):$(VBOX_PATH_VALIDATIONKIT_SRC)/testboxscript:$(VBOX_PATH_VALIDATIONKIT_SRC)/testmanager
endif
BLDDIRS += $(PATH_TARGET)/pylint $(PATH_TARGET)/pyunittest
define def_vbox_validationkit_py_check
$(eval name:=$(basename $(notdir $(py))))
pylint:: $(name)-py-phony.o
$(name).o: $(name)-py-phony.o
$(PATH_TARGET)/pylint/$(name).o $(name)-py-phony.o:: $(py) | $(PATH_TARGET)/pylint/
ifdef VBOX_WITH_PYLINT
$(QUIET2)$(call MSG_L1,Subjecting $(py) to pylint...)
$(QUIET)$(REDIRECT) -C "$(dir $(py))" -E LC_ALL=C -E PYTHONPATH="$(VBOX_PYTHONPATH_VALIDATIONKIT)" -- \
$(VBOX_PYLINT) --rcfile=$(VBOX_PATH_VALIDATIONKIT_SRC)/pylintrc $$(VBOX_PYLINT_FLAGS) $$($(py)_VBOX_PYLINT_FLAGS) ./$(notdir $(py))
endif
$(QUIET)$(APPEND) -t "$(PATH_TARGET)/pylint/$(name).o"
ifn1of ($(py),$(VBOX_VALIDATIONKIT_PYUNITTEST_EXCLUDE))
pyunittest:: $(name)-pyunittest.o
$(PATH_TARGET)/pyunittest/$(name).o $(name)-pyunittest.o:: $(py) | $(PATH_TARGET)/pyunittest/
$(QUIET2)$(call MSG_L1,Unittesting Python source $(py)...)
$(QUIET)$(REDIRECT) -E LC_ALL=C -E PYTHONPATH="$(VBOX_PYTHONPATH_VALIDATIONKIT)" -C $(dir $(py)) \
-- $(VBOX_BLD_PYTHON) -m unittest -v $(notdir $(basename $(py)))
$(QUIET)$(APPEND) -t "$(PATH_TARGET)/pyunittest/$(name).o"
VBOX_VALIDATIONKIT_PYUNITTEST_TARGETS += $(PATH_TARGET)/pyunittest/$(name).o
TESTING += $(name)-pyunittest.o
endif
TESTING += $(name)-py-phony.o
VBOX_VALIDATIONKIT_PYLINT_TARGETS += $(PATH_TARGET)/pylint/$(name).o
endef # def_vbox_validationkit_py_check
define def_vbox_validationkit_process_python_sources
$(if-expr $(words $(_SUB_MAKEFILE_STACK)) <= 0 || "$1" == "FORCE", \
$(foreach py, $(VBOX_VALIDATIONKIT_PYTHON_SOURCES), $(eval $(def_vbox_validationkit_py_check))),)
endef
#
# http://www.jshint.com
#
VBOX_JSHINT ?= jshint
VBOX_JSHINT_FLAGS := --config $(VBOX_PATH_VALIDATIONKIT_SRC)/jshintrc.js --verbose
ifndef VBOX_WITH_JSHINT
VBOX_WITH_JSHINT := $(which $(VBOX_JSHINT))
endif
#
# List of javascript sources that should be checked and linted.
#
VBOX_VALIDATIONKIT_JS_SOURCES :=
define def_vbox_validationkit_js_check
$(eval name:=$(basename $(notdir $(js))))
$(name).o $(name).obj:: # $(PATH_SUB_CURRENT)/$(js)
-$(REDIRECT) -E LC_ALL=C -C $(dir $(js)) -- $$(VBOX_JSHINT) ./$(notdir $(js)) $$(VBOX_JSHINT_FLAGS)
jslint:: $(name).o
endef
define def_vbox_validationkit_process_js_sources
$(if-expr $(words $(_SUB_MAKEFILE_STACK)) <= 0, \
$(foreach js, $(VBOX_VALIDATIONKIT_JS_SOURCES), $(eval $(def_vbox_validationkit_js_check))),)
endef