1 2 #PIN_ROOT is taken from env var. 3 PIN_BIN=${PIN_ROOT}/pin 4 5 INLINE= 6 OPTLEVEL=-O3 7 CXXFLAGS_L=$(OPTLEVEL) $(INLINE) -Wall -Werror -Wno-unknown-pragmas -g -fno-omit-frame-pointer -fno-strict-aliasing -fPIC 8 CXXFLAGS_L64=-DBIGARRAY_MULTIPLIER=1 -DUSING_XED -DTARGET_IA32E -DHOST_IA32E -DTARGET_LINUX 9 CXXFLAGS_L32=-DBIGARRAY_MULTIPLIER=1 -DUSING_XED -DTARGET_IA32 -DHOST_IA32 -DTARGET_LINUX 10 INCLUDES_L64=-I.. -I$(PIN_ROOT)/extras/xed2-intel64/include -I$(PIN_ROOT)/source/include -I$(PIN_ROOT)/source/include/gen 11 INCLUDES_L32=-I.. -I$(PIN_ROOT)/extras/xed2-ia32/include -I$(PIN_ROOT)/source/include -I$(PIN_ROOT)/source/include/gen 12 LIBPATHS_L64=-L$(PIN_ROOT)/extras/xed2-intel64/lib -L$(PIN_ROOT)/intel64/lib -L$(PIN_ROOT)/intel64/lib-ext 13 LIBPATHS_L32=-L$(PIN_ROOT)/extras/xed2-ia32/lib -L$(PIN_ROOT)/ia32/lib -L$(PIN_ROOT)/ia32/lib-ext 14 LDFLAGS_L=-g -shared -Wl,-Bsymbolic -Wl,--version-script=$(PIN_ROOT)/source/include/pintool.ver 15 LIBS_L= -lpin -lxed -ldwarf -lelf -ldl -lpthread 16 17 18 ifeq ($(OS), l) 19 SO=so 20 OBJ=o 21 CXX=g++ 22 LD=g++ 23 LIBS=$(LIBS_L) 24 ifeq ($(B), 64) 25 CXXFLAGS=$(CXXFLAGS_L) $(CXXFLAGS_L64) $(INCLUDES_L64) -m64 26 LDFLAGS=$(LDFLAGS_L) $(LIBPATHS_L64) -m64 27 else 28 CXXFLAGS=$(CXXFLAGS_L) $(CXXFLAGS_L32) $(INCLUDES_L32) -m32 29 LDFLAGS=$(LDFLAGS_L) $(LIBPATHS_L32) -m32 30 endif 31 else ifeq ($(OS), w) 32 SO=dll 33 OBJ=obj 34 CXX=cl 35 LD=link 36 CXXFLAGS=/c /MT /EHs- /EHa- /wd4530 /DTARGET_WINDOWS /DBIGARRAY_MULTIPLIER=1 /DUSING_XED /D_CRT_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo /Gy /O2 /DTARGET_IA32 /DHOST_IA32 \ 37 /I.. /I$(PIN_ROOT)/source/include /I$(PIN_ROOT)/source/include/gen /I$(PIN_ROOT)/extras/xed2-ia32/include 38 LDFLAGS=/DLL /EXPORT:main /NODEFAULTLIB /NOLOGO /INCREMENTAL:NO /OPT:REF /MACHINE:x86 /ENTRY:Ptrace_DllMainCRTStartup@12 /BASE:0x55000000 \ 39 /LIBPATH:$(PIN_ROOT)/ia32/lib /LIBPATH:$(PIN_ROOT)/ia32/lib-ext /LIBPATH:$(PIN_ROOT)/extras/xed2-ia32/lib 40 LIBS=pin.lib libxed.lib libcpmt.lib libcmt.lib pinvm.lib kernel32.lib ntdll-32.lib 41 else 42 43 endif 44 45 ifeq ($(DEBUG), 1) 46 BUILD_SUFIX=_deb 47 DEFINES=-DDEBUG=1 48 else 49 BUILD_SUFIX=_opt 50 DEFINES=-DINCLUDE_THREAD_SANITIZER_CC=1 51 endif 52 53 54 SUFIX=_${OS}$(B)$(BUILD_SUFIX) 55 56 ALL_OBJECTS=ts_pin$(SUFIX).$(OBJ) ts_util$(SUFIX).$(OBJ) thread_sanitizer$(SUFIX).$(OBJ) 57 58 all: 59 60 pintool: ts_pin$(SUFIX).$(SO) 61 62 l: l32 l64 63 l64: l64o l64d 64 l32: l32o l32d 65 ld: l64d l32d 66 lo: l64o l32o 67 68 l64d: 69 $(MAKE) pintool OS=l B=64 DEBUG=1 70 l64o: 71 $(MAKE) pintool OS=l B=64 DEBUG=0 72 73 l32d: 74 $(MAKE) pintool OS=l B=32 DEBUG=1 75 l32o: 76 $(MAKE) pintool OS=l B=32 DEBUG=0 77 78 w32d: 79 $(MAKE) pintool OS=w B=32 DEBUG=1 80 81 82 83 84 ts_pin$(SUFIX).so: $(ALL_OBJECTS) 85 $(LD) $(LDFLAGS) $(LIBPATHS) -o $@ $^ $(LIBS) 86 87 ts_pin$(SUFIX).dll: $(ALL_OBJECTS) 88 $(LD) $(LDFLAGS) $(LIBPATHS) /IMPLIB:ts_pin$(SUFIX).lib /PDB:ts_pin$(SUFIX).pdb /OUT:$@ $^ $(LIBS) 89 90 HEADERS=../thread_sanitizer.h ../ts_util.h 91 92 93 %$(SUFIX).o: %.cc $(HEADERS) 94 $(CXX) $(CXXFLAGS) -o $@ -c $< $(DEFINES) 95 %$(SUFIX).o: ../%.cc $(HEADERS) 96 $(CXX) $(CXXFLAGS) -o $@ -c $< $(DEFINES) 97 98 %$(SUFIX).obj: %.cc $(HEADERS) 99 $(CXX) $(CXXFLAGS) /Fo$@ -c $< $(DEFINES) 100 %$(SUFIX).obj: ../%.cc $(HEADERS) 101 $(CXX) $(CXXFLAGS) /Fo$@ -c $< $(DEFINES) 102 103 104 #all_tests: simple_pin_test.so detach_example.so 105 #%.so: %.$(OBJ) 106 # $(CXX) $(LDFLAGS) $(LIBPATHS) -o $@ $< $(LIBS) 107 # 108 # 109 win_test.exe: win_test.cpp 110 cl /Zi $< 111 112 113 clean: 114 rm -fv *.so *.o *.obj *.dll core* pintool.log* pin.log *.exp *.lib *.pdb *.ilk *.exe 115