make 3.6 KB

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