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