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