#
# Eraser Plugin General Nmakefile
#
# File:      Nmakefile
# Author:    Jan Fiedor (fiedorjan@centrum.cz)
# Date:      Created 2012-02-26
# Date:      Last Update 2012-05-27
# Version:   0.1
#

# We need to get the location, defines and other info about the PIN framework 
!include .\Nmakefile.pin

# Build the IA-32, Intel64 and Itanium versions of the plugin separately
BUILD_DIR = .\build\$(TARGET_LONG)

# The CMake executable we will use to perform the build 
!if ("$(CMAKE)" == "")
CMAKE = cmake
!endif
# We need to pass some information set by the PIN's Makefile to CMake
CMAKE_PIN_FLAGS = -DTARGET_LONG="$(TARGET_LONG)"
CMAKE_PIN_FLAGS = $(CMAKE_PIN_FLAGS) -DCXX="$(CXX)"
CMAKE_PIN_FLAGS = $(CMAKE_PIN_FLAGS) -DPIN_CXXFLAGS="$(PIN_CXXFLAGS)"
CMAKE_PIN_FLAGS = $(CMAKE_PIN_FLAGS) -DPIN_LDFLAGS="$(PIN_LDFLAGS)"
CMAKE_PIN_FLAGS = $(CMAKE_PIN_FLAGS) -DPIN_LPATHS="$(PIN_LPATHS)"
CMAKE_PIN_FLAGS = $(CMAKE_PIN_FLAGS) -DPIN_LIBS="$(PIN_LIBS)"
# General CMake parameters used in all types of build (debug, release, etc.)
CMAKE_FLAGS = -DCMAKE_INSTALL_PREFIX=../.. -G "NMake Makefiles"
CMAKE_FLAGS = $(CMAKE_FLAGS) $(CMAKE_PIN_FLAGS)
# General NMake parameters used in all types of build (debug, relaase, etc.)
NMAKE_FLAGS = /nologo

# The default build type is a release version
all: release

# Debug version of the plugin
debug:
	@-md $(BUILD_DIR)
	@cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) -DDEBUG=1 ../..
	@cd $(BUILD_DIR) && $(MAKE) $(NMAKE_FLAGS)

# Release version of the plugin
release:
	@-md $(BUILD_DIR)
	@cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) -DRELEASE=1 ../..
	@cd $(BUILD_DIR) && $(MAKE) $(NMAKE_FLAGS)

# Installation of the plugin
install:
	@cd $(BUILD_DIR) && $(MAKE) $(NMAKE_FLAGS) install

# Cleanup of the compiled objects, Makefiles and other stuff created by CMake
clean:
	@-rd /s /q .\build .\include .\lib

# End of file Nmakefile
