Makefile.perf 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. include ../scripts/Makefile.include
  2. # The default target of this Makefile is...
  3. all:
  4. include ../scripts/utilities.mak
  5. # Define V to have a more verbose compile.
  6. #
  7. # Define VF to have a more verbose feature check output.
  8. #
  9. # Define O to save output files in a separate directory.
  10. #
  11. # Define ARCH as name of target architecture if you want cross-builds.
  12. #
  13. # Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
  14. #
  15. # Define NO_LIBPERL to disable perl script extension.
  16. #
  17. # Define NO_LIBPYTHON to disable python script extension.
  18. #
  19. # Define PYTHON to point to the python binary if the default
  20. # `python' is not correct; for example: PYTHON=python2
  21. #
  22. # Define PYTHON_CONFIG to point to the python-config binary if
  23. # the default `$(PYTHON)-config' is not correct.
  24. #
  25. # Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
  26. #
  27. # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
  28. #
  29. # Define LDFLAGS=-static to build a static binary.
  30. #
  31. # Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
  32. #
  33. # Define NO_DWARF if you do not want debug-info analysis feature at all.
  34. #
  35. # Define WERROR=0 to disable treating any warnings as errors.
  36. #
  37. # Define NO_NEWT if you do not want TUI support. (deprecated)
  38. #
  39. # Define NO_SLANG if you do not want TUI support.
  40. #
  41. # Define NO_GTK2 if you do not want GTK+ GUI support.
  42. #
  43. # Define NO_DEMANGLE if you do not want C++ symbol demangling.
  44. #
  45. # Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
  46. #
  47. # Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
  48. # backtrace post unwind.
  49. #
  50. # Define NO_BACKTRACE if you do not want stack backtrace debug feature
  51. #
  52. # Define NO_LIBNUMA if you do not want numa perf benchmark
  53. #
  54. # Define NO_LIBAUDIT if you do not want libaudit support
  55. #
  56. # Define NO_LIBBIONIC if you do not want bionic support
  57. #
  58. # Define NO_LIBCRYPTO if you do not want libcrypto (openssl) support
  59. # used for generating build-ids for ELFs generated by jitdump.
  60. #
  61. # Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
  62. # for dwarf backtrace post unwind.
  63. #
  64. # Define NO_PERF_READ_VDSO32 if you do not want to build perf-read-vdso32
  65. # for reading the 32-bit compatibility VDSO in 64-bit mode
  66. #
  67. # Define NO_PERF_READ_VDSOX32 if you do not want to build perf-read-vdsox32
  68. # for reading the x32 mode 32-bit compatibility VDSO in 64-bit mode
  69. #
  70. # Define NO_ZLIB if you do not want to support compressed kernel modules
  71. #
  72. # Define LIBBABELTRACE if you DO want libbabeltrace support
  73. # for CTF data format.
  74. #
  75. # Define NO_LZMA if you do not want to support compressed (xz) kernel modules
  76. #
  77. # Define NO_AUXTRACE if you do not want AUX area tracing support
  78. #
  79. # Define NO_LIBBPF if you do not want BPF support
  80. #
  81. # Define FEATURES_DUMP to provide features detection dump file
  82. # and bypass the feature detection
  83. # As per kernel Makefile, avoid funny character set dependencies
  84. unexport LC_ALL
  85. LC_COLLATE=C
  86. LC_NUMERIC=C
  87. export LC_COLLATE LC_NUMERIC
  88. ifeq ($(srctree),)
  89. srctree := $(patsubst %/,%,$(dir $(shell pwd)))
  90. srctree := $(patsubst %/,%,$(dir $(srctree)))
  91. #$(info Determined 'srctree' to be $(srctree))
  92. endif
  93. ifneq ($(objtree),)
  94. #$(info Determined 'objtree' to be $(objtree))
  95. endif
  96. ifneq ($(OUTPUT),)
  97. #$(info Determined 'OUTPUT' to be $(OUTPUT))
  98. # Adding $(OUTPUT) as a directory to look for source files,
  99. # because use generated output files as sources dependency
  100. # for flex/bison parsers.
  101. VPATH += $(OUTPUT)
  102. export VPATH
  103. endif
  104. ifeq ($(V),1)
  105. Q =
  106. else
  107. Q = @
  108. endif
  109. # Do not use make's built-in rules
  110. # (this improves performance and avoids hard-to-debug behaviour);
  111. MAKEFLAGS += -r
  112. $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
  113. $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
  114. $(Q)touch $(OUTPUT)PERF-VERSION-FILE
  115. # Makefiles suck: This macro sets a default value of $(2) for the
  116. # variable named by $(1), unless the variable has been set by
  117. # environment or command line. This is necessary for CC and AR
  118. # because make sets default values, so the simpler ?= approach
  119. # won't work as expected.
  120. define allow-override
  121. $(if $(or $(findstring environment,$(origin $(1))),\
  122. $(findstring command line,$(origin $(1)))),,\
  123. $(eval $(1) = $(2)))
  124. endef
  125. # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
  126. $(call allow-override,CC,$(CROSS_COMPILE)gcc)
  127. $(call allow-override,AR,$(CROSS_COMPILE)ar)
  128. $(call allow-override,LD,$(CROSS_COMPILE)ld)
  129. LD += $(EXTRA_LDFLAGS)
  130. PKG_CONFIG = $(CROSS_COMPILE)pkg-config
  131. RM = rm -f
  132. LN = ln -f
  133. MKDIR = mkdir
  134. FIND = find
  135. INSTALL = install
  136. FLEX = flex
  137. BISON = bison
  138. STRIP = strip
  139. AWK = awk
  140. LIB_DIR = $(srctree)/tools/lib/api/
  141. TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
  142. BPF_DIR = $(srctree)/tools/lib/bpf/
  143. SUBCMD_DIR = $(srctree)/tools/lib/subcmd/
  144. # include config/Makefile by default and rule out
  145. # non-config cases
  146. config := 1
  147. NON_CONFIG_TARGETS := clean TAGS tags cscope help
  148. ifdef MAKECMDGOALS
  149. ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
  150. config := 0
  151. endif
  152. endif
  153. # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
  154. # Without this setting the output feature dump file misses some features, for
  155. # example, liberty. Select all checkers so we won't get an incomplete feature
  156. # dump file.
  157. ifeq ($(config),1)
  158. ifdef MAKECMDGOALS
  159. ifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump)
  160. FEATURE_TESTS := all
  161. endif
  162. endif
  163. include config/Makefile
  164. endif
  165. ifeq ($(config),0)
  166. include $(srctree)/tools/scripts/Makefile.arch
  167. -include arch/$(ARCH)/Makefile
  168. endif
  169. # The FEATURE_DUMP_EXPORT holds location of the actual
  170. # FEATURE_DUMP file to be used to bypass feature detection
  171. # (for bpf or any other subproject)
  172. ifeq ($(FEATURES_DUMP),)
  173. FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
  174. else
  175. FEATURE_DUMP_EXPORT := $(FEATURES_DUMP)
  176. endif
  177. export prefix bindir sharedir sysconfdir DESTDIR
  178. # sparse is architecture-neutral, which means that we need to tell it
  179. # explicitly what architecture to check for. Fix this up for yours..
  180. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
  181. # Guard against environment variables
  182. PYRF_OBJS =
  183. SCRIPT_SH =
  184. SCRIPT_SH += perf-archive.sh
  185. SCRIPT_SH += perf-with-kcore.sh
  186. grep-libs = $(filter -l%,$(1))
  187. strip-libs = $(filter-out -l%,$(1))
  188. ifneq ($(OUTPUT),)
  189. TE_PATH=$(OUTPUT)
  190. BPF_PATH=$(OUTPUT)
  191. SUBCMD_PATH=$(OUTPUT)
  192. ifneq ($(subdir),)
  193. API_PATH=$(OUTPUT)/../lib/api/
  194. else
  195. API_PATH=$(OUTPUT)
  196. endif
  197. else
  198. TE_PATH=$(TRACE_EVENT_DIR)
  199. API_PATH=$(LIB_DIR)
  200. BPF_PATH=$(BPF_DIR)
  201. SUBCMD_PATH=$(SUBCMD_DIR)
  202. endif
  203. LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
  204. export LIBTRACEEVENT
  205. LIBTRACEEVENT_DYNAMIC_LIST = $(TE_PATH)libtraceevent-dynamic-list
  206. LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
  207. LIBAPI = $(API_PATH)libapi.a
  208. export LIBAPI
  209. LIBBPF = $(BPF_PATH)libbpf.a
  210. LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
  211. # python extension build directories
  212. PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
  213. PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
  214. PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
  215. export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
  216. python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
  217. PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
  218. PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
  219. $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
  220. $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
  221. CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
  222. $(PYTHON_WORD) util/setup.py \
  223. --quiet build_ext; \
  224. mkdir -p $(OUTPUT)python && \
  225. cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
  226. #
  227. # No Perl scripts right now:
  228. #
  229. SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
  230. PROGRAMS += $(OUTPUT)perf
  231. ifndef NO_PERF_READ_VDSO32
  232. PROGRAMS += $(OUTPUT)perf-read-vdso32
  233. endif
  234. ifndef NO_PERF_READ_VDSOX32
  235. PROGRAMS += $(OUTPUT)perf-read-vdsox32
  236. endif
  237. # what 'all' will build and 'install' will install, in perfexecdir
  238. ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
  239. # what 'all' will build but not install in perfexecdir
  240. OTHER_PROGRAMS = $(OUTPUT)perf
  241. # Set paths to tools early so that they can be used for version tests.
  242. ifndef SHELL_PATH
  243. SHELL_PATH = /bin/sh
  244. endif
  245. ifndef PERL_PATH
  246. PERL_PATH = /usr/bin/perl
  247. endif
  248. export PERL_PATH
  249. LIB_FILE=$(OUTPUT)libperf.a
  250. PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD)
  251. ifndef NO_LIBBPF
  252. PERFLIBS += $(LIBBPF)
  253. endif
  254. # We choose to avoid "if .. else if .. else .. endif endif"
  255. # because maintaining the nesting to match is a pain. If
  256. # we had "elif" things would have been much nicer...
  257. ifneq ($(OUTPUT),)
  258. CFLAGS += -I$(OUTPUT)
  259. endif
  260. ifndef NO_GTK2
  261. ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
  262. GTK_IN := $(OUTPUT)gtk-in.o
  263. install-gtk: $(OUTPUT)libperf-gtk.so
  264. $(call QUIET_INSTALL, 'GTK UI') \
  265. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
  266. $(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
  267. endif
  268. ifdef ASCIIDOC8
  269. export ASCIIDOC8
  270. endif
  271. LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
  272. export INSTALL SHELL_PATH
  273. ### Build rules
  274. SHELL = $(SHELL_PATH)
  275. all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
  276. please_set_SHELL_PATH_to_a_more_modern_shell:
  277. $(Q)$$(:)
  278. shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
  279. strip: $(PROGRAMS) $(OUTPUT)perf
  280. $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
  281. PERF_IN := $(OUTPUT)perf-in.o
  282. export srctree OUTPUT RM CC LD AR CFLAGS V BISON FLEX AWK
  283. include $(srctree)/tools/build/Makefile.include
  284. $(PERF_IN): prepare FORCE
  285. $(Q)$(MAKE) $(build)=perf
  286. $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
  287. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
  288. $(PERF_IN) $(LIBS) -o $@
  289. $(GTK_IN): fixdep FORCE
  290. $(Q)$(MAKE) $(build)=gtk
  291. $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
  292. $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
  293. $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
  294. $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
  295. $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
  296. $(SCRIPTS) : % : %.sh
  297. $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
  298. # These can record PERF_VERSION
  299. perf.spec $(SCRIPTS) \
  300. : $(OUTPUT)PERF-VERSION-FILE
  301. .SUFFIXES:
  302. #
  303. # If a target does not match any of the later rules then prefix it by $(OUTPUT)
  304. # This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
  305. #
  306. ifneq ($(OUTPUT),)
  307. %.o: $(OUTPUT)%.o
  308. @echo " # Redirected target $@ => $(OUTPUT)$@"
  309. util/%.o: $(OUTPUT)util/%.o
  310. @echo " # Redirected target $@ => $(OUTPUT)$@"
  311. bench/%.o: $(OUTPUT)bench/%.o
  312. @echo " # Redirected target $@ => $(OUTPUT)$@"
  313. tests/%.o: $(OUTPUT)tests/%.o
  314. @echo " # Redirected target $@ => $(OUTPUT)$@"
  315. endif
  316. # These two need to be here so that when O= is not used they take precedence
  317. # over the general rule for .o
  318. # get relative building directory (to $(OUTPUT))
  319. # and '.' if it's $(OUTPUT) itself
  320. __build-dir = $(subst $(OUTPUT),,$(dir $@))
  321. build-dir = $(if $(__build-dir),$(__build-dir),.)
  322. prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h fixdep archheaders
  323. $(OUTPUT)%.o: %.c prepare FORCE
  324. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  325. $(OUTPUT)%.i: %.c prepare FORCE
  326. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  327. $(OUTPUT)%.s: %.c prepare FORCE
  328. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  329. $(OUTPUT)%-bison.o: %.c prepare FORCE
  330. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  331. $(OUTPUT)%-flex.o: %.c prepare FORCE
  332. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  333. $(OUTPUT)%.o: %.S prepare FORCE
  334. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  335. $(OUTPUT)%.i: %.S prepare FORCE
  336. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  337. $(OUTPUT)perf-%: %.o $(PERFLIBS)
  338. $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
  339. ifndef NO_PERF_READ_VDSO32
  340. $(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-vdso-map.c
  341. $(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
  342. endif
  343. ifndef NO_PERF_READ_VDSOX32
  344. $(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-vdso-map.c
  345. $(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
  346. endif
  347. $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
  348. LIBPERF_IN := $(OUTPUT)libperf-in.o
  349. $(LIBPERF_IN): prepare fixdep FORCE
  350. $(Q)$(MAKE) $(build)=libperf
  351. $(LIB_FILE): $(LIBPERF_IN)
  352. $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN) $(LIB_OBJS)
  353. LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ)
  354. $(LIBTRACEEVENT): fixdep FORCE
  355. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a
  356. libtraceevent_plugins: fixdep FORCE
  357. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins
  358. $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins
  359. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent-dynamic-list
  360. $(LIBTRACEEVENT)-clean:
  361. $(call QUIET_CLEAN, libtraceevent)
  362. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean >/dev/null
  363. install-traceevent-plugins: libtraceevent_plugins
  364. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins
  365. $(LIBAPI): fixdep FORCE
  366. $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
  367. $(LIBAPI)-clean:
  368. $(call QUIET_CLEAN, libapi)
  369. $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
  370. $(LIBBPF): fixdep FORCE
  371. $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
  372. $(LIBBPF)-clean:
  373. $(call QUIET_CLEAN, libbpf)
  374. $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
  375. $(LIBSUBCMD): fixdep FORCE
  376. $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
  377. $(LIBSUBCMD)-clean:
  378. $(call QUIET_CLEAN, libsubcmd)
  379. $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) clean
  380. help:
  381. @echo 'Perf make targets:'
  382. @echo ' doc - make *all* documentation (see below)'
  383. @echo ' man - make manpage documentation (access with man <foo>)'
  384. @echo ' html - make html documentation'
  385. @echo ' info - make GNU info documentation (access with info <foo>)'
  386. @echo ' pdf - make pdf documentation'
  387. @echo ' TAGS - use etags to make tag information for source browsing'
  388. @echo ' tags - use ctags to make tag information for source browsing'
  389. @echo ' cscope - use cscope to make interactive browsing database'
  390. @echo ''
  391. @echo 'Perf install targets:'
  392. @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
  393. @echo ' HINT: use "prefix" or "DESTDIR" to install to a particular'
  394. @echo ' path like "make prefix=/usr/local install install-doc"'
  395. @echo ' install - install compiled binaries'
  396. @echo ' install-doc - install *all* documentation'
  397. @echo ' install-man - install manpage documentation'
  398. @echo ' install-html - install html documentation'
  399. @echo ' install-info - install GNU info documentation'
  400. @echo ' install-pdf - install pdf documentation'
  401. @echo ''
  402. @echo ' quick-install-doc - alias for quick-install-man'
  403. @echo ' quick-install-man - install the documentation quickly'
  404. @echo ' quick-install-html - install the html documentation quickly'
  405. @echo ''
  406. @echo 'Perf maintainer targets:'
  407. @echo ' clean - clean all binary objects and build output'
  408. DOC_TARGETS := doc man html info pdf
  409. INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
  410. INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
  411. # 'make doc' should call 'make -C Documentation all'
  412. $(DOC_TARGETS):
  413. $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all)
  414. TAG_FOLDERS= . ../lib ../include
  415. TAG_FILES= ../../include/uapi/linux/perf_event.h
  416. TAGS:
  417. $(QUIET_GEN)$(RM) TAGS; \
  418. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs etags -a $(TAG_FILES)
  419. tags:
  420. $(QUIET_GEN)$(RM) tags; \
  421. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs ctags -a $(TAG_FILES)
  422. cscope:
  423. $(QUIET_GEN)$(RM) cscope*; \
  424. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs cscope -b $(TAG_FILES)
  425. ### Testing rules
  426. # GNU make supports exporting all variables by "export" without parameters.
  427. # However, the environment gets quite big, and some programs have problems
  428. # with that.
  429. check: $(OUTPUT)common-cmds.h
  430. if sparse; \
  431. then \
  432. for i in *.c */*.c; \
  433. do \
  434. sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
  435. done; \
  436. else \
  437. exit 1; \
  438. fi
  439. ### Installation rules
  440. install-gtk:
  441. install-tools: all install-gtk
  442. $(call QUIET_INSTALL, binaries) \
  443. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
  444. $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
  445. $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'
  446. ifndef NO_PERF_READ_VDSO32
  447. $(call QUIET_INSTALL, perf-read-vdso32) \
  448. $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
  449. endif
  450. ifndef NO_PERF_READ_VDSOX32
  451. $(call QUIET_INSTALL, perf-read-vdsox32) \
  452. $(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
  453. endif
  454. $(call QUIET_INSTALL, libexec) \
  455. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  456. $(call QUIET_INSTALL, perf-archive) \
  457. $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  458. $(call QUIET_INSTALL, perf-with-kcore) \
  459. $(INSTALL) $(OUTPUT)perf-with-kcore -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  460. ifndef NO_LIBAUDIT
  461. $(call QUIET_INSTALL, strace/groups) \
  462. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'; \
  463. $(INSTALL) trace/strace/groups/* -t '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'
  464. endif
  465. ifndef NO_LIBPERL
  466. $(call QUIET_INSTALL, perl-scripts) \
  467. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
  468. $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
  469. $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
  470. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
  471. $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  472. endif
  473. ifndef NO_LIBPYTHON
  474. $(call QUIET_INSTALL, python-scripts) \
  475. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
  476. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
  477. $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
  478. $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
  479. $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  480. endif
  481. $(call QUIET_INSTALL, perf_completion-script) \
  482. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
  483. $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
  484. $(call QUIET_INSTALL, perf-tip) \
  485. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
  486. $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
  487. install-tests: all install-gtk
  488. $(call QUIET_INSTALL, tests) \
  489. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
  490. $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
  491. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
  492. $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
  493. install-bin: install-tools install-tests
  494. install: install-bin try-install-man install-traceevent-plugins
  495. install-python_ext:
  496. $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
  497. # 'make install-doc' should call 'make -C Documentation install'
  498. $(INSTALL_DOC_TARGETS):
  499. $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=)
  500. ### Cleaning rules
  501. #
  502. # This is here, not in config/Makefile, because config/Makefile does
  503. # not get included for the clean target:
  504. #
  505. config-clean:
  506. $(call QUIET_CLEAN, config)
  507. $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null
  508. clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean
  509. $(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
  510. $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
  511. $(Q)$(RM) $(OUTPUT).config-detected
  512. $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32
  513. $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
  514. $(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \
  515. $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c
  516. $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
  517. $(python-clean)
  518. #
  519. # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
  520. # file if defined, with no further action.
  521. feature-dump:
  522. ifdef FEATURE_DUMP_COPY
  523. @cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY)
  524. @echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)"
  525. else
  526. @echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP"
  527. endif
  528. #
  529. # Trick: if ../../.git does not exist - we are building out of tree for example,
  530. # then force version regeneration:
  531. #
  532. ifeq ($(wildcard ../../.git/HEAD),)
  533. GIT-HEAD-PHONY = ../../.git/HEAD
  534. else
  535. GIT-HEAD-PHONY =
  536. endif
  537. FORCE:
  538. .PHONY: all install clean config-clean strip install-gtk
  539. .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
  540. .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare
  541. .PHONY: libtraceevent_plugins archheaders