##############################################################
# 
# Copyright (C) 2021-2024 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 ######

# Define the SDE example pin tools to build
SDE_TOOLS := example agen-example amx-example apx-example reg-example
PINPLAY_TOOLS := controller-example example-procinfo example-replay pcregions_control

ifneq ($(OS),Windows_NT)
PINPLAY_TOOLS += loop-profiler loop-tracker looppoint
endif

TOOL_ROOTS := $(SDE_TOOLS) $(PINPLAY_TOOLS)

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

# See makefile.default.rules for the default build rules.
TOOL_CXXFLAGS := -I$(SDE_ROOT)/include $(TOOL_CXXFLAGS)
TOOL_CXXFLAGS += -DSDE_INIT -DPINPLAY -I$(PINPLAY_ROOT)/include
TOOL_CXXFLAGS += -DPIN_RT -D_LIBCPP_HAS_MUSL_LIBC -DPIN_DISABLE_CRT_REG_DEF
TOOL_CXXFLAGS += -Wno-sign-compare
ifeq ($(OS),Windows_NT)
TOOL_CXXFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -D_LIBCPP_NO_VCRUNTIME -D_LIBCPP_DISABLE_AVAILABILITY -D_mm_malloc
TOOL_CXXFLAGS += -nostdinc /std:c++17 -fno-builtin -Wno-unicode
TOOL_CXXFLAGS += -Wno-unknown-pragmas -Wno-pointer-sign -Wno-incompatible-pointer-types -Wno-microsoft-include
TOOL_CXXFLAGS += -Wno-ignored-attributes -Wno-unused-function -Wno-non-c-typedef-for-linkage
TOOL_CXXFLAGS += -Wno-invalid-noreturn -Wno-missing-braces -Wno-unused-command-line-argument
TOOL_CXXFLAGS += -Wno-nonportable-include-path -Wno-sizeof-pointer-memaccess -Wno-unused-value
TOOL_CXXFLAGS += -Wno-overloaded-virtual -Wno-unused-private-field -Wno-deprecated-declarations
TOOL_CXXFLAGS += -Wno-microsoft-enum-forward-reference -Wno-unused-but-set-variable -Wno-bitwise-instead-of-logical
TOOL_CXXFLAGS += -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override
TOOL_CXXFLAGS += -mcx16
endif

ifeq ($(OS),Windows_NT)
TOOL_LPATHS += /LIBPATH:$(SDE_ROOT)/lib/$(TARGET) /LIBPATH:$(PINPLAY_ROOT)/$(TARGET)
TOOL_LPATHS += libpinplay.lib libsde.lib bz2.lib zlib.lib
else
# sde and pinplay libraries appears twice to avoid circular dependency
TOOL_LPATHS += -L$(SDE_ROOT)/lib/$(TARGET) -L$(PINPLAY_ROOT)/$(TARGET)
TOOL_LPATHS += -lpinplay -lsde -lpinplay -lsde -lbz2 -lzlib
endif


