Makefile.perf 19 KB

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