# These definitions are generated by the kit builder KIT=1# TARGET=ia32 TARGET_OS=l ############################################################## # # Here are some things you might want to configure # ############################################################## # 0 means off; 1 means on DEBUG = 1 # if your tool is not in the kit directory # then set this to the pin-2.0-X-Y directory PIN_HOME ?= .. # Select static or dynamic linking for tool # only applies to unix #PIN_DYNAMIC = -static PIN_DYNAMIC = -ldl ############################################################## # # Typical users will not need to change the stuff below here # ############################################################## ############################################################## # Set things for all architectures and all OS ############################################################## ifeq ($(DEBUG),1) DBG = -g else DBG = endif PIN_CXXFLAGS = -DBIGARRAY_MULTIPLIER=1 -DUSING_XED $(DBG) PIN_CXXFLAGS += -fno-strict-aliasing -I$(PIN_HOME)/Include -I$(PIN_HOME)/Include/gen PIN_LPATHS = -L$(PIN_HOME)/Lib/ -L$(PIN_HOME)/ExtLib/ PIN_BASE_LIBS := PIN_LDFLAGS = $(DBG) NO_LOGO = SSE2 = -msse2 ############################################################## # Set the kit versus source tree stuff ############################################################## ifndef KIT KIT = 0 endif ifeq (${KIT},0) # # Building out of a source tree # OS=$(shell uname -s) ifeq ($(findstring CYGWIN,$(OS)),CYGWIN) BUILD_OS = w TARGET_OS = w else ifeq ($(OS),Darwin) BUILD_OS = m TARGET_OS = m else BUILD_OS = l TARGET_OS = l endif endif # default to building for the host you are on. You can override this on the cmd line. HOST=$(shell uname -m) ifeq (${HOST},x86_64) TARGET=ia32e endif ifeq (${HOST},amd64) TARGET=ia32e endif ifeq (${HOST},i686) TARGET=ia32 endif ifeq (${HOST},x86) TARGET=ia32 endif ifeq (${HOST},i386) TARGET=ia32 endif ifeq (${HOST},ia64) TARGET=ipf endif ifndef TARGET $(error you must define TARGET on the command line) endif # If you are building out of a source tree and not a kit # point this to the charm directory PIN_ROOT ?= ../.. XEDOBJ = $(PIN_ROOT)/Source/obj/xed/$(TARGET)_$(TARGET)_$(TARGET_OS) PIN_CXXFLAGS += -I$(XEDOBJ)/gen PIN_CXXFLAGS += -I$(PIN_ROOT)/External/Xed/src/include/public # We override CXX only if it is the default one from Make. # Environment overrides of CXX take precidence. ifeq ($(TARGET),ipf) ifeq ($(origin CXX), default) CXX = /usr/intel/pkgs/gcc/3.4/bin/g++ endif ifeq ($(origin CC), default) CC = /usr/intel/pkgs/gcc/3.4/bin/gcc endif endif ifeq ($(TARGET),ia32) ifeq ($(TARGET_OS),l) ifeq ($(origin CC), default) CC = /usr/intel/pkgs/gcc/4.1.0/bin/gcc endif ifeq ($(origin CXX), default) CXX = /usr/intel/pkgs/gcc/4.1.0/bin/g++ endif endif endif ifeq ($(TARGET),ia32e) ifeq ($(TARGET_OS),l) ifeq ($(origin CXX), default) CXX = /usr/intel/pkgs/gcc/4.1.0/bin/g++ endif ifeq ($(origin CC), default) CC = /usr/intel/pkgs/gcc/4.1.0/bin/gcc endif endif endif ifeq ($(TARGET_OS),w) ifneq ($(BUILD_OS),w) CXX = /proj/vssad1/users/swallace/cygwin/bin/i686-pc-mingw32-g++ CC = /proj/vssad1/users/swallace/cygwin/bin/i686-pc-mingw32-gcc endif endif ifeq ($(TARGET_OS),m) ifneq ($(BUILD_OS),m) CXX = /proj/vssad1/users/swallace/mac/bin/i686-apple-darwin8-g++ CC = /proj/vssad1/users/swallace/mac/bin/i686-apple-darwin8-gcc endif endif TARGET_SPEC = ${TARGET}_${TARGET_OS}${TARGET_OFORMAT} PIN_LPATHS += -L$(PIN_ROOT)/Source/obj/${TARGET}_${TARGET_SPEC} \ -L$(PIN_ROOT)/External/Libdwarf/Lib_${TARGET_SPEC} \ -L$(PIN_ROOT)/External/Libelf/Lib_${TARGET_SPEC} \ -L$(XEDOBJ) PIN_BIN = $(PIN_ROOT)/Source/obj/${TARGET}_${TARGET_SPEC}/pin PIN = ${PIN_BIN} -slow_asserts $(PIN_FLAGS) PIN_LIBNAMES = $(PIN_ROOT)/Source/obj/${TARGET}_${TARGET_SPEC}/libpin.a else # # Building out of a kit # PIN = $(PIN_HOME)/Bin/pin -slow_asserts $(PIN_FLAGS) endif ############################################################## # Set the architecture specific stuff ############################################################## ifeq ($(TARGET),ia32) PIN_CXXFLAGS += -DTARGET_IA32 #TOOLADDR=--section-start,.interp=0x70008400 # The 400 in the address leaves room for the program headers ifeq ($(TARGET_OS),m) ### TOOLADDR setting for Mac # old value that works with MacOS 10.4.1: 0x50048000 # old value that works for SPEC but not gui program: 0x16048000 TOOLADDR = -Wl,-seg1addr -Wl,0x84048000 PIN_BASE_LIBS += -lxed PIN_PTHREAD_LIBS = -lpinpthread ### FIXMAC: __pthread_mutex_init is not yet redefined #PIN_PTHREAD_LIBS_FLAGS = -Wl,-u,__pthread_mutex_init else ### TOOLADDR setting for Linux and Windows TOOLADDR = -Wl,--section-start,.interp=0x05048400 #TOOLADDR = -Wl,--section-start,.note.ABI-tag=0x05048400 \ # -Wl,--section-start,.init=0x05049400 PIN_BASE_LIBS += -lxed PIN_PTHREAD_LIBS = -lpinpthread PIN_PTHREAD_LIBS_FLAGS = -Wl,-u,__pthread_mutex_init endif endif ifeq ($(TARGET),ia32e) PIN_CXXFLAGS += -DTARGET_IA32E -DHOST_IA32E PIN_BASE_LIBS += -lxed PIN_PTHREAD_LIBS = -lpinpthread PIN_PTHREAD_LIBS_FLAGS = -Wl,-u,__pthread_mutex_init TOOLADDR = -Wl,--section-start,.interp=0x20048000 ifeq ($(TARGET_OS),l) PIN_PIE = 0 endif endif ifeq ($(TARGET),ipf) PIN_CXXFLAGS += -DTARGET_IPF -DHOST_IPF TOOLADDR = -Wl,--section-start,.interp=0x00000c0000000400,--section-start,.init_array=0x00000e0000000400,-defsym,__init_array_start=0x00000e0000000400,-defsym,__preinit_array_start=__init_array_start,-defsym,__preinit_array_end=__preinit_array_start PIN_PTHREAD_LIBS = -lpinpthread PIN_PTHREAD_LIBS_FLAGS = -Wl,-u,__pthread_mutex_init endif ############################################################## # Set the OS specific variables # Some of this refers to architecture dependent variables # so this must second ############################################################## ifeq ($(TARGET_OS),w) ### Windows PIN_CXXFLAGS += -DTARGET_WINDOWS -mno-cygwin #FIXME: make this conditional based on the compiler PIN_BASE_LIBS += -lpinvm -lntdll PIN_LDFLAGS += -Wl,--export-all-symbols PIN_LDFLAGS += -shared -Wl,-wrap,atexit,-wrap,_onexit,-e,_True_DllMainCRTStartup@12 -mno-cygwin PIN_LDFLAGS += -Wl,--image-base -Wl,0x55000000 PINTOOL_SUFFIX = .dll #TESTAPP = C:/cygwin/bin/cp.exe TESTAPP = $(PIN_HOME)/Tests/cp-win.exe APP_CXXFLAGS += -DTARGET_WINDOWS PIN_CMP = cmp PIN_DIFF = diff -w APP_CXXFLAGS2 += -mno-cygwin EXEEXT = .exe OBJEXT = obj else ### Linux or Mac # This enables the thread safe libc by pulling in pthread.o from libpinpthread.a # Otherwise, you will get the non threadsafe version from libc # It also pulls in malloc_st.o by using malloc ifeq ($(TARGET_OS),m) PIN_CMP = ../mac-cmp else PIN_CMP = cmp endif PIN_DIFF = ${PIN_CMP} ifeq ($(TARGET_OS),l) ### Linux PIN_BASE_LIBS += -ldwarf -lelf ${PIN_DYNAMIC} PIN_CXXFLAGS += -DTARGET_LINUX PIN_LDFLAGS += -Wl,-u,malloc APP_CXXFLAGS += -DTARGET_LINUX else ### Mac PIN_BASE_LIBS += $(PIN_PTHREAD_LIBS) ${PIN_DYNAMIC} PIN_LDFLAGS += $(PIN_PTHREAD_LIBS_FLAGS) # Suppress linker warnings PIN_LDFLAGS += -w -Wl,-multiply_defined -Wl,suppress PIN_CXXFLAGS += -DTARGET_MAC APP_CXXFLAGS += -DTARGET_MAC endif PIN_LDFLAGS += ${TOOLADDR} PINTOOL_SUFFIX = EXEEXT = OBJEXT = o TESTAPP = /bin/cp endif ifeq ($(PIN_PIE),1) PIN_CXXFLAGS += -fPIE PIN_LDFLAGS += -pie -Wl,-Bsymbolic TOOLADDR = endif SAPIN_LIBS = -lsapin $(PIN_BASE_LIBS) PIN_LIBS = -lpin $(PIN_BASE_LIBS) ############################################################## # Some final variables ############################################################## # put the lpaths before all the libs PIN_LDFLAGS += ${PIN_LPATHS} OPT = -O3 NO_OPTIMIZE = -O0 COPT = -c OUTOPT = -o OUTEXE = -o LINK_OUT = -o ifeq ($(DEBUG),0) PIN_CXXFLAGS += $(OPT) endif ############################################################## # Rules to make testing easier # This testing only checks that the application ran correctly. # It does no checking of the results of the tool. # If you make the tool self checking and exit with a non zero exit code, # then it will detect the error # Before the test, we make a .tested and a .failed file. If # the test succeeds, we remove the .failed file. # find . -name '*.tested' # and # find . -name '*.failed' # will summarize what you tested and what failed ############################################################## %$(PINTOOL_SUFFIX).test : %$(PINTOOL_SUFFIX) %$(PINTOOL_SUFFIX).tested %$(PINTOOL_SUFFIX).failed touch $<.makefile.copy; rm $<.makefile.copy $(PIN) -t $< -- $(TESTAPP) makefile $<.makefile.copy $(PIN_CMP) makefile $<.makefile.copy rm $<.makefile.copy; rm $<.failed # Some subdirectories do not want the $(PINTOOL_SUFFIX) in their test name. %.test : %$(PINTOOL_SUFFIX) %$(PINTOOL_SUFFIX).tested %$(PINTOOL_SUFFIX).failed touch $<.makefile.copy; rm $<.makefile.copy $(PIN) -t $< -- $(TESTAPP) makefile $<.makefile.copy $(PIN_CMP) makefile $<.makefile.copy rm $<.makefile.copy; rm $<.failed %.tested : touch $@ %.failed : touch $@ # otherwise these are deleted if the tool build fails .PRECIOUS : %.tested %.failed