#
# Copyright (C) 2012-2023 Intel Corporation.
# SPDX-License-Identifier: MIT
#

##############################################################
#
# This file includes all the test targets as well as all the
# non-default build rules and test recipes.
#
##############################################################


##############################################################
#
# Test targets
#
##############################################################

###### Place all generic definitions here ######

# This defines tests which run tools of the same name.  This is simply for convenience to avoid
# defining the test name twice (once in TOOL_ROOTS and again in TEST_ROOTS).
# Tests defined here should not be defined in TOOL_ROOTS and TEST_ROOTS.
TEST_TOOL_ROOTS :=

# This defines the tests to be run that were not already defined in TEST_TOOL_ROOTS.
TEST_ROOTS :=

# This defines the tools which will be run during the the tests, and were not already defined in
# TEST_TOOL_ROOTS.
TOOL_ROOTS :=

# This defines the static analysis tools which will be run during the the tests. They should not
# be defined in TEST_TOOL_ROOTS. If a test with the same name exists, it should be defined in
# TEST_ROOTS.
# Note: Static analysis tools are in fact executables linked with the Pin Static Analysis Library.
# This library provides a subset of the Pin APIs which allows the tool to perform static analysis
# of an application or dll. Pin itself is not used when this tool runs.
SA_TOOL_ROOTS :=

# This defines all the applications that will be run during the tests.
APP_ROOTS :=

# This defines any additional object files that need to be compiled.
OBJECT_ROOTS := alarm_manager alarms control_chain control_manager controller_events ialarm parse_control init_alarm interactive_listener call-stack

# This defines any additional dlls (shared objects), other than the pintools, that need to be compiled.
DLL_ROOTS :=

# This defines any static libraries (archives), that need to be built.
LIB_ROOTS := controller

###### Handle exceptions here (OS/arch related) ######

RUNNABLE_TESTS := $(TEST_TOOL_ROOTS) $(TEST_ROOTS)

###### Handle exceptions here (bugs related) ######

###### Define the sanity subset ######

# This defines the list of tests that should run in sanity. It should include all the tests listed in
# TEST_TOOL_ROOTS and TEST_ROOTS excluding only unstable tests.
SANITY_SUBSET := $(TEST_TOOL_ROOTS) $(TEST_ROOTS)

##############################################################
#
# Build rules
#
##############################################################

# This section contains the build rules for all binaries that have special build rules.
# See makefile.default.rules for the default build rules.

###### Special libs' build rules ######

$(OBJDIR)controller$(LIB_SUFFIX): $(OBJDIR)alarm_manager$(OBJ_SUFFIX) $(OBJDIR)alarms$(OBJ_SUFFIX) $(OBJDIR)control_chain$(OBJ_SUFFIX) $(OBJDIR)control_manager$(OBJ_SUFFIX) $(OBJDIR)controller_events$(OBJ_SUFFIX) $(OBJDIR)ialarm$(OBJ_SUFFIX) $(OBJDIR)parse_control$(OBJ_SUFFIX) $(OBJDIR)init_alarm$(OBJ_SUFFIX) $(OBJDIR)interactive_listener$(OBJ_SUFFIX) $(OBJDIR)call-stack$(OBJ_SUFFIX)
	$(ARCHIVER)$@ $^

###### Special objects' build rules ######

$(OBJDIR)alarm_manager$(OBJ_SUFFIX): alarm_manager.cpp
	$(CXX) $(TOOL_CXXFLAGS) $(SUPPRESS_WARNING_ALIGNED_NEW) $(COMP_OBJ)$@ $<

$(OBJDIR)call-stack$(OBJ_SUFFIX): call-stack.cpp
	$(CXX) $(TOOL_CXXFLAGS) $(SUPPRESS_WARNING_ALIGNED_NEW) $(COMP_OBJ)$@ $<


