Makefile 3.9 KB

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