make 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. PERF := .
  2. MK := Makefile
  3. has = $(shell which $1 2>/dev/null)
  4. # standard single make variable specified
  5. make_clean_all := clean all
  6. make_python_perf_so := python/perf.so
  7. make_debug := DEBUG=1
  8. make_no_libperl := NO_LIBPERL=1
  9. make_no_libpython := NO_LIBPYTHON=1
  10. make_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1
  11. make_no_newt := NO_NEWT=1
  12. make_no_slang := NO_SLANG=1
  13. make_no_gtk2 := NO_GTK2=1
  14. make_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
  15. make_no_demangle := NO_DEMANGLE=1
  16. make_no_libelf := NO_LIBELF=1
  17. make_no_libunwind := NO_LIBUNWIND=1
  18. make_no_backtrace := NO_BACKTRACE=1
  19. make_no_libnuma := NO_LIBNUMA=1
  20. make_no_libaudit := NO_LIBAUDIT=1
  21. make_no_libbionic := NO_LIBBIONIC=1
  22. make_tags := tags
  23. make_cscope := cscope
  24. make_help := help
  25. make_doc := doc
  26. make_perf_o := perf.o
  27. make_util_map_o := util/map.o
  28. # all the NO_* variable combined
  29. make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
  30. make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
  31. make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
  32. # $(run) contains all available tests
  33. run := make_pure
  34. run += make_clean_all
  35. run += make_python_perf_so
  36. run += make_debug
  37. run += make_no_libperl
  38. run += make_no_libpython
  39. run += make_no_scripts
  40. run += make_no_newt
  41. run += make_no_slang
  42. run += make_no_gtk2
  43. run += make_no_ui
  44. run += make_no_demangle
  45. run += make_no_libelf
  46. run += make_no_libunwind
  47. run += make_no_backtrace
  48. run += make_no_libnuma
  49. run += make_no_libaudit
  50. run += make_no_libbionic
  51. run += make_help
  52. run += make_doc
  53. run += make_perf_o
  54. run += make_util_map_o
  55. run += make_minimal
  56. ifneq ($(call has,ctags),)
  57. run += make_tags
  58. endif
  59. ifneq ($(call has,cscope),)
  60. run += make_cscope
  61. endif
  62. # $(run_O) contains same portion of $(run) tests with '_O' attached
  63. # to distinguish O=... tests
  64. run_O := $(addsuffix _O,$(run))
  65. # disable some tests for O=...
  66. run_O := $(filter-out make_python_perf_so_O,$(run_O))
  67. # define test for each compile as 'test_NAME' variable
  68. # with the test itself as a value
  69. test_make_tags = test -f tags
  70. test_make_cscope = test -f cscope.out
  71. test_make_tags_O := $(test_make_tags)
  72. test_make_cscope_O := $(test_make_cscope)
  73. test_ok := true
  74. test_make_help := $(test_ok)
  75. test_make_doc := $(test_ok)
  76. test_make_help_O := $(test_ok)
  77. test_make_doc_O := $(test_ok)
  78. test_make_python_perf_so := test -f $(PERF)/python/perf.so
  79. test_make_perf_o := test -f $(PERF)/perf.o
  80. test_make_util_map_o := test -f $(PERF)/util/map.o
  81. # Kbuild tests only
  82. #test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
  83. #test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o
  84. #test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o
  85. test_make_perf_o_O := true
  86. test_make_util_map_o_O := true
  87. test_default = test -x $(PERF)/perf
  88. test = $(if $(test_$1),$(test_$1),$(test_default))
  89. test_default_O = test -x $$TMP_O/perf
  90. test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
  91. all:
  92. ifdef DEBUG
  93. d := $(info run $(run))
  94. d := $(info run_O $(run_O))
  95. endif
  96. MAKEFLAGS := --no-print-directory
  97. clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
  98. $(run):
  99. $(call clean)
  100. @cmd="cd $(PERF) && make -f $(MK) $($@)"; \
  101. echo "- $@: $$cmd" && echo $$cmd > $@ && \
  102. ( eval $$cmd ) >> $@ 2>&1; \
  103. echo " test: $(call test,$@)"; \
  104. $(call test,$@) && \
  105. rm -f $@
  106. $(run_O):
  107. $(call clean)
  108. @TMP_O=$$(mktemp -d); \
  109. cmd="cd $(PERF) && make -f $(MK) $($(patsubst %_O,%,$@)) O=$$TMP_O"; \
  110. echo "- $@: $$cmd" && echo $$cmd > $@ && \
  111. ( eval $$cmd ) >> $@ 2>&1 && \
  112. echo " test: $(call test_O,$@)"; \
  113. $(call test_O,$@) && \
  114. rm -f $@ && \
  115. rm -rf $$TMP_O
  116. all: $(run) $(run_O)
  117. @echo OK
  118. out: $(run_O)
  119. @echo OK
  120. .PHONY: all $(run) $(run_O) clean