make 6.9 KB

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