// $Id: pin.mpb 2159 2013-10-29 06:01:21Z hillj $

project {
  includes += $(PIN_ROOT)/source/include \
              $(PIN_ROOT)/source/include/pin \
              $(PIN_ROOT)/source/include/pin/gen \
              $(PIN_ROOT)/extras/components/include

  macros += BIGARRAY_MULTIPLIER=1 USING_XED

  specific (prop:windows) {
    macros += TARGET_WINDOWS _SECURE_SCL=0

    compile_flags += /Oy

    linkflags += -Wl,--hash-style=sysv -Wl,-Bsymbolic -Wl,--version-script=$(PIN_ROOT)/source/include/pintool.ver

    runtime_library = 0
    DisableSpecificWarning += 4530
    IgnoreAllDefaultLibraries = true
  } else {
    compile_flags += -O3 -fomit-frame-pointer -fno-strict-aliasing -Wunused-parameter -Wno-unknown-pragmas -fno-stack-protector -fPIC

    libs += pin xed
  }

  verbatim (gnuace, macros) {
    // Check for MacOS X vs. Linux
    ifeq ($(shell uname -s), Darwin)
      CPPFLAGS += -DTARGET_MAC
      LDFLAGS  += -lpindwarf -lpinpthread
      LDFLAGS  -= -lpthread
    else
      CPPFLAGS += -DTARGET_LINUX
    endif

    // We have to disable hidden symbols since we are
    // not manually exporting the main() function.
    no_hidden_visibility = 1
  }

  verbatim (make, macros) {
    // Check for MacOS X vs. Linux
    ifeq ($(shell uname -s), Darwin)
      CPPFLAGS += -DTARGET_MAC
      LDFLAGS  += -lpindwarf -lpinpthread
      LDFLAGS  -= -lpthread
    else
      CPPFLAGS += -DTARGET_LINUX
    endif

    // We have to disable hidden symbols since we are
    // not manually exporting the main() function.
    no_hidden_visibility = 1
  }
}

feature(ia32) {
  includes += $(PIN_ROOT)/extras/xed2-ia32/include

  libpaths += $(PIN_ROOT)/ia32/lib \
              $(PIN_ROOT)/ia32/lib-ext \
              $(PIN_ROOT)/extras/xed2-ia32/lib

  macros += TARGET_IA32 HOST_IA32

  specific (prop:windows) {
    // DO NOT CHANGE ORDER
    pure_libs += "ntdll-32.lib libxed.lib pin.lib pinvm.lib libcmt.lib libcpmt.lib"

    libpaths += $(PIN_ROOT)/ia32/lib \
                $(PIN_ROOT)/ia32/lib-ext
  }
}

feature(intel64) {
  includes += $(PIN_ROOT)/extras/xed2-intel64/include

  libpaths += $(PIN_ROOT)/intel64/lib \
              $(PIN_ROOT)/intel64/lib-ext \
              $(PIN_ROOT)/extras/xed2-intel64/lib

  macros += TARGET_IA32E HOST_IA32E

  specific (prop:windows) {
    // DO NOT CHANGE ORDER
    pure_libs += "ntdll-64.lib libxed.lib pin.lib pinvm.lib libcmt.lib libcpmt.lib"
  }
}
