Skip to content

Instantly share code, notes, and snippets.

@w4kfu
Created January 28, 2016 16:27
Show Gist options
  • Save w4kfu/7b4817bee2b2d8372251 to your computer and use it in GitHub Desktop.
Save w4kfu/7b4817bee2b2d8372251 to your computer and use it in GitHub Desktop.
nmake pin
# Changes added _After_ Pin 2.12 / 54730
# ===========================================
# ...
# Nmake is no longer supported on windows. Either use make or the example vcproj file in the
# MyPinTool directory.
# ...
PIN_PATH = <PATH_2_PIN>
TARGET = rand
CC = cl.exe /nologo
RC = rc.exe /nologo
LINK = link.exe /nologo
SRC_DIR = .
BIN_DIR = .\bin
DEL = del /Q /F
DEL_DIR = rmdir /Q /S
SRC = <FILES_.CPP>
OBJS = $(SRC:.cpp=.obj)
!if [ml64 >nul 2>&1] == 0
PIN_INCLUDE = /I$(PIN_PATH)\extras\components\include /I$(PIN_PATH)\extras\xed-intel64\include /I$(PIN_PATH)\source\include\pin\gen /I$(PIN_PATH)\source\include\pin
PIN_LIB_PATH = /LIBPATH:$(PIN_PATH)\intel64\lib /LIBPATH:$(PIN_PATH)\intel64\lib-ext /LIBPATH:$(PIN_PATH)\extras\xed-intel64\lib
PIN_LIBS = pin.lib libxed.lib libcpmt.lib libcmt.lib pinvm.lib kernel32.lib ntdll-64.lib
CPU = x64
AS = ml64.exe /nologo
CFLAGS = /W3 /WX- /O2 /Oi /Oy- /D TARGET_IA32E /D HOST_IA32E /D TARGET_WINDOWS /D BIGARRAY_MULTIPLIER=1 /D _CRT_SECURE_NO_DEPRECATE /D _SECURE_SCL=0 /D WIN32 /Gm- /MT /GS- /Gy /Gd /TP /wd4530 /EHs- /EHa-
LFLAGS = /DLL /EXPORT:main /NODEFAULTLIB /ENTRY:Ptrace_DllMainCRTStartup $(PIN_LIB_PATH) $(PIN_LIBS)
OBJS = $(OBJS:.\=Win64\)
BUILDDIR = Win64
TARGET = $(TARGET)_64
!else
PIN_INCLUDE = /I$(PIN_PATH)\extras\components\include /I$(PIN_PATH)\extras\xed-ia32\include /I$(PIN_PATH)\source\include\pin\gen /I$(PIN_PATH)\source\include\pin
PIN_LIB_PATH = /LIBPATH:$(PIN_PATH)\ia32\lib /LIBPATH:$(PIN_PATH)\ia32\lib-ext /LIBPATH:$(PIN_PATH)\extras\xed-ia32\lib
PIN_LIBS = pin.lib libxed.lib libcpmt.lib libcmt.lib pinvm.lib kernel32.lib ntdll-32.lib
CPU = x86
AS = ml.exe /nologo
CFLAGS = /W3 /WX- /O2 /Oi /Oy- /D TARGET_IA32 /D HOST_IA32 /D TARGET_WINDOWS /D BIGARRAY_MULTIPLIER=1 /D _CRT_SECURE_NO_DEPRECATE /D _SECURE_SCL=0 /D WIN32 /Gm- /MT /GS- /Gy /Gd /TP /wd4530 /EHs- /EHa-
LFLAGS = /DLL /EXPORT:main /NODEFAULTLIB /ENTRY:Ptrace_DllMainCRTStartup@12 $(PIN_LIB_PATH) $(PIN_LIBS)
OBJS = $(OBJS:.\=Win32\)
BUILDDIR = Win32
TARGET = $(TARGET)_32
!endif
all: $(OBJS)
@IF NOT exist $(BIN_DIR) (mkdir $(BIN_DIR))
$(LINK) $(LFLAGS) /OUT:$(BIN_DIR)\$(TARGET).dll $**
{$(SRC_DIR)}.cpp{$(BUILDDIR)}.obj:
@IF NOT exist $(BUILDDIR) (mkdir $(BUILDDIR))
$(CC) /c $(PIN_INCLUDE) $(CFLAGS) /Fo$@ $<
clean:
@IF exist Win32 (@$(DEL_DIR) Win32 2> nul)
@IF exist Win64 (@$(DEL_DIR) Win64 2> nul)
@IF exist $(BIN_DIR) (@$(DEL_DIR) $(BIN_DIR) 2> nul)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment