Makefile.perf 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. include ../scripts/Makefile.include
  3. include ../scripts/Makefile.arch
  4. # The default target of this Makefile is...
  5. all:
  6. include ../scripts/utilities.mak
  7. # Define V to have a more verbose compile.
  8. #
  9. # Define VF to have a more verbose feature check output.
  10. #
  11. # Define O to save output files in a separate directory.
  12. #
  13. # Define ARCH as name of target architecture if you want cross-builds.
  14. #
  15. # Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
  16. #
  17. # Define NO_LIBPERL to disable perl script extension.
  18. #
  19. # Define NO_LIBPYTHON to disable python script extension.
  20. #
  21. # Define PYTHON to point to the python binary if the default
  22. # `python' is not correct; for example: PYTHON=python2
  23. #
  24. # Define PYTHON_CONFIG to point to the python-config binary if
  25. # the default `$(PYTHON)-config' is not correct.
  26. #
  27. # Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
  28. #
  29. # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
  30. #
  31. # Define LDFLAGS=-static to build a static binary.
  32. #
  33. # Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
  34. #
  35. # Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
  36. # EXTLIBS.
  37. #
  38. # Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.
  39. #
  40. # Define NO_DWARF if you do not want debug-info analysis feature at all.
  41. #
  42. # Define WERROR=0 to disable treating any warnings as errors.
  43. #
  44. # Define NO_NEWT if you do not want TUI support. (deprecated)
  45. #
  46. # Define NO_SLANG if you do not want TUI support.
  47. #
  48. # Define GTK2 if you want GTK+ GUI support.
  49. #
  50. # Define NO_DEMANGLE if you do not want C++ symbol demangling.
  51. #
  52. # Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
  53. #
  54. # Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
  55. # backtrace post unwind.
  56. #
  57. # Define NO_BACKTRACE if you do not want stack backtrace debug feature
  58. #
  59. # Define NO_LIBNUMA if you do not want numa perf benchmark
  60. #
  61. # Define NO_LIBAUDIT if you do not want libaudit support
  62. #
  63. # Define NO_LIBBIONIC if you do not want bionic support
  64. #
  65. # Define NO_LIBCRYPTO if you do not want libcrypto (openssl) support
  66. # used for generating build-ids for ELFs generated by jitdump.
  67. #
  68. # Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
  69. # for dwarf backtrace post unwind.
  70. #
  71. # Define NO_PERF_READ_VDSO32 if you do not want to build perf-read-vdso32
  72. # for reading the 32-bit compatibility VDSO in 64-bit mode
  73. #
  74. # Define NO_PERF_READ_VDSOX32 if you do not want to build perf-read-vdsox32
  75. # for reading the x32 mode 32-bit compatibility VDSO in 64-bit mode
  76. #
  77. # Define NO_ZLIB if you do not want to support compressed kernel modules
  78. #
  79. # Define NO_LIBBABELTRACE if you do not want libbabeltrace support
  80. # for CTF data format.
  81. #
  82. # Define NO_LZMA if you do not want to support compressed (xz) kernel modules
  83. #
  84. # Define NO_AUXTRACE if you do not want AUX area tracing support
  85. #
  86. # Define NO_LIBBPF if you do not want BPF support
  87. #
  88. # Define NO_LIBCAP if you do not want process capabilities considered by perf
  89. #
  90. # Define NO_SDT if you do not want to define SDT event in perf tools,
  91. # note that it doesn't disable SDT scanning support.
  92. #
  93. # Define FEATURES_DUMP to provide features detection dump file
  94. # and bypass the feature detection
  95. #
  96. # Define NO_JVMTI if you do not want jvmti agent built
  97. #
  98. # Define NO_JVMTI_CMLR (debug only) if you do not want to process CMLR
  99. # data for java source lines.
  100. #
  101. # Define LIBCLANGLLVM if you DO want builtin clang and llvm support.
  102. # When selected, pass LLVM_CONFIG=/path/to/llvm-config to `make' if
  103. # llvm-config is not in $PATH.
  104. #
  105. # Define CORESIGHT if you DO WANT support for CoreSight trace decoding.
  106. #
  107. # Define NO_AIO if you do not want support of Posix AIO based trace
  108. # streaming for record mode. Currently Posix AIO trace streaming is
  109. # supported only when linking with glibc.
  110. #
  111. # Define NO_LIBZSTD if you do not want support of Zstandard based runtime
  112. # trace compression in record mode.
  113. #
  114. # Define TCMALLOC to enable tcmalloc heap profiling.
  115. #
  116. # Define LIBBPF_DYNAMIC to enable libbpf dynamic linking.
  117. #
  118. # Define NO_SYSCALL_TABLE=1 to disable the use of syscall id to/from name tables
  119. # generated from the kernel .tbl or unistd.h files and use, if available, libaudit
  120. # for doing the conversions to/from strings/id.
  121. #
  122. # Define LIBPFM4 to enable libpfm4 events extension.
  123. #
  124. # Define NO_LIBDEBUGINFOD if you do not want support debuginfod
  125. #
  126. # As per kernel Makefile, avoid funny character set dependencies
  127. unexport LC_ALL
  128. LC_COLLATE=C
  129. LC_NUMERIC=C
  130. export LC_COLLATE LC_NUMERIC
  131. ifeq ($(srctree),)
  132. srctree := $(patsubst %/,%,$(dir $(CURDIR)))
  133. srctree := $(patsubst %/,%,$(dir $(srctree)))
  134. #$(info Determined 'srctree' to be $(srctree))
  135. endif
  136. ifneq ($(objtree),)
  137. #$(info Determined 'objtree' to be $(objtree))
  138. endif
  139. ifneq ($(OUTPUT),)
  140. #$(info Determined 'OUTPUT' to be $(OUTPUT))
  141. # Adding $(OUTPUT) as a directory to look for source files,
  142. # because use generated output files as sources dependency
  143. # for flex/bison parsers.
  144. VPATH += $(OUTPUT)
  145. export VPATH
  146. endif
  147. ifeq ($(V),1)
  148. Q =
  149. else
  150. Q = @
  151. endif
  152. # Do not use make's built-in rules
  153. # (this improves performance and avoids hard-to-debug behaviour);
  154. MAKEFLAGS += -r
  155. # Makefiles suck: This macro sets a default value of $(2) for the
  156. # variable named by $(1), unless the variable has been set by
  157. # environment or command line. This is necessary for CC and AR
  158. # because make sets default values, so the simpler ?= approach
  159. # won't work as expected.
  160. define allow-override
  161. $(if $(or $(findstring environment,$(origin $(1))),\
  162. $(findstring command line,$(origin $(1)))),,\
  163. $(eval $(1) = $(2)))
  164. endef
  165. LD += $(EXTRA_LDFLAGS)
  166. PKG_CONFIG = $(CROSS_COMPILE)pkg-config
  167. LLVM_CONFIG ?= llvm-config
  168. RM = rm -f
  169. LN = ln -f
  170. MKDIR = mkdir
  171. FIND = find
  172. INSTALL = install
  173. FLEX ?= flex
  174. BISON ?= bison
  175. STRIP = strip
  176. AWK = awk
  177. # include Makefile.config by default and rule out
  178. # non-config cases
  179. config := 1
  180. NON_CONFIG_TARGETS := clean python-clean TAGS tags cscope help
  181. ifdef MAKECMDGOALS
  182. ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
  183. config := 0
  184. endif
  185. endif
  186. # The fixdep build - we force fixdep tool to be built as
  187. # the first target in the separate make session not to be
  188. # disturbed by any parallel make jobs. Once fixdep is done
  189. # we issue the requested build with FIXDEP=1 variable.
  190. #
  191. # The fixdep build is disabled for $(NON_CONFIG_TARGETS)
  192. # targets, because it's not necessary.
  193. ifdef FIXDEP
  194. force_fixdep := 0
  195. else
  196. force_fixdep := $(config)
  197. endif
  198. export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK
  199. export HOSTCC HOSTLD HOSTAR
  200. include $(srctree)/tools/build/Makefile.include
  201. ifeq ($(force_fixdep),1)
  202. goals := $(filter-out all sub-make, $(MAKECMDGOALS))
  203. $(goals) all: sub-make
  204. sub-make: fixdep
  205. @./check-headers.sh
  206. $(Q)$(MAKE) FIXDEP=1 -f Makefile.perf $(goals)
  207. else # force_fixdep
  208. LIB_DIR = $(srctree)/tools/lib/api/
  209. TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
  210. BPF_DIR = $(srctree)/tools/lib/bpf/
  211. SUBCMD_DIR = $(srctree)/tools/lib/subcmd/
  212. LIBPERF_DIR = $(srctree)/tools/lib/perf/
  213. DOC_DIR = $(srctree)/tools/perf/Documentation/
  214. # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
  215. # Without this setting the output feature dump file misses some features, for
  216. # example, liberty. Select all checkers so we won't get an incomplete feature
  217. # dump file.
  218. ifeq ($(config),1)
  219. ifdef MAKECMDGOALS
  220. ifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump)
  221. FEATURE_TESTS := all
  222. endif
  223. endif
  224. include Makefile.config
  225. endif
  226. ifeq ($(config),0)
  227. include $(srctree)/tools/scripts/Makefile.arch
  228. -include arch/$(SRCARCH)/Makefile
  229. endif
  230. # The FEATURE_DUMP_EXPORT holds location of the actual
  231. # FEATURE_DUMP file to be used to bypass feature detection
  232. # (for bpf or any other subproject)
  233. ifeq ($(FEATURES_DUMP),)
  234. FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
  235. else
  236. FEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP))
  237. endif
  238. export prefix bindir sharedir sysconfdir DESTDIR
  239. # sparse is architecture-neutral, which means that we need to tell it
  240. # explicitly what architecture to check for. Fix this up for yours..
  241. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
  242. # Guard against environment variables
  243. PYRF_OBJS =
  244. SCRIPT_SH =
  245. SCRIPT_SH += perf-archive.sh
  246. SCRIPT_SH += perf-with-kcore.sh
  247. grep-libs = $(filter -l%,$(1))
  248. strip-libs = $(filter-out -l%,$(1))
  249. ifneq ($(OUTPUT),)
  250. TE_PATH=$(OUTPUT)
  251. PLUGINS_PATH=$(OUTPUT)
  252. BPF_PATH=$(OUTPUT)
  253. SUBCMD_PATH=$(OUTPUT)
  254. LIBPERF_PATH=$(OUTPUT)
  255. ifneq ($(subdir),)
  256. API_PATH=$(OUTPUT)/../lib/api/
  257. else
  258. API_PATH=$(OUTPUT)
  259. endif
  260. else
  261. TE_PATH=$(TRACE_EVENT_DIR)
  262. PLUGINS_PATH=$(TRACE_EVENT_DIR)plugins/
  263. API_PATH=$(LIB_DIR)
  264. BPF_PATH=$(BPF_DIR)
  265. SUBCMD_PATH=$(SUBCMD_DIR)
  266. LIBPERF_PATH=$(LIBPERF_DIR)
  267. endif
  268. LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
  269. export LIBTRACEEVENT
  270. LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list
  271. #
  272. # The static build has no dynsym table, so this does not work for
  273. # static build. Looks like linker starts to scream about that now
  274. # (in Fedora 26) so we need to switch it off for static build.
  275. DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
  276. LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS))
  277. LIBAPI = $(API_PATH)libapi.a
  278. export LIBAPI
  279. LIBBPF = $(BPF_PATH)libbpf.a
  280. LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
  281. LIBPERF = $(LIBPERF_PATH)libperf.a
  282. export LIBPERF
  283. # python extension build directories
  284. PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
  285. PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
  286. PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
  287. export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
  288. python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
  289. PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
  290. PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
  291. SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
  292. PROGRAMS += $(OUTPUT)perf
  293. ifndef NO_PERF_READ_VDSO32
  294. PROGRAMS += $(OUTPUT)perf-read-vdso32
  295. endif
  296. ifndef NO_PERF_READ_VDSOX32
  297. PROGRAMS += $(OUTPUT)perf-read-vdsox32
  298. endif
  299. LIBJVMTI = libperf-jvmti.so
  300. ifndef NO_JVMTI
  301. PROGRAMS += $(OUTPUT)$(LIBJVMTI)
  302. endif
  303. # what 'all' will build and 'install' will install, in perfexecdir
  304. ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
  305. # what 'all' will build but not install in perfexecdir
  306. OTHER_PROGRAMS = $(OUTPUT)perf
  307. # Set paths to tools early so that they can be used for version tests.
  308. ifndef SHELL_PATH
  309. SHELL_PATH = /bin/sh
  310. endif
  311. ifndef PERL_PATH
  312. PERL_PATH = /usr/bin/perl
  313. endif
  314. export PERL_PATH
  315. PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF)
  316. ifndef NO_LIBBPF
  317. ifndef LIBBPF_DYNAMIC
  318. PERFLIBS += $(LIBBPF)
  319. endif
  320. endif
  321. # We choose to avoid "if .. else if .. else .. endif endif"
  322. # because maintaining the nesting to match is a pain. If
  323. # we had "elif" things would have been much nicer...
  324. ifneq ($(OUTPUT),)
  325. CFLAGS += -I$(OUTPUT)
  326. endif
  327. ifdef GTK2
  328. ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
  329. GTK_IN := $(OUTPUT)gtk-in.o
  330. endif
  331. ifdef ASCIIDOC8
  332. export ASCIIDOC8
  333. endif
  334. EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
  335. LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
  336. ifeq ($(USE_CLANG), 1)
  337. CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
  338. CLANGLIBS_NOEXT_LIST = $(foreach l,$(CLANGLIBS_LIST),$(shell $(LLVM_CONFIG) --libdir)/libclang$(l))
  339. LIBCLANG = $(foreach l,$(CLANGLIBS_NOEXT_LIST),$(wildcard $(l).a $(l).so))
  340. LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-group
  341. endif
  342. ifeq ($(USE_LLVM), 1)
  343. LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)
  344. LIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)
  345. endif
  346. ifeq ($(USE_CXX), 1)
  347. LIBS += -lstdc++
  348. endif
  349. export INSTALL SHELL_PATH
  350. ### Build rules
  351. SHELL = $(SHELL_PATH)
  352. beauty_linux_dir := $(srctree)/tools/perf/trace/beauty/include/linux/
  353. linux_uapi_dir := $(srctree)/tools/include/uapi/linux
  354. asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic
  355. arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/
  356. x86_arch_asm_uapi_dir := $(srctree)/tools/arch/x86/include/uapi/asm/
  357. x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/
  358. beauty_outdir := $(OUTPUT)trace/beauty/generated
  359. beauty_ioctl_outdir := $(beauty_outdir)/ioctl
  360. drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c
  361. drm_hdr_dir := $(srctree)/tools/include/uapi/drm
  362. drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh
  363. # Create output directory if not already present
  364. _dummy := $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)')
  365. $(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl)
  366. $(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@
  367. fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c
  368. fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh
  369. $(fadvise_advice_array): $(linux_uapi_dir)/in.h $(fadvise_advice_tbl)
  370. $(Q)$(SHELL) '$(fadvise_advice_tbl)' $(linux_uapi_dir) > $@
  371. fsmount_arrays := $(beauty_outdir)/fsmount_arrays.c
  372. fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh
  373. $(fsmount_arrays): $(linux_uapi_dir)/fs.h $(fsmount_tbls)
  374. $(Q)$(SHELL) '$(fsmount_tbls)' $(linux_uapi_dir) > $@
  375. fspick_arrays := $(beauty_outdir)/fspick_arrays.c
  376. fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh
  377. $(fspick_arrays): $(linux_uapi_dir)/fs.h $(fspick_tbls)
  378. $(Q)$(SHELL) '$(fspick_tbls)' $(linux_uapi_dir) > $@
  379. fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c
  380. fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh
  381. $(fsconfig_arrays): $(linux_uapi_dir)/fs.h $(fsconfig_tbls)
  382. $(Q)$(SHELL) '$(fsconfig_tbls)' $(linux_uapi_dir) > $@
  383. pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c
  384. asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
  385. pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
  386. $(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl)
  387. $(Q)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@
  388. sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c
  389. sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound
  390. sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh
  391. $(sndrv_ctl_ioctl_array): $(sndrv_ctl_hdr_dir)/asound.h $(sndrv_ctl_ioctl_tbl)
  392. $(Q)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(sndrv_ctl_hdr_dir) > $@
  393. sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c
  394. sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound
  395. sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh
  396. $(sndrv_pcm_ioctl_array): $(sndrv_pcm_hdr_dir)/asound.h $(sndrv_pcm_ioctl_tbl)
  397. $(Q)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(sndrv_pcm_hdr_dir) > $@
  398. kcmp_type_array := $(beauty_outdir)/kcmp_type_array.c
  399. kcmp_hdr_dir := $(srctree)/tools/include/uapi/linux/
  400. kcmp_type_tbl := $(srctree)/tools/perf/trace/beauty/kcmp_type.sh
  401. $(kcmp_type_array): $(kcmp_hdr_dir)/kcmp.h $(kcmp_type_tbl)
  402. $(Q)$(SHELL) '$(kcmp_type_tbl)' $(kcmp_hdr_dir) > $@
  403. kvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c
  404. kvm_hdr_dir := $(srctree)/tools/include/uapi/linux
  405. kvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh
  406. $(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl)
  407. $(Q)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@
  408. socket_ipproto_array := $(beauty_outdir)/socket_ipproto_array.c
  409. socket_ipproto_tbl := $(srctree)/tools/perf/trace/beauty/socket_ipproto.sh
  410. $(socket_ipproto_array): $(linux_uapi_dir)/in.h $(socket_ipproto_tbl)
  411. $(Q)$(SHELL) '$(socket_ipproto_tbl)' $(linux_uapi_dir) > $@
  412. socket_arrays := $(beauty_outdir)/socket_arrays.c
  413. socket_tbl := $(srctree)/tools/perf/trace/beauty/socket.sh
  414. $(socket_arrays): $(beauty_linux_dir)/socket.h $(socket_tbl)
  415. $(Q)$(SHELL) '$(socket_tbl)' $(beauty_linux_dir) > $@
  416. vhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c
  417. vhost_virtio_hdr_dir := $(srctree)/tools/include/uapi/linux
  418. vhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh
  419. $(vhost_virtio_ioctl_array): $(vhost_virtio_hdr_dir)/vhost.h $(vhost_virtio_ioctl_tbl)
  420. $(Q)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(vhost_virtio_hdr_dir) > $@
  421. perf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c
  422. perf_hdr_dir := $(srctree)/tools/include/uapi/linux
  423. perf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh
  424. $(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl)
  425. $(Q)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@
  426. madvise_behavior_array := $(beauty_outdir)/madvise_behavior_array.c
  427. madvise_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
  428. madvise_behavior_tbl := $(srctree)/tools/perf/trace/beauty/madvise_behavior.sh
  429. $(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_tbl)
  430. $(Q)$(SHELL) '$(madvise_behavior_tbl)' $(madvise_hdr_dir) > $@
  431. mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c
  432. mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh
  433. $(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl)
  434. $(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@
  435. mremap_flags_array := $(beauty_outdir)/mremap_flags_array.c
  436. mremap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mremap_flags.sh
  437. $(mremap_flags_array): $(linux_uapi_dir)/mman.h $(mremap_flags_tbl)
  438. $(Q)$(SHELL) '$(mremap_flags_tbl)' $(linux_uapi_dir) > $@
  439. mount_flags_array := $(beauty_outdir)/mount_flags_array.c
  440. mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh
  441. $(mount_flags_array): $(linux_uapi_dir)/fs.h $(mount_flags_tbl)
  442. $(Q)$(SHELL) '$(mount_flags_tbl)' $(linux_uapi_dir) > $@
  443. move_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c
  444. move_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh
  445. $(move_mount_flags_array): $(linux_uapi_dir)/fs.h $(move_mount_flags_tbl)
  446. $(Q)$(SHELL) '$(move_mount_flags_tbl)' $(linux_uapi_dir) > $@
  447. mmap_prot_array := $(beauty_outdir)/mmap_prot_array.c
  448. mmap_prot_tbl := $(srctree)/tools/perf/trace/beauty/mmap_prot.sh
  449. $(mmap_prot_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_prot_tbl)
  450. $(Q)$(SHELL) '$(mmap_prot_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@
  451. prctl_option_array := $(beauty_outdir)/prctl_option_array.c
  452. prctl_hdr_dir := $(srctree)/tools/include/uapi/linux/
  453. prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh
  454. $(prctl_option_array): $(prctl_hdr_dir)/prctl.h $(prctl_option_tbl)
  455. $(Q)$(SHELL) '$(prctl_option_tbl)' $(prctl_hdr_dir) > $@
  456. usbdevfs_ioctl_array := $(beauty_ioctl_outdir)/usbdevfs_ioctl_array.c
  457. usbdevfs_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/usbdevfs_ioctl.sh
  458. $(usbdevfs_ioctl_array): $(linux_uapi_dir)/usbdevice_fs.h $(usbdevfs_ioctl_tbl)
  459. $(Q)$(SHELL) '$(usbdevfs_ioctl_tbl)' $(linux_uapi_dir) > $@
  460. x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c
  461. x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh
  462. $(x86_arch_prctl_code_array): $(x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl)
  463. $(Q)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(x86_arch_asm_uapi_dir) > $@
  464. x86_arch_irq_vectors_array := $(beauty_outdir)/x86_arch_irq_vectors_array.c
  465. x86_arch_irq_vectors_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh
  466. $(x86_arch_irq_vectors_array): $(x86_arch_asm_dir)/irq_vectors.h $(x86_arch_irq_vectors_tbl)
  467. $(Q)$(SHELL) '$(x86_arch_irq_vectors_tbl)' $(x86_arch_asm_dir) > $@
  468. x86_arch_MSRs_array := $(beauty_outdir)/x86_arch_MSRs_array.c
  469. x86_arch_MSRs_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_msr.sh
  470. $(x86_arch_MSRs_array): $(x86_arch_asm_dir)/msr-index.h $(x86_arch_MSRs_tbl)
  471. $(Q)$(SHELL) '$(x86_arch_MSRs_tbl)' $(x86_arch_asm_dir) > $@
  472. rename_flags_array := $(beauty_outdir)/rename_flags_array.c
  473. rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh
  474. $(rename_flags_array): $(linux_uapi_dir)/fs.h $(rename_flags_tbl)
  475. $(Q)$(SHELL) '$(rename_flags_tbl)' $(linux_uapi_dir) > $@
  476. arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c
  477. arch_errno_hdr_dir := $(srctree)/tools
  478. arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
  479. $(arch_errno_name_array): $(arch_errno_tbl)
  480. $(Q)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@
  481. sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c
  482. sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh
  483. $(sync_file_range_arrays): $(linux_uapi_dir)/fs.h $(sync_file_range_tbls)
  484. $(Q)$(SHELL) '$(sync_file_range_tbls)' $(linux_uapi_dir) > $@
  485. all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
  486. # Create python binding output directory if not already present
  487. _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
  488. $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) $(LIBPERF)
  489. $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
  490. CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
  491. $(PYTHON_WORD) util/setup.py \
  492. --quiet build_ext; \
  493. cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
  494. please_set_SHELL_PATH_to_a_more_modern_shell:
  495. $(Q)$$(:)
  496. shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
  497. strip: $(PROGRAMS) $(OUTPUT)perf
  498. $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
  499. PERF_IN := $(OUTPUT)perf-in.o
  500. JEVENTS := $(OUTPUT)pmu-events/jevents
  501. JEVENTS_IN := $(OUTPUT)pmu-events/jevents-in.o
  502. PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
  503. export JEVENTS
  504. build := -f $(srctree)/tools/build/Makefile.build dir=. obj
  505. $(PERF_IN): prepare FORCE
  506. $(Q)$(MAKE) $(build)=perf
  507. $(JEVENTS_IN): FORCE
  508. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=jevents
  509. $(JEVENTS): $(JEVENTS_IN)
  510. $(QUIET_LINK)$(HOSTCC) $(JEVENTS_IN) -o $@
  511. $(PMU_EVENTS_IN): $(JEVENTS) FORCE
  512. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
  513. $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
  514. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
  515. $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
  516. $(GTK_IN): FORCE
  517. $(Q)$(MAKE) $(build)=gtk
  518. $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
  519. $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
  520. $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
  521. $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
  522. $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
  523. $(SCRIPTS) : % : %.sh
  524. $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
  525. $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
  526. $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
  527. $(Q)touch $(OUTPUT)PERF-VERSION-FILE
  528. # These can record PERF_VERSION
  529. perf.spec $(SCRIPTS) \
  530. : $(OUTPUT)PERF-VERSION-FILE
  531. .SUFFIXES:
  532. #
  533. # If a target does not match any of the later rules then prefix it by $(OUTPUT)
  534. # This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
  535. #
  536. ifneq ($(OUTPUT),)
  537. %.o: $(OUTPUT)%.o
  538. @echo " # Redirected target $@ => $(OUTPUT)$@"
  539. pmu-events/%.o: $(OUTPUT)pmu-events/%.o
  540. @echo " # Redirected target $@ => $(OUTPUT)$@"
  541. util/%.o: $(OUTPUT)util/%.o
  542. @echo " # Redirected target $@ => $(OUTPUT)$@"
  543. bench/%.o: $(OUTPUT)bench/%.o
  544. @echo " # Redirected target $@ => $(OUTPUT)$@"
  545. tests/%.o: $(OUTPUT)tests/%.o
  546. @echo " # Redirected target $@ => $(OUTPUT)$@"
  547. endif
  548. # These two need to be here so that when O= is not used they take precedence
  549. # over the general rule for .o
  550. # get relative building directory (to $(OUTPUT))
  551. # and '.' if it's $(OUTPUT) itself
  552. __build-dir = $(subst $(OUTPUT),,$(dir $@))
  553. build-dir = $(if $(__build-dir),$(__build-dir),.)
  554. prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \
  555. $(fadvise_advice_array) \
  556. $(fsconfig_arrays) \
  557. $(fsmount_arrays) \
  558. $(fspick_arrays) \
  559. $(pkey_alloc_access_rights_array) \
  560. $(sndrv_pcm_ioctl_array) \
  561. $(sndrv_ctl_ioctl_array) \
  562. $(kcmp_type_array) \
  563. $(kvm_ioctl_array) \
  564. $(socket_ipproto_array) \
  565. $(socket_arrays) \
  566. $(vhost_virtio_ioctl_array) \
  567. $(madvise_behavior_array) \
  568. $(mmap_flags_array) \
  569. $(mmap_prot_array) \
  570. $(mremap_flags_array) \
  571. $(mount_flags_array) \
  572. $(move_mount_flags_array) \
  573. $(perf_ioctl_array) \
  574. $(prctl_option_array) \
  575. $(usbdevfs_ioctl_array) \
  576. $(x86_arch_irq_vectors_array) \
  577. $(x86_arch_MSRs_array) \
  578. $(x86_arch_prctl_code_array) \
  579. $(rename_flags_array) \
  580. $(arch_errno_name_array) \
  581. $(sync_file_range_arrays)
  582. $(OUTPUT)%.o: %.c prepare FORCE
  583. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  584. $(OUTPUT)%.i: %.c prepare FORCE
  585. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  586. $(OUTPUT)%.s: %.c prepare FORCE
  587. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  588. $(OUTPUT)%-bison.o: %.c prepare FORCE
  589. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  590. $(OUTPUT)%-flex.o: %.c prepare FORCE
  591. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  592. $(OUTPUT)%.o: %.S prepare FORCE
  593. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  594. $(OUTPUT)%.i: %.S prepare FORCE
  595. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  596. $(OUTPUT)perf-%: %.o $(PERFLIBS)
  597. $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
  598. ifndef NO_PERF_READ_VDSO32
  599. $(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-map.c
  600. $(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
  601. endif
  602. ifndef NO_PERF_READ_VDSOX32
  603. $(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-map.c
  604. $(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
  605. endif
  606. ifndef NO_JVMTI
  607. LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
  608. $(LIBJVMTI_IN): FORCE
  609. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
  610. $(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
  611. $(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
  612. endif
  613. $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
  614. LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(LDFLAGS)'
  615. $(LIBTRACEEVENT): FORCE
  616. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a
  617. libtraceevent_plugins: FORCE
  618. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR)plugins $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins
  619. $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins
  620. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR)plugins $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent-dynamic-list
  621. $(LIBTRACEEVENT)-clean:
  622. $(call QUIET_CLEAN, libtraceevent)
  623. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean >/dev/null
  624. install-traceevent-plugins: libtraceevent_plugins
  625. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins
  626. $(LIBAPI): FORCE
  627. $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
  628. $(LIBAPI)-clean:
  629. $(call QUIET_CLEAN, libapi)
  630. $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
  631. $(LIBBPF): FORCE
  632. $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
  633. $(LIBBPF)-clean:
  634. $(call QUIET_CLEAN, libbpf)
  635. $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
  636. $(LIBPERF): FORCE
  637. $(Q)$(MAKE) -C $(LIBPERF_DIR) EXTRA_CFLAGS="$(LIBPERF_CFLAGS)" O=$(OUTPUT) $(OUTPUT)libperf.a
  638. $(LIBPERF)-clean:
  639. $(call QUIET_CLEAN, libperf)
  640. $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) clean >/dev/null
  641. $(LIBSUBCMD): FORCE
  642. $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
  643. $(LIBSUBCMD)-clean:
  644. $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) clean
  645. help:
  646. @echo 'Perf make targets:'
  647. @echo ' doc - make *all* documentation (see below)'
  648. @echo ' man - make manpage documentation (access with man <foo>)'
  649. @echo ' html - make html documentation'
  650. @echo ' info - make GNU info documentation (access with info <foo>)'
  651. @echo ' pdf - make pdf documentation'
  652. @echo ' TAGS - use etags to make tag information for source browsing'
  653. @echo ' tags - use ctags to make tag information for source browsing'
  654. @echo ' cscope - use cscope to make interactive browsing database'
  655. @echo ''
  656. @echo 'Perf install targets:'
  657. @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
  658. @echo ' HINT: use "prefix" or "DESTDIR" to install to a particular'
  659. @echo ' path like "make prefix=/usr/local install install-doc"'
  660. @echo ' install - install compiled binaries'
  661. @echo ' install-doc - install *all* documentation'
  662. @echo ' install-man - install manpage documentation'
  663. @echo ' install-html - install html documentation'
  664. @echo ' install-info - install GNU info documentation'
  665. @echo ' install-pdf - install pdf documentation'
  666. @echo ''
  667. @echo ' quick-install-doc - alias for quick-install-man'
  668. @echo ' quick-install-man - install the documentation quickly'
  669. @echo ' quick-install-html - install the html documentation quickly'
  670. @echo ''
  671. @echo 'Perf maintainer targets:'
  672. @echo ' clean - clean all binary objects and build output'
  673. DOC_TARGETS := doc man html info pdf
  674. INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
  675. INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
  676. # 'make doc' should call 'make -C Documentation all'
  677. $(DOC_TARGETS):
  678. $(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:doc=all) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
  679. TAG_FOLDERS= . ../lib ../include
  680. TAG_FILES= ../../include/uapi/linux/perf_event.h
  681. TAGS:
  682. $(QUIET_GEN)$(RM) TAGS; \
  683. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs etags -a $(TAG_FILES)
  684. tags:
  685. $(QUIET_GEN)$(RM) tags; \
  686. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs ctags -a $(TAG_FILES)
  687. cscope:
  688. $(QUIET_GEN)$(RM) cscope*; \
  689. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs cscope -b $(TAG_FILES)
  690. ### Testing rules
  691. # GNU make supports exporting all variables by "export" without parameters.
  692. # However, the environment gets quite big, and some programs have problems
  693. # with that.
  694. check: $(OUTPUT)common-cmds.h
  695. if sparse; \
  696. then \
  697. for i in *.c */*.c; \
  698. do \
  699. sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
  700. done; \
  701. else \
  702. exit 1; \
  703. fi
  704. ### Installation rules
  705. ifdef GTK2
  706. install-gtk: $(OUTPUT)libperf-gtk.so
  707. $(call QUIET_INSTALL, 'GTK UI') \
  708. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
  709. $(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
  710. else
  711. install-gtk:
  712. endif
  713. install-tools: all install-gtk
  714. $(call QUIET_INSTALL, binaries) \
  715. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
  716. $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
  717. $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'
  718. ifndef NO_PERF_READ_VDSO32
  719. $(call QUIET_INSTALL, perf-read-vdso32) \
  720. $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
  721. endif
  722. ifndef NO_PERF_READ_VDSOX32
  723. $(call QUIET_INSTALL, perf-read-vdsox32) \
  724. $(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
  725. endif
  726. ifndef NO_JVMTI
  727. $(call QUIET_INSTALL, $(LIBJVMTI)) \
  728. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
  729. $(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
  730. endif
  731. $(call QUIET_INSTALL, libexec) \
  732. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  733. ifndef NO_LIBBPF
  734. $(call QUIET_INSTALL, bpf-headers) \
  735. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
  736. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'; \
  737. $(INSTALL) include/bpf/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
  738. $(INSTALL) include/bpf/linux/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'
  739. $(call QUIET_INSTALL, bpf-examples) \
  740. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'; \
  741. $(INSTALL) examples/bpf/*.c -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
  742. endif
  743. $(call QUIET_INSTALL, perf-archive) \
  744. $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  745. $(call QUIET_INSTALL, perf-with-kcore) \
  746. $(INSTALL) $(OUTPUT)perf-with-kcore -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  747. ifndef NO_LIBAUDIT
  748. $(call QUIET_INSTALL, strace/groups) \
  749. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'; \
  750. $(INSTALL) trace/strace/groups/* -t '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'
  751. endif
  752. ifndef NO_LIBPERL
  753. $(call QUIET_INSTALL, perl-scripts) \
  754. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
  755. $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
  756. $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
  757. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
  758. $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  759. endif
  760. ifndef NO_LIBPYTHON
  761. $(call QUIET_INSTALL, python-scripts) \
  762. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
  763. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
  764. $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
  765. $(INSTALL) scripts/python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
  766. $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  767. endif
  768. $(call QUIET_INSTALL, perf_completion-script) \
  769. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
  770. $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
  771. $(call QUIET_INSTALL, perf-tip) \
  772. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
  773. $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
  774. install-tests: all install-gtk
  775. $(call QUIET_INSTALL, tests) \
  776. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
  777. $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
  778. $(INSTALL) tests/pe-file.exe* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
  779. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
  780. $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
  781. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
  782. $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
  783. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
  784. $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
  785. install-bin: install-tools install-tests install-traceevent-plugins
  786. install: install-bin try-install-man
  787. install-python_ext:
  788. $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
  789. # 'make install-doc' should call 'make -C Documentation install'
  790. $(INSTALL_DOC_TARGETS):
  791. $(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:-doc=) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
  792. ### Cleaning rules
  793. #
  794. # This is here, not in Makefile.config, because Makefile.config does
  795. # not get included for the clean target:
  796. #
  797. config-clean:
  798. $(call QUIET_CLEAN, config)
  799. $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null
  800. python-clean:
  801. $(python-clean)
  802. clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean config-clean fixdep-clean python-clean
  803. $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
  804. $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
  805. $(Q)$(RM) $(OUTPUT).config-detected
  806. $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
  807. $(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* \
  808. $(OUTPUT)util/intel-pt-decoder/inat-tables.c \
  809. $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
  810. $(OUTPUT)pmu-events/pmu-events.c \
  811. $(OUTPUT)$(fadvise_advice_array) \
  812. $(OUTPUT)$(fsconfig_arrays) \
  813. $(OUTPUT)$(fsmount_arrays) \
  814. $(OUTPUT)$(fspick_arrays) \
  815. $(OUTPUT)$(madvise_behavior_array) \
  816. $(OUTPUT)$(mmap_flags_array) \
  817. $(OUTPUT)$(mmap_prot_array) \
  818. $(OUTPUT)$(mremap_flags_array) \
  819. $(OUTPUT)$(mount_flags_array) \
  820. $(OUTPUT)$(move_mount_flags_array) \
  821. $(OUTPUT)$(drm_ioctl_array) \
  822. $(OUTPUT)$(pkey_alloc_access_rights_array) \
  823. $(OUTPUT)$(sndrv_ctl_ioctl_array) \
  824. $(OUTPUT)$(sndrv_pcm_ioctl_array) \
  825. $(OUTPUT)$(kvm_ioctl_array) \
  826. $(OUTPUT)$(kcmp_type_array) \
  827. $(OUTPUT)$(socket_ipproto_array) \
  828. $(OUTPUT)$(socket_arrays) \
  829. $(OUTPUT)$(vhost_virtio_ioctl_array) \
  830. $(OUTPUT)$(perf_ioctl_array) \
  831. $(OUTPUT)$(prctl_option_array) \
  832. $(OUTPUT)$(usbdevfs_ioctl_array) \
  833. $(OUTPUT)$(x86_arch_irq_vectors_array) \
  834. $(OUTPUT)$(x86_arch_MSRs_array) \
  835. $(OUTPUT)$(x86_arch_prctl_code_array) \
  836. $(OUTPUT)$(rename_flags_array) \
  837. $(OUTPUT)$(arch_errno_name_array) \
  838. $(OUTPUT)$(sync_file_range_arrays)
  839. $(call QUIET_CLEAN, Documentation) \
  840. $(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null
  841. #
  842. # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
  843. # file if defined, with no further action.
  844. feature-dump:
  845. ifdef FEATURE_DUMP_COPY
  846. @cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY)
  847. @echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)"
  848. else
  849. @echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP"
  850. endif
  851. #
  852. # Trick: if ../../.git does not exist - we are building out of tree for example,
  853. # then force version regeneration:
  854. #
  855. ifeq ($(wildcard ../../.git/HEAD),)
  856. GIT-HEAD-PHONY = ../../.git/HEAD
  857. else
  858. GIT-HEAD-PHONY =
  859. endif
  860. FORCE:
  861. .PHONY: all install clean config-clean strip install-gtk
  862. .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
  863. .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare
  864. .PHONY: libtraceevent_plugins archheaders
  865. endif # force_fixdep