Makefile.common 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. SIM_ROOT ?= $(shell readlink -f "$(CURDIR)/../")
  2. include $(SIM_ROOT)/Makefile.config
  3. DIRECTORIES := ${shell find $(SIM_ROOT)/common -type d -print} \
  4. $(SIM_ROOT)/include
  5. LIBCARBON_SOURCES = $(foreach dir,$(DIRECTORIES),$(wildcard $(dir)/*.cc)) \
  6. $(wildcard $(SIM_ROOT)/common/config/*.cpp)
  7. LIBCARBON_OBJECTS = $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(LIBCARBON_SOURCES) ) ) )
  8. INCLUDE_DIRECTORIES = $(DIRECTORIES) $(PIN_HOME)/extras/xed-$(SNIPER_TARGET_ARCH)/include $(PIN_HOME)/extras/xed2-$(SNIPER_TARGET_ARCH)/include $(SIM_ROOT)/linux $(SIM_ROOT)/sift
  9. CLEAN=$(findstring clean,$(MAKECMDGOALS))
  10. ifeq ($(SNIPER_TARGET_ARCH),ia32)
  11. # Add -march=i686 to enable some extra instructions that allow for implementation of 64-bit atomic adds
  12. CXXFLAGS += -m32 -march=i686 -DTARGET_IA32
  13. LD_FLAGS += -m32
  14. endif
  15. ifeq ($(SNIPER_TARGET_ARCH),intel64)
  16. CXXFLAGS += -fPIC -DTARGET_INTEL64
  17. LD_FLAGS +=
  18. endif
  19. CXXFLAGS += -DPIN_REV=$(shell $(SIM_ROOT)/tools/pinversion.py $(PIN_HOME) | cut -d. -f3)
  20. include $(SIM_ROOT)/Makefile.config
  21. ifneq ($(BOOST_INCLUDE),)
  22. CPPFLAGS += -I$(BOOST_INCLUDE)
  23. endif
  24. LD_LIBS += -lsift -lxed -L$(SIM_ROOT)/python_kit/$(SNIPER_TARGET_ARCH)/lib -lpython2.7 -lrt -lz -lsqlite3
  25. LD_FLAGS += -L$(SIM_ROOT)/lib -L$(SIM_ROOT)/sift -L$(PIN_HOME)/extras/xed-$(SNIPER_TARGET_ARCH)/lib
  26. ifneq ($(SQLITE_PATH),)
  27. CPPFLAGS += -I$(SQLITE_PATH)/include
  28. LD_FLAGS += -L$(SQLITE_PATH)/lib
  29. endif
  30. export LD_LIBRARY_PATH := $(SIM_ROOT)/lib:$(LD_LIBRARY_PATH)
  31. # Include paths
  32. CPPFLAGS+=$(foreach dir,$(INCLUDE_DIRECTORIES),-I$(dir)) \
  33. -I$(SIM_ROOT)/python_kit/$(SNIPER_TARGET_ARCH)/include/python2.7
  34. CXXFLAGS+=-c \
  35. -Wall -Wextra -Wcast-align -Wno-unused-parameter -Wno-unknown-pragmas -std=c++0x -fno-strict-aliasing $(OPT_CFLAGS) #-Werror
  36. %.h %.hh %.hpp:
  37. @echo >&2
  38. @echo " Unable to find $@" >&2
  39. @echo " You may want to try running 'make empty_deps'" >&2
  40. @echo >&2
  41. @false
  42. # Build rules for dependency generation
  43. %.d: %.cpp
  44. $(_MSG) '[DEP ]' $(subst $(shell readlink -f $(SIM_ROOT))/,,$(shell readlink -f $@))
  45. $(_CMD) $(CXX) -MM -MG $(CPPFLAGS) $(CXXFLAGS) $< | sed -n "H;$$ {g;s@.*:\(.*\)@$*.o $@: \$$\(wildcard\1\)@;p}" >$@
  46. %.d: %.cc
  47. $(_MSG) '[DEP ]' $(subst $(shell readlink -f $(SIM_ROOT))/,,$(shell readlink -f $@))
  48. $(_CMD) $(CXX) -MM -MG $(CPPFLAGS) $(CXXFLAGS) $< | sed -n "H;$$ {g;s@.*:\(.*\)@$*.o $@: \$$\(wildcard\1\)@;p}" >$@
  49. %.d: %.c
  50. $(_MSG) '[DEP ]' $(subst $(shell readlink -f $(SIM_ROOT))/,,$(shell readlink -f $@))
  51. $(_CMD) $(CC) -MM -MG $(CPPFLAGS) $(CFLAGS) $< | sed -n "H;$$ {g;s@.*:\(.*\)@$*.o $@: \$$\(wildcard\1\)@;p}" >$@
  52. # Build rules for object generation
  53. %.o: %.cpp
  54. $(_MSG) '[CXX ]' $(subst $(shell readlink -f $(SIM_ROOT))/,,$(shell readlink -f $@))
  55. $(_CMD) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
  56. %.o : %.cc
  57. $(_MSG) '[CXX ]' $(subst $(shell readlink -f $(SIM_ROOT))/,,$(shell readlink -f $@))
  58. $(_CMD) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
  59. %.o : %.c
  60. $(_MSG) '[CC ]' $(subst $(shell readlink -f $(SIM_ROOT))/,,$(shell readlink -f $@))
  61. $(_CMD) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@