Makefile 3.2 KB

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