make 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. PERF := .
  2. MK := Makefile
  3. include config/Makefile.arch
  4. # FIXME looks like x86 is the only arch running tests ;-)
  5. # we need some IS_(32/64) flag to make this generic
  6. ifeq ($(IS_X86_64),1)
  7. lib = lib64
  8. else
  9. lib = lib
  10. endif
  11. has = $(shell which $1 2>/dev/null)
  12. # standard single make variable specified
  13. make_clean_all := clean all
  14. make_python_perf_so := python/perf.so
  15. make_debug := DEBUG=1
  16. make_no_libperl := NO_LIBPERL=1
  17. make_no_libpython := NO_LIBPYTHON=1
  18. make_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1
  19. make_no_newt := NO_NEWT=1
  20. make_no_slang := NO_SLANG=1
  21. make_no_gtk2 := NO_GTK2=1
  22. make_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
  23. make_no_demangle := NO_DEMANGLE=1
  24. make_no_libelf := NO_LIBELF=1
  25. make_no_libunwind := NO_LIBUNWIND=1
  26. make_no_backtrace := NO_BACKTRACE=1
  27. make_no_libnuma := NO_LIBNUMA=1
  28. make_no_libaudit := NO_LIBAUDIT=1
  29. make_no_libbionic := NO_LIBBIONIC=1
  30. make_tags := tags
  31. make_cscope := cscope
  32. make_help := help
  33. make_doc := doc
  34. make_perf_o := perf.o
  35. make_util_map_o := util/map.o
  36. make_install := install
  37. make_install_bin := install-bin
  38. make_install_doc := install-doc
  39. make_install_man := install-man
  40. make_install_html := install-html
  41. make_install_info := install-info
  42. make_install_pdf := install-pdf
  43. # all the NO_* variable combined
  44. make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
  45. make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
  46. make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
  47. # $(run) contains all available tests
  48. run := make_pure
  49. run += make_clean_all
  50. run += make_python_perf_so
  51. run += make_debug
  52. run += make_no_libperl
  53. run += make_no_libpython
  54. run += make_no_scripts
  55. run += make_no_newt
  56. run += make_no_slang
  57. run += make_no_gtk2
  58. run += make_no_ui
  59. run += make_no_demangle
  60. run += make_no_libelf
  61. run += make_no_libunwind
  62. run += make_no_backtrace
  63. run += make_no_libnuma
  64. run += make_no_libaudit
  65. run += make_no_libbionic
  66. run += make_help
  67. run += make_doc
  68. run += make_perf_o
  69. run += make_util_map_o
  70. run += make_install
  71. run += make_install_bin
  72. # FIXME 'install-*' commented out till they're fixed
  73. # run += make_install_doc
  74. # run += make_install_man
  75. # run += make_install_html
  76. # run += make_install_info
  77. # run += make_install_pdf
  78. run += make_minimal
  79. ifneq ($(call has,ctags),)
  80. run += make_tags
  81. endif
  82. ifneq ($(call has,cscope),)
  83. run += make_cscope
  84. endif
  85. # $(run_O) contains same portion of $(run) tests with '_O' attached
  86. # to distinguish O=... tests
  87. run_O := $(addsuffix _O,$(run))
  88. # disable some tests for O=...
  89. run_O := $(filter-out make_python_perf_so_O,$(run_O))
  90. # define test for each compile as 'test_NAME' variable
  91. # with the test itself as a value
  92. test_make_tags = test -f tags
  93. test_make_cscope = test -f cscope.out
  94. test_make_tags_O := $(test_make_tags)
  95. test_make_cscope_O := $(test_make_cscope)
  96. test_ok := true
  97. test_make_help := $(test_ok)
  98. test_make_doc := $(test_ok)
  99. test_make_help_O := $(test_ok)
  100. test_make_doc_O := $(test_ok)
  101. test_make_python_perf_so := test -f $(PERF)/python/perf.so
  102. test_make_perf_o := test -f $(PERF)/perf.o
  103. test_make_util_map_o := test -f $(PERF)/util/map.o
  104. define test_dest_files
  105. for file in $(1); do \
  106. if [ ! -x $$TMP_DEST/$$file ]; then \
  107. echo " failed to find: $$file"; \
  108. fi \
  109. done
  110. endef
  111. installed_files_bin := bin/perf
  112. installed_files_bin += etc/bash_completion.d/perf
  113. installed_files_bin += libexec/perf-core/perf-archive
  114. installed_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so
  115. installed_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so
  116. installed_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so
  117. installed_files_plugins += $(lib)/traceevent/plugins/plugin_function.so
  118. installed_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so
  119. installed_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so
  120. installed_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so
  121. installed_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so
  122. installed_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so
  123. installed_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so
  124. installed_files_all := $(installed_files_bin)
  125. installed_files_all += $(installed_files_plugins)
  126. test_make_install := $(call test_dest_files,$(installed_files_all))
  127. test_make_install_O := $(call test_dest_files,$(installed_files_all))
  128. test_make_install_bin := $(call test_dest_files,$(installed_files_bin))
  129. test_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))
  130. # FIXME nothing gets installed
  131. test_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1
  132. test_make_install_man_O := $(test_make_install_man)
  133. # FIXME nothing gets installed
  134. test_make_install_doc := $(test_ok)
  135. test_make_install_doc_O := $(test_ok)
  136. # FIXME nothing gets installed
  137. test_make_install_html := $(test_ok)
  138. test_make_install_html_O := $(test_ok)
  139. # FIXME nothing gets installed
  140. test_make_install_info := $(test_ok)
  141. test_make_install_info_O := $(test_ok)
  142. # FIXME nothing gets installed
  143. test_make_install_pdf := $(test_ok)
  144. test_make_install_pdf_O := $(test_ok)
  145. # Kbuild tests only
  146. #test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
  147. #test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o
  148. #test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o
  149. test_make_perf_o_O := true
  150. test_make_util_map_o_O := true
  151. test_default = test -x $(PERF)/perf
  152. test = $(if $(test_$1),$(test_$1),$(test_default))
  153. test_default_O = test -x $$TMP_O/perf
  154. test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
  155. all:
  156. ifdef DEBUG
  157. d := $(info run $(run))
  158. d := $(info run_O $(run_O))
  159. endif
  160. MAKEFLAGS := --no-print-directory
  161. clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
  162. $(run):
  163. $(call clean)
  164. @TMP_DEST=$$(mktemp -d); \
  165. cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
  166. echo "- $@: $$cmd" && echo $$cmd > $@ && \
  167. ( eval $$cmd ) >> $@ 2>&1; \
  168. echo " test: $(call test,$@)" >> $@ 2>&1; \
  169. $(call test,$@) && \
  170. rm -f $@ \
  171. rm -rf $$TMP_DEST
  172. $(run_O):
  173. $(call clean)
  174. @TMP_O=$$(mktemp -d); \
  175. TMP_DEST=$$(mktemp -d); \
  176. cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
  177. echo "- $@: $$cmd" && echo $$cmd > $@ && \
  178. ( eval $$cmd ) >> $@ 2>&1 && \
  179. echo " test: $(call test_O,$@)" >> $@ 2>&1; \
  180. $(call test_O,$@) && \
  181. rm -f $@ && \
  182. rm -rf $$TMP_O \
  183. rm -rf $$TMP_DEST
  184. tarpkg:
  185. @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
  186. echo "- $@: $$cmd" && echo $$cmd > $@ && \
  187. ( eval $$cmd ) >> $@ 2>&1
  188. all: $(run) $(run_O) tarpkg
  189. @echo OK
  190. out: $(run_O)
  191. @echo OK
  192. .PHONY: all $(run) $(run_O) tarpkg clean