Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. FILES= \
  2. test-all \
  3. test-backtrace \
  4. test-bionic \
  5. test-dwarf \
  6. test-fortify-source \
  7. test-glibc \
  8. test-gtk2 \
  9. test-gtk2-infobar \
  10. test-hello \
  11. test-libaudit \
  12. test-libbfd \
  13. test-liberty \
  14. test-liberty-z \
  15. test-cplus-demangle \
  16. test-libelf \
  17. test-libelf-getphdrnum \
  18. test-libelf-mmap \
  19. test-libnuma \
  20. test-libperl \
  21. test-libpython \
  22. test-libpython-version \
  23. test-libslang \
  24. test-libunwind \
  25. test-on-exit \
  26. test-stackprotector-all \
  27. test-stackprotector
  28. CC := $(CC) -MD
  29. all: $(FILES)
  30. BUILD = $(CC) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
  31. ###############################
  32. test-all:
  33. $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
  34. test-hello:
  35. $(BUILD)
  36. test-stackprotector-all:
  37. $(BUILD) -Werror -fstack-protector-all
  38. test-stackprotector:
  39. $(BUILD) -Werror -fstack-protector
  40. test-fortify-source:
  41. $(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2
  42. test-bionic:
  43. $(BUILD)
  44. test-libelf:
  45. $(BUILD) -lelf
  46. test-glibc:
  47. $(BUILD)
  48. test-dwarf:
  49. $(BUILD) -ldw
  50. test-libelf-mmap:
  51. $(BUILD) -lelf
  52. test-libelf-getphdrnum:
  53. $(BUILD) -lelf
  54. test-libnuma:
  55. $(BUILD) -lnuma
  56. test-libunwind:
  57. $(BUILD) -lunwind -lunwind-x86_64 -lelf
  58. test-libaudit:
  59. $(BUILD) -laudit
  60. test-libslang:
  61. $(BUILD) -I/usr/include/slang -lslang
  62. test-gtk2:
  63. $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
  64. test-gtk2-infobar:
  65. $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
  66. grep-libs = $(filter -l%,$(1))
  67. strip-libs = $(filter-out -l%,$(1))
  68. PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
  69. PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
  70. PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
  71. PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
  72. FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
  73. test-libperl:
  74. $(BUILD) $(FLAGS_PERL_EMBED)
  75. override PYTHON := python
  76. override PYTHON_CONFIG := python-config
  77. escape-for-shell-sq = $(subst ','\'',$(1))
  78. shell-sq = '$(escape-for-shell-sq)'
  79. PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG))
  80. PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
  81. PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
  82. PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
  83. PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
  84. FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
  85. test-libpython:
  86. $(BUILD) $(FLAGS_PYTHON_EMBED)
  87. test-libpython-version:
  88. $(BUILD) $(FLAGS_PYTHON_EMBED)
  89. test-libbfd:
  90. $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
  91. test-liberty:
  92. $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
  93. test-liberty-z:
  94. $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
  95. test-cplus-demangle:
  96. $(BUILD) -liberty
  97. test-on-exit:
  98. $(BUILD)
  99. test-backtrace:
  100. $(BUILD)
  101. -include *.d */*.d
  102. ###############################
  103. clean:
  104. rm -f $(FILES) *.d