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

##############################################################
#
# This file contains general variable definitions used by the PinTools makefiles.
# See makefile.unix.config for an explanation of each variable defined in this file.
#
##############################################################

###### Architecture ######

# Identify the architecture of the host
ifndef HOST_ARCH
    ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
        HOST_ARCH := intel64
    else
        ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
            HOST_ARCH := intel64
        endif
        ifeq ($(PROCESSOR_ARCHITECTURE),x86)
            HOST_ARCH := ia32
        endif
    endif
endif

# Verify known host
ifndef HOST_ARCH
    $(error Could not detect the host architecture. Please define HOST_ARCH from the command line.)
endif

# Define the architecture of the target
# "Platform" environment variable is set by a Visual Studio environment since version 2015.
ifeq ($(Platform),x86)
    TARGET := ia32
else
    ifeq ($(Platform),x64)
        TARGET := intel64
    else
        TARGET := $(HOST_ARCH)
    endif
endif

ifeq ($(TARGET),ia32)
    BITS := 32
else
    BITS := 64
endif

# Define the output directory
OBJDIR := obj-$(TARGET)/

# Seperator for list of paths
PATHS_SEPERATOR := ;

###### Operating system ###### 

# Identify the operating system
ifneq ($(TARGET_OS),windows)
    TARGET_OS := windows
endif

# Define the general OS type
OS_TYPE := win

COMPILER ?= clang-cl

ARCHIVER := lib /out:

ifeq ($(TARGET),ia32)
    ASMBLR := ml
    APP_ASMBLR := $(ASMBLR)
else
    ASMBLR := ml64
    APP_ASMBLR := $(ASMBLR)
endif

###### File extensions ######

EXE_SUFFIX := .exe
OBJ_SUFFIX := .obj
APP_OBJ_SUFFIX := .app.obj
DLL_SUFFIX := .dll
PINTOOL_SUFFIX := $(DLL_SUFFIX)
SATOOL_SUFFIX := .exe
LIB_SUFFIX := .lib
ASM_SUFFIX := .asm
DLL_PREFIX :=
DLL_LINKAGE_SUFFIX := $(LIB_SUFFIX)
DBG_SUFFIX := .pdb

###### Function pre/suffixes ######

GLOBALFUN_PREFIX :=

###### Attach support ######

# No limits on ATTACH in windows
ATTACH := 1

###### Additional utilities ######

RM := $(CMD_PREFIX) rm
MV := $(CMD_PREFIX) mv
SYNC := $(CMD_PREFIX) sync
PYTHON := $(CMD_PREFIX) python3
DIFF := $(CMD_PREFIX) diff -w
CMP := $(CMD_PREFIX) cmp
CMD := $(CMD_PREFIX) cmd /C
SH := $(CMD_PREFIX) sh
TR := $(CMD_PREFIX) tr
GREP := $(CMD_PREFIX) grep
QGREP := $(CMD_PREFIX) grep -q
CGREP := $(CMD_PREFIX) grep -c
EGREP := $(CMD_PREFIX) egrep
PGREP := $(CMD_PREFIX) pgrep 
LINECOUNT := $(CMD_PREFIX) wc -l
BASHTEST := $(CMD_PREFIX) test
TOUCH := $(CMD_PREFIX) touch
STRIP :=
CP := $(CMD_PREFIX) cp
OBJCOPY := 
LS_VERBOSE := $(CMD_PREFIX) ls -l --time-style=+""
SORT := $(CMD_PREFIX) /usr/bin/sort
SED := $(CMD_PREFIX) sed
EXPR := $(CMD_PREFIX) expr
UNAME := $(CMD_PREFIX) uname
READLINK := $(CMD_PREFIX) readlink
SETARCH := $(CMD_PREFIX) setarch
AWK := $(CMD_PREFIX) awk
XARGS := $(CMD_PREFIX) xargs
UNIQ := $(CMD_PREFIX) uniq

