make 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. make_install := install
  29. make_install_bin := install-bin
  30. make_install_doc := install-doc
  31. make_install_man := install-man
  32. make_install_html := install-html
  33. make_install_info := install-info
  34. make_install_pdf := install-pdf
  35. # all the NO_* variable combined
  36. make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
  37. make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
  38. make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
  39. # $(run) contains all available tests
  40. run := make_pure
  41. run += make_clean_all
  42. run += make_python_perf_so
  43. run += make_debug
  44. run += make_no_libperl
  45. run += make_no_libpython
  46. run += make_no_scripts
  47. run += make_no_newt
  48. run += make_no_slang
  49. run += make_no_gtk2
  50. run += make_no_ui
  51. run += make_no_demangle
  52. run += make_no_libelf
  53. run += make_no_libunwind
  54. run += make_no_backtrace
  55. run += make_no_libnuma
  56. run += make_no_libaudit
  57. run += make_no_libbionic
  58. run += make_help
  59. run += make_doc
  60. run += make_perf_o
  61. run += make_util_map_o
  62. run += make_install
  63. run += make_install_bin
  64. # FIXME 'install-*' commented out till they're fixed
  65. # run += make_install_doc
  66. # run += make_install_man
  67. # run += make_install_html
  68. # run += make_install_info
  69. # run += make_install_pdf
  70. run += make_minimal
  71. ifneq ($(call has,ctags),)
  72. run += make_tags
  73. endif
  74. ifneq ($(call has,cscope),)
  75. run += make_cscope
  76. endif
  77. # $(run_O) contains same portion of $(run) tests with '_O' attached
  78. # to distinguish O=... tests
  79. run_O := $(addsuffix _O,$(run))
  80. # disable some tests for O=...
  81. run_O := $(filter-out make_python_perf_so_O,$(run_O))
  82. # define test for each compile as 'test_NAME' variable
  83. # with the test itself as a value
  84. test_make_tags = test -f tags
  85. test_make_cscope = test -f cscope.out
  86. test_make_tags_O := $(test_make_tags)
  87. test_make_cscope_O := $(test_make_cscope)
  88. test_ok := true
  89. test_make_help := $(test_ok)
  90. test_make_doc := $(test_ok)
  91. test_make_help_O := $(test_ok)
  92. test_make_doc_O := $(test_ok)
  93. test_make_python_perf_so := test -f $(PERF)/python/perf.so
  94. test_make_perf_o := test -f $(PERF)/perf.o
  95. test_make_util_map_o := test -f $(PERF)/util/map.o
  96. test_make_install := test -x $$TMP_DEST/bin/perf
  97. test_make_install_O := $(test_make_install)
  98. test_make_install_bin := $(test_make_install)
  99. test_make_install_bin_O := $(test_make_install)
  100. # FIXME nothing gets installed
  101. test_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1
  102. test_make_install_man_O := $(test_make_install_man)
  103. # FIXME nothing gets installed
  104. test_make_install_doc := $(test_ok)
  105. test_make_install_doc_O := $(test_ok)
  106. # FIXME nothing gets installed
  107. test_make_install_html := $(test_ok)
  108. test_make_install_html_O := $(test_ok)
  109. # FIXME nothing gets installed
  110. test_make_install_info := $(test_ok)
  111. test_make_install_info_O := $(test_ok)
  112. # FIXME nothing gets installed
  113. test_make_install_pdf := $(test_ok)
  114. test_make_install_pdf_O := $(test_ok)
  115. # Kbuild tests only
  116. #test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
  117. #test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o
  118. #test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o
  119. test_make_perf_o_O := true
  120. test_make_util_map_o_O := true
  121. test_default = test -x $(PERF)/perf
  122. test = $(if $(test_$1),$(test_$1),$(test_default))
  123. test_default_O = test -x $$TMP_O/perf
  124. test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
  125. all:
  126. ifdef DEBUG
  127. d := $(info run $(run))
  128. d := $(info run_O $(run_O))
  129. endif
  130. MAKEFLAGS := --no-print-directory
  131. clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
  132. $(run):
  133. $(call clean)
  134. @TMP_DEST=$$(mktemp -d); \
  135. cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
  136. echo "- $@: $$cmd" && echo $$cmd > $@ && \
  137. ( eval $$cmd ) >> $@ 2>&1; \
  138. echo " test: $(call test,$@)"; \
  139. $(call test,$@) && \
  140. rm -f $@ \
  141. rm -rf $$TMP_DEST
  142. $(run_O):
  143. $(call clean)
  144. @TMP_O=$$(mktemp -d); \
  145. TMP_DEST=$$(mktemp -d); \
  146. cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
  147. echo "- $@: $$cmd" && echo $$cmd > $@ && \
  148. ( eval $$cmd ) >> $@ 2>&1 && \
  149. echo " test: $(call test_O,$@)"; \
  150. $(call test_O,$@) && \
  151. rm -f $@ && \
  152. rm -rf $$TMP_O \
  153. rm -rf $$TMP_DEST
  154. all: $(run) $(run_O)
  155. @echo OK
  156. out: $(run_O)
  157. @echo OK
  158. .PHONY: all $(run) $(run_O) clean