Makefile.perf 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  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 NO_SDT if you do not want to define SDT event in perf tools,
  82. # note that it doesn't disable SDT scanning support.
  83. #
  84. # Define FEATURES_DUMP to provide features detection dump file
  85. # and bypass the feature detection
  86. #
  87. # Define NO_JVMTI if you do not want jvmti agent built
  88. #
  89. # Define LIBCLANGLLVM if you DO want builtin clang and llvm support.
  90. # When selected, pass LLVM_CONFIG=/path/to/llvm-config to `make' if
  91. # llvm-config is not in $PATH.
  92. # As per kernel Makefile, avoid funny character set dependencies
  93. unexport LC_ALL
  94. LC_COLLATE=C
  95. LC_NUMERIC=C
  96. export LC_COLLATE LC_NUMERIC
  97. ifeq ($(srctree),)
  98. srctree := $(patsubst %/,%,$(dir $(CURDIR)))
  99. srctree := $(patsubst %/,%,$(dir $(srctree)))
  100. #$(info Determined 'srctree' to be $(srctree))
  101. endif
  102. ifneq ($(objtree),)
  103. #$(info Determined 'objtree' to be $(objtree))
  104. endif
  105. ifneq ($(OUTPUT),)
  106. #$(info Determined 'OUTPUT' to be $(OUTPUT))
  107. # Adding $(OUTPUT) as a directory to look for source files,
  108. # because use generated output files as sources dependency
  109. # for flex/bison parsers.
  110. VPATH += $(OUTPUT)
  111. export VPATH
  112. endif
  113. ifeq ($(V),1)
  114. Q =
  115. else
  116. Q = @
  117. endif
  118. # Do not use make's built-in rules
  119. # (this improves performance and avoids hard-to-debug behaviour);
  120. MAKEFLAGS += -r
  121. # Makefiles suck: This macro sets a default value of $(2) for the
  122. # variable named by $(1), unless the variable has been set by
  123. # environment or command line. This is necessary for CC and AR
  124. # because make sets default values, so the simpler ?= approach
  125. # won't work as expected.
  126. define allow-override
  127. $(if $(or $(findstring environment,$(origin $(1))),\
  128. $(findstring command line,$(origin $(1)))),,\
  129. $(eval $(1) = $(2)))
  130. endef
  131. # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
  132. $(call allow-override,CC,$(CROSS_COMPILE)gcc)
  133. $(call allow-override,AR,$(CROSS_COMPILE)ar)
  134. $(call allow-override,LD,$(CROSS_COMPILE)ld)
  135. $(call allow-override,CXX,$(CROSS_COMPILE)g++)
  136. LD += $(EXTRA_LDFLAGS)
  137. HOSTCC ?= gcc
  138. HOSTLD ?= ld
  139. HOSTAR ?= ar
  140. PKG_CONFIG = $(CROSS_COMPILE)pkg-config
  141. LLVM_CONFIG ?= llvm-config
  142. RM = rm -f
  143. LN = ln -f
  144. MKDIR = mkdir
  145. FIND = find
  146. INSTALL = install
  147. FLEX = flex
  148. BISON = bison
  149. STRIP = strip
  150. AWK = awk
  151. # include Makefile.config by default and rule out
  152. # non-config cases
  153. config := 1
  154. NON_CONFIG_TARGETS := clean TAGS tags cscope help install-doc install-man install-html install-info install-pdf doc man html info pdf
  155. ifdef MAKECMDGOALS
  156. ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
  157. config := 0
  158. endif
  159. endif
  160. # The fixdep build - we force fixdep tool to be built as
  161. # the first target in the separate make session not to be
  162. # disturbed by any parallel make jobs. Once fixdep is done
  163. # we issue the requested build with FIXDEP=1 variable.
  164. #
  165. # The fixdep build is disabled for $(NON_CONFIG_TARGETS)
  166. # targets, because it's not necessary.
  167. ifdef FIXDEP
  168. force_fixdep := 0
  169. else
  170. force_fixdep := $(config)
  171. endif
  172. export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK
  173. export HOSTCC HOSTLD HOSTAR
  174. include $(srctree)/tools/build/Makefile.include
  175. ifeq ($(force_fixdep),1)
  176. goals := $(filter-out all sub-make, $(MAKECMDGOALS))
  177. $(goals) all: sub-make
  178. sub-make: fixdep
  179. @./check-headers.sh
  180. $(Q)$(MAKE) FIXDEP=1 -f Makefile.perf $(goals)
  181. else # force_fixdep
  182. LIB_DIR = $(srctree)/tools/lib/api/
  183. TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
  184. BPF_DIR = $(srctree)/tools/lib/bpf/
  185. SUBCMD_DIR = $(srctree)/tools/lib/subcmd/
  186. # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
  187. # Without this setting the output feature dump file misses some features, for
  188. # example, liberty. Select all checkers so we won't get an incomplete feature
  189. # dump file.
  190. ifeq ($(config),1)
  191. ifdef MAKECMDGOALS
  192. ifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump)
  193. FEATURE_TESTS := all
  194. endif
  195. endif
  196. include Makefile.config
  197. endif
  198. ifeq ($(config),0)
  199. include $(srctree)/tools/scripts/Makefile.arch
  200. -include arch/$(ARCH)/Makefile
  201. endif
  202. # The FEATURE_DUMP_EXPORT holds location of the actual
  203. # FEATURE_DUMP file to be used to bypass feature detection
  204. # (for bpf or any other subproject)
  205. ifeq ($(FEATURES_DUMP),)
  206. FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
  207. else
  208. FEATURE_DUMP_EXPORT := $(FEATURES_DUMP)
  209. endif
  210. export prefix bindir sharedir sysconfdir DESTDIR
  211. # sparse is architecture-neutral, which means that we need to tell it
  212. # explicitly what architecture to check for. Fix this up for yours..
  213. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
  214. # Guard against environment variables
  215. PYRF_OBJS =
  216. SCRIPT_SH =
  217. SCRIPT_SH += perf-archive.sh
  218. SCRIPT_SH += perf-with-kcore.sh
  219. grep-libs = $(filter -l%,$(1))
  220. strip-libs = $(filter-out -l%,$(1))
  221. ifneq ($(OUTPUT),)
  222. TE_PATH=$(OUTPUT)
  223. BPF_PATH=$(OUTPUT)
  224. SUBCMD_PATH=$(OUTPUT)
  225. ifneq ($(subdir),)
  226. API_PATH=$(OUTPUT)/../lib/api/
  227. else
  228. API_PATH=$(OUTPUT)
  229. endif
  230. else
  231. TE_PATH=$(TRACE_EVENT_DIR)
  232. API_PATH=$(LIB_DIR)
  233. BPF_PATH=$(BPF_DIR)
  234. SUBCMD_PATH=$(SUBCMD_DIR)
  235. endif
  236. LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
  237. export LIBTRACEEVENT
  238. LIBTRACEEVENT_DYNAMIC_LIST = $(TE_PATH)libtraceevent-dynamic-list
  239. LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
  240. LIBAPI = $(API_PATH)libapi.a
  241. export LIBAPI
  242. LIBBPF = $(BPF_PATH)libbpf.a
  243. LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
  244. # python extension build directories
  245. PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
  246. PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
  247. PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
  248. export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
  249. python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
  250. PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
  251. PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
  252. SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
  253. PROGRAMS += $(OUTPUT)perf
  254. ifndef NO_PERF_READ_VDSO32
  255. PROGRAMS += $(OUTPUT)perf-read-vdso32
  256. endif
  257. ifndef NO_PERF_READ_VDSOX32
  258. PROGRAMS += $(OUTPUT)perf-read-vdsox32
  259. endif
  260. LIBJVMTI = libperf-jvmti.so
  261. ifndef NO_JVMTI
  262. PROGRAMS += $(OUTPUT)$(LIBJVMTI)
  263. endif
  264. # what 'all' will build and 'install' will install, in perfexecdir
  265. ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
  266. # what 'all' will build but not install in perfexecdir
  267. OTHER_PROGRAMS = $(OUTPUT)perf
  268. # Set paths to tools early so that they can be used for version tests.
  269. ifndef SHELL_PATH
  270. SHELL_PATH = /bin/sh
  271. endif
  272. ifndef PERL_PATH
  273. PERL_PATH = /usr/bin/perl
  274. endif
  275. export PERL_PATH
  276. LIB_FILE=$(OUTPUT)libperf.a
  277. PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD)
  278. ifndef NO_LIBBPF
  279. PERFLIBS += $(LIBBPF)
  280. endif
  281. # We choose to avoid "if .. else if .. else .. endif endif"
  282. # because maintaining the nesting to match is a pain. If
  283. # we had "elif" things would have been much nicer...
  284. ifneq ($(OUTPUT),)
  285. CFLAGS += -I$(OUTPUT)
  286. endif
  287. ifndef NO_GTK2
  288. ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
  289. GTK_IN := $(OUTPUT)gtk-in.o
  290. endif
  291. ifdef ASCIIDOC8
  292. export ASCIIDOC8
  293. endif
  294. LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
  295. ifeq ($(USE_CLANG), 1)
  296. CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
  297. LIBCLANG = $(foreach l,$(CLANGLIBS_LIST),$(wildcard $(shell $(LLVM_CONFIG) --libdir)/libclang$(l).a))
  298. LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-group
  299. endif
  300. ifeq ($(USE_LLVM), 1)
  301. LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)
  302. LIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)
  303. endif
  304. ifeq ($(USE_CXX), 1)
  305. LIBS += -lstdc++
  306. endif
  307. export INSTALL SHELL_PATH
  308. ### Build rules
  309. SHELL = $(SHELL_PATH)
  310. all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
  311. $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
  312. $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
  313. CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
  314. $(PYTHON_WORD) util/setup.py \
  315. --quiet build_ext; \
  316. mkdir -p $(OUTPUT)python && \
  317. cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
  318. please_set_SHELL_PATH_to_a_more_modern_shell:
  319. $(Q)$$(:)
  320. shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
  321. strip: $(PROGRAMS) $(OUTPUT)perf
  322. $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
  323. PERF_IN := $(OUTPUT)perf-in.o
  324. JEVENTS := $(OUTPUT)pmu-events/jevents
  325. JEVENTS_IN := $(OUTPUT)pmu-events/jevents-in.o
  326. PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
  327. export JEVENTS
  328. build := -f $(srctree)/tools/build/Makefile.build dir=. obj
  329. $(PERF_IN): prepare FORCE
  330. $(Q)$(MAKE) $(build)=perf
  331. $(JEVENTS_IN): FORCE
  332. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=jevents
  333. $(JEVENTS): $(JEVENTS_IN)
  334. $(QUIET_LINK)$(HOSTCC) $(JEVENTS_IN) -o $@
  335. $(PMU_EVENTS_IN): $(JEVENTS) FORCE
  336. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
  337. $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
  338. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
  339. $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
  340. $(GTK_IN): FORCE
  341. $(Q)$(MAKE) $(build)=gtk
  342. $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
  343. $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
  344. $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
  345. $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
  346. $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
  347. $(SCRIPTS) : % : %.sh
  348. $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
  349. $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
  350. $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
  351. $(Q)touch $(OUTPUT)PERF-VERSION-FILE
  352. # These can record PERF_VERSION
  353. perf.spec $(SCRIPTS) \
  354. : $(OUTPUT)PERF-VERSION-FILE
  355. .SUFFIXES:
  356. #
  357. # If a target does not match any of the later rules then prefix it by $(OUTPUT)
  358. # This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
  359. #
  360. ifneq ($(OUTPUT),)
  361. %.o: $(OUTPUT)%.o
  362. @echo " # Redirected target $@ => $(OUTPUT)$@"
  363. pmu-events/%.o: $(OUTPUT)pmu-events/%.o
  364. @echo " # Redirected target $@ => $(OUTPUT)$@"
  365. util/%.o: $(OUTPUT)util/%.o
  366. @echo " # Redirected target $@ => $(OUTPUT)$@"
  367. bench/%.o: $(OUTPUT)bench/%.o
  368. @echo " # Redirected target $@ => $(OUTPUT)$@"
  369. tests/%.o: $(OUTPUT)tests/%.o
  370. @echo " # Redirected target $@ => $(OUTPUT)$@"
  371. endif
  372. # These two need to be here so that when O= is not used they take precedence
  373. # over the general rule for .o
  374. # get relative building directory (to $(OUTPUT))
  375. # and '.' if it's $(OUTPUT) itself
  376. __build-dir = $(subst $(OUTPUT),,$(dir $@))
  377. build-dir = $(if $(__build-dir),$(__build-dir),.)
  378. prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders
  379. $(OUTPUT)%.o: %.c prepare FORCE
  380. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  381. $(OUTPUT)%.i: %.c prepare FORCE
  382. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  383. $(OUTPUT)%.s: %.c prepare FORCE
  384. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  385. $(OUTPUT)%-bison.o: %.c prepare FORCE
  386. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  387. $(OUTPUT)%-flex.o: %.c prepare FORCE
  388. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  389. $(OUTPUT)%.o: %.S prepare FORCE
  390. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  391. $(OUTPUT)%.i: %.S prepare FORCE
  392. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
  393. $(OUTPUT)perf-%: %.o $(PERFLIBS)
  394. $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
  395. ifndef NO_PERF_READ_VDSO32
  396. $(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-vdso-map.c
  397. $(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
  398. endif
  399. ifndef NO_PERF_READ_VDSOX32
  400. $(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-vdso-map.c
  401. $(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
  402. endif
  403. ifndef NO_JVMTI
  404. LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
  405. $(LIBJVMTI_IN): FORCE
  406. $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
  407. $(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
  408. $(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $< -lelf -lrt
  409. endif
  410. $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
  411. LIBPERF_IN := $(OUTPUT)libperf-in.o
  412. $(LIBPERF_IN): prepare FORCE
  413. $(Q)$(MAKE) $(build)=libperf
  414. $(LIB_FILE): $(LIBPERF_IN)
  415. $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN) $(LIB_OBJS)
  416. LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ)
  417. $(LIBTRACEEVENT): FORCE
  418. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a
  419. libtraceevent_plugins: FORCE
  420. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins
  421. $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins
  422. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent-dynamic-list
  423. $(LIBTRACEEVENT)-clean:
  424. $(call QUIET_CLEAN, libtraceevent)
  425. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean >/dev/null
  426. install-traceevent-plugins: libtraceevent_plugins
  427. $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins
  428. $(LIBAPI): FORCE
  429. $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
  430. $(LIBAPI)-clean:
  431. $(call QUIET_CLEAN, libapi)
  432. $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
  433. $(LIBBPF): FORCE
  434. $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
  435. $(LIBBPF)-clean:
  436. $(call QUIET_CLEAN, libbpf)
  437. $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
  438. $(LIBSUBCMD): FORCE
  439. $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
  440. $(LIBSUBCMD)-clean:
  441. $(call QUIET_CLEAN, libsubcmd)
  442. $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) clean
  443. help:
  444. @echo 'Perf make targets:'
  445. @echo ' doc - make *all* documentation (see below)'
  446. @echo ' man - make manpage documentation (access with man <foo>)'
  447. @echo ' html - make html documentation'
  448. @echo ' info - make GNU info documentation (access with info <foo>)'
  449. @echo ' pdf - make pdf documentation'
  450. @echo ' TAGS - use etags to make tag information for source browsing'
  451. @echo ' tags - use ctags to make tag information for source browsing'
  452. @echo ' cscope - use cscope to make interactive browsing database'
  453. @echo ''
  454. @echo 'Perf install targets:'
  455. @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
  456. @echo ' HINT: use "prefix" or "DESTDIR" to install to a particular'
  457. @echo ' path like "make prefix=/usr/local install install-doc"'
  458. @echo ' install - install compiled binaries'
  459. @echo ' install-doc - install *all* documentation'
  460. @echo ' install-man - install manpage documentation'
  461. @echo ' install-html - install html documentation'
  462. @echo ' install-info - install GNU info documentation'
  463. @echo ' install-pdf - install pdf documentation'
  464. @echo ''
  465. @echo ' quick-install-doc - alias for quick-install-man'
  466. @echo ' quick-install-man - install the documentation quickly'
  467. @echo ' quick-install-html - install the html documentation quickly'
  468. @echo ''
  469. @echo 'Perf maintainer targets:'
  470. @echo ' clean - clean all binary objects and build output'
  471. DOC_TARGETS := doc man html info pdf
  472. INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
  473. INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
  474. # 'make doc' should call 'make -C Documentation all'
  475. $(DOC_TARGETS):
  476. $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all)
  477. TAG_FOLDERS= . ../lib ../include
  478. TAG_FILES= ../../include/uapi/linux/perf_event.h
  479. TAGS:
  480. $(QUIET_GEN)$(RM) TAGS; \
  481. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs etags -a $(TAG_FILES)
  482. tags:
  483. $(QUIET_GEN)$(RM) tags; \
  484. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs ctags -a $(TAG_FILES)
  485. cscope:
  486. $(QUIET_GEN)$(RM) cscope*; \
  487. $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs cscope -b $(TAG_FILES)
  488. ### Testing rules
  489. # GNU make supports exporting all variables by "export" without parameters.
  490. # However, the environment gets quite big, and some programs have problems
  491. # with that.
  492. check: $(OUTPUT)common-cmds.h
  493. if sparse; \
  494. then \
  495. for i in *.c */*.c; \
  496. do \
  497. sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
  498. done; \
  499. else \
  500. exit 1; \
  501. fi
  502. ### Installation rules
  503. ifndef NO_GTK2
  504. install-gtk: $(OUTPUT)libperf-gtk.so
  505. $(call QUIET_INSTALL, 'GTK UI') \
  506. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
  507. $(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
  508. else
  509. install-gtk:
  510. endif
  511. install-tools: all install-gtk
  512. $(call QUIET_INSTALL, binaries) \
  513. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
  514. $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
  515. $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'
  516. ifndef NO_PERF_READ_VDSO32
  517. $(call QUIET_INSTALL, perf-read-vdso32) \
  518. $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
  519. endif
  520. ifndef NO_PERF_READ_VDSOX32
  521. $(call QUIET_INSTALL, perf-read-vdsox32) \
  522. $(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
  523. endif
  524. ifndef NO_JVMTI
  525. $(call QUIET_INSTALL, $(LIBJVMTI)) \
  526. $(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
  527. endif
  528. $(call QUIET_INSTALL, libexec) \
  529. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  530. $(call QUIET_INSTALL, perf-archive) \
  531. $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  532. $(call QUIET_INSTALL, perf-with-kcore) \
  533. $(INSTALL) $(OUTPUT)perf-with-kcore -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  534. ifndef NO_LIBAUDIT
  535. $(call QUIET_INSTALL, strace/groups) \
  536. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'; \
  537. $(INSTALL) trace/strace/groups/* -t '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'
  538. endif
  539. ifndef NO_LIBPERL
  540. $(call QUIET_INSTALL, perl-scripts) \
  541. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
  542. $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
  543. $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
  544. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
  545. $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  546. endif
  547. ifndef NO_LIBPYTHON
  548. $(call QUIET_INSTALL, python-scripts) \
  549. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
  550. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
  551. $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
  552. $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
  553. $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  554. endif
  555. $(call QUIET_INSTALL, perf_completion-script) \
  556. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
  557. $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
  558. $(call QUIET_INSTALL, perf-tip) \
  559. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
  560. $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
  561. install-tests: all install-gtk
  562. $(call QUIET_INSTALL, tests) \
  563. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
  564. $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
  565. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
  566. $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
  567. install-bin: install-tools install-tests install-traceevent-plugins
  568. install: install-bin try-install-man
  569. install-python_ext:
  570. $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
  571. # 'make install-doc' should call 'make -C Documentation install'
  572. $(INSTALL_DOC_TARGETS):
  573. $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=)
  574. ### Cleaning rules
  575. #
  576. # This is here, not in Makefile.config, because Makefile.config does
  577. # not get included for the clean target:
  578. #
  579. config-clean:
  580. $(call QUIET_CLEAN, config)
  581. $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null
  582. clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean
  583. $(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
  584. $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
  585. $(Q)$(RM) $(OUTPUT).config-detected
  586. $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
  587. $(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* \
  588. $(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \
  589. $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
  590. $(OUTPUT)pmu-events/pmu-events.c
  591. $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
  592. $(python-clean)
  593. #
  594. # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
  595. # file if defined, with no further action.
  596. feature-dump:
  597. ifdef FEATURE_DUMP_COPY
  598. @cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY)
  599. @echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)"
  600. else
  601. @echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP"
  602. endif
  603. #
  604. # Trick: if ../../.git does not exist - we are building out of tree for example,
  605. # then force version regeneration:
  606. #
  607. ifeq ($(wildcard ../../.git/HEAD),)
  608. GIT-HEAD-PHONY = ../../.git/HEAD
  609. else
  610. GIT-HEAD-PHONY =
  611. endif
  612. FORCE:
  613. .PHONY: all install clean config-clean strip install-gtk
  614. .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
  615. .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare
  616. .PHONY: libtraceevent_plugins archheaders
  617. endif # force_fixdep