make 8.3 KB

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