Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. FILES= \
  2. test-all.bin \
  3. test-backtrace.bin \
  4. test-bionic.bin \
  5. test-dwarf.bin \
  6. test-fortify-source.bin \
  7. test-sync-compare-and-swap.bin \
  8. test-glibc.bin \
  9. test-gtk2.bin \
  10. test-gtk2-infobar.bin \
  11. test-hello.bin \
  12. test-libaudit.bin \
  13. test-libbfd.bin \
  14. test-liberty.bin \
  15. test-liberty-z.bin \
  16. test-cplus-demangle.bin \
  17. test-libelf.bin \
  18. test-libelf-getphdrnum.bin \
  19. test-libelf-mmap.bin \
  20. test-libnuma.bin \
  21. test-libperl.bin \
  22. test-libpython.bin \
  23. test-libpython-version.bin \
  24. test-libslang.bin \
  25. test-libunwind.bin \
  26. test-libunwind-debug-frame.bin \
  27. test-pthread-attr-setaffinity-np.bin \
  28. test-stackprotector-all.bin \
  29. test-timerfd.bin \
  30. test-libdw-dwarf-unwind.bin \
  31. test-libbabeltrace.bin \
  32. test-compile-32.bin \
  33. test-compile-x32.bin \
  34. test-zlib.bin \
  35. test-lzma.bin \
  36. test-bpf.bin
  37. CC := $(CROSS_COMPILE)gcc -MD
  38. PKG_CONFIG := $(CROSS_COMPILE)pkg-config
  39. all: $(FILES)
  40. __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
  41. BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1
  42. ###############################
  43. test-all.bin:
  44. $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz -llzma
  45. test-hello.bin:
  46. $(BUILD)
  47. test-pthread-attr-setaffinity-np.bin:
  48. $(BUILD) -D_GNU_SOURCE -lpthread
  49. test-stackprotector-all.bin:
  50. $(BUILD) -fstack-protector-all
  51. test-fortify-source.bin:
  52. $(BUILD) -O2 -D_FORTIFY_SOURCE=2
  53. test-bionic.bin:
  54. $(BUILD)
  55. test-libelf.bin:
  56. $(BUILD) -lelf
  57. test-glibc.bin:
  58. $(BUILD)
  59. DWARFLIBS := -ldw
  60. ifeq ($(findstring -static,${LDFLAGS}),-static)
  61. DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
  62. endif
  63. test-dwarf.bin:
  64. $(BUILD) $(DWARFLIBS)
  65. test-libelf-mmap.bin:
  66. $(BUILD) -lelf
  67. test-libelf-getphdrnum.bin:
  68. $(BUILD) -lelf
  69. test-libnuma.bin:
  70. $(BUILD) -lnuma
  71. test-libunwind.bin:
  72. $(BUILD) -lelf
  73. test-libunwind-debug-frame.bin:
  74. $(BUILD) -lelf
  75. test-libaudit.bin:
  76. $(BUILD) -laudit
  77. test-libslang.bin:
  78. $(BUILD) -I/usr/include/slang -lslang
  79. test-gtk2.bin:
  80. $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
  81. test-gtk2-infobar.bin:
  82. $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
  83. grep-libs = $(filter -l%,$(1))
  84. strip-libs = $(filter-out -l%,$(1))
  85. PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
  86. PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
  87. PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
  88. PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
  89. FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
  90. test-libperl.bin:
  91. $(BUILD) $(FLAGS_PERL_EMBED)
  92. test-libpython.bin:
  93. $(BUILD)
  94. test-libpython-version.bin:
  95. $(BUILD)
  96. test-libbfd.bin:
  97. $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
  98. test-liberty.bin:
  99. $(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
  100. test-liberty-z.bin:
  101. $(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
  102. test-cplus-demangle.bin:
  103. $(BUILD) -liberty
  104. test-backtrace.bin:
  105. $(BUILD)
  106. test-timerfd.bin:
  107. $(BUILD)
  108. test-libdw-dwarf-unwind.bin:
  109. $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
  110. test-libbabeltrace.bin:
  111. $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
  112. test-sync-compare-and-swap.bin:
  113. $(BUILD)
  114. test-compile-32.bin:
  115. $(CC) -m32 -o $(OUTPUT)$@ test-compile.c
  116. test-compile-x32.bin:
  117. $(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
  118. test-zlib.bin:
  119. $(BUILD) -lz
  120. test-lzma.bin:
  121. $(BUILD) -llzma
  122. test-bpf.bin:
  123. $(BUILD)
  124. -include *.d
  125. ###############################
  126. clean:
  127. rm -f $(FILES) *.d $(FILES:.bin=.make.output)