Makefile 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. ifeq ($(src-perf),)
  2. src-perf := $(srctree)/tools/perf
  3. endif
  4. ifeq ($(obj-perf),)
  5. obj-perf := $(OUTPUT)
  6. endif
  7. ifneq ($(obj-perf),)
  8. obj-perf := $(abspath $(obj-perf))/
  9. endif
  10. $(shell printf "" > $(OUTPUT).config-detected)
  11. detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
  12. detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
  13. CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
  14. include $(srctree)/tools/scripts/Makefile.arch
  15. $(call detected_var,ARCH)
  16. NO_PERF_REGS := 1
  17. # Additional ARCH settings for x86
  18. ifeq ($(ARCH),x86)
  19. $(call detected,CONFIG_X86)
  20. ifeq (${IS_64_BIT}, 1)
  21. CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
  22. ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
  23. LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
  24. $(call detected,CONFIG_X86_64)
  25. else
  26. LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
  27. endif
  28. NO_PERF_REGS := 0
  29. endif
  30. ifeq ($(ARCH),arm)
  31. NO_PERF_REGS := 0
  32. LIBUNWIND_LIBS = -lunwind -lunwind-arm
  33. endif
  34. ifeq ($(ARCH),arm64)
  35. NO_PERF_REGS := 0
  36. LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
  37. endif
  38. ifeq ($(NO_PERF_REGS),0)
  39. $(call detected,CONFIG_PERF_REGS)
  40. endif
  41. # So far there's only x86 and arm libdw unwind support merged in perf.
  42. # Disable it on all other architectures in case libdw unwind
  43. # support is detected in system. Add supported architectures
  44. # to the check.
  45. ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
  46. NO_LIBDW_DWARF_UNWIND := 1
  47. endif
  48. ifeq ($(LIBUNWIND_LIBS),)
  49. NO_LIBUNWIND := 1
  50. endif
  51. #
  52. # For linking with debug library, run like:
  53. #
  54. # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
  55. #
  56. ifdef LIBUNWIND_DIR
  57. LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
  58. LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
  59. endif
  60. LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
  61. # Set per-feature check compilation flags
  62. FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
  63. FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
  64. FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
  65. FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
  66. ifeq ($(NO_PERF_REGS),0)
  67. CFLAGS += -DHAVE_PERF_REGS_SUPPORT
  68. endif
  69. # for linking with debug library, run like:
  70. # make DEBUG=1 LIBDW_DIR=/opt/libdw/
  71. ifdef LIBDW_DIR
  72. LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
  73. LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
  74. endif
  75. FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
  76. FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
  77. # for linking with debug library, run like:
  78. # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
  79. ifdef LIBBABELTRACE_DIR
  80. LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
  81. LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
  82. endif
  83. FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
  84. FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
  85. FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(ARCH)/include/uapi -I$(srctree)/include/uapi
  86. # include ARCH specific config
  87. -include $(src-perf)/arch/$(ARCH)/Makefile
  88. ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
  89. CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
  90. endif
  91. include $(src-perf)/config/utilities.mak
  92. ifeq ($(call get-executable,$(FLEX)),)
  93. dummy := $(error Error: $(FLEX) is missing on this system, please install it)
  94. endif
  95. ifeq ($(call get-executable,$(BISON)),)
  96. dummy := $(error Error: $(BISON) is missing on this system, please install it)
  97. endif
  98. # Treat warnings as errors unless directed not to
  99. ifneq ($(WERROR),0)
  100. CFLAGS += -Werror
  101. endif
  102. ifndef DEBUG
  103. DEBUG := 0
  104. endif
  105. ifeq ($(DEBUG),0)
  106. CFLAGS += -O6
  107. endif
  108. ifdef PARSER_DEBUG
  109. PARSER_DEBUG_BISON := -t
  110. PARSER_DEBUG_FLEX := -d
  111. CFLAGS += -DPARSER_DEBUG
  112. $(call detected_var,PARSER_DEBUG_BISON)
  113. $(call detected_var,PARSER_DEBUG_FLEX)
  114. endif
  115. # Try different combinations to accommodate systems that only have
  116. # python[2][-config] in weird combinations but always preferring
  117. # python2 and python2-config as per pep-0394. If we catch a
  118. # python[-config] in version 3, the version check will kill it.
  119. PYTHON2 := $(if $(call get-executable,python2),python2,python)
  120. override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
  121. PYTHON2_CONFIG := \
  122. $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
  123. override PYTHON_CONFIG := \
  124. $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
  125. PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
  126. PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
  127. PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
  128. FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
  129. FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
  130. FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
  131. FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
  132. CFLAGS += -fno-omit-frame-pointer
  133. CFLAGS += -ggdb3
  134. CFLAGS += -funwind-tables
  135. CFLAGS += -Wall
  136. CFLAGS += -Wextra
  137. CFLAGS += -std=gnu99
  138. # Enforce a non-executable stack, as we may regress (again) in the future by
  139. # adding assembler files missing the .GNU-stack linker note.
  140. LDFLAGS += -Wl,-z,noexecstack
  141. EXTLIBS = -lpthread -lrt -lm -ldl
  142. ifeq ($(FEATURES_DUMP),)
  143. include $(srctree)/tools/build/Makefile.feature
  144. else
  145. include $(FEATURES_DUMP)
  146. endif
  147. ifeq ($(feature-stackprotector-all), 1)
  148. CFLAGS += -fstack-protector-all
  149. endif
  150. ifeq ($(DEBUG),0)
  151. ifeq ($(feature-fortify-source), 1)
  152. CFLAGS += -D_FORTIFY_SOURCE=2
  153. endif
  154. endif
  155. CFLAGS += -I$(src-perf)/util/include
  156. CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
  157. CFLAGS += -I$(srctree)/tools/include/
  158. CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
  159. CFLAGS += -I$(srctree)/arch/$(ARCH)/include
  160. CFLAGS += -I$(srctree)/include/uapi
  161. CFLAGS += -I$(srctree)/include
  162. # $(obj-perf) for generated common-cmds.h
  163. # $(obj-perf)/util for generated bison/flex headers
  164. ifneq ($(OUTPUT),)
  165. CFLAGS += -I$(obj-perf)/util
  166. CFLAGS += -I$(obj-perf)
  167. endif
  168. CFLAGS += -I$(src-perf)/util
  169. CFLAGS += -I$(src-perf)
  170. CFLAGS += -I$(srctree)/tools/lib/
  171. CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
  172. ifeq ($(feature-sync-compare-and-swap), 1)
  173. CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
  174. endif
  175. ifeq ($(feature-pthread-attr-setaffinity-np), 1)
  176. CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
  177. endif
  178. ifndef NO_BIONIC
  179. $(call feature_check,bionic)
  180. ifeq ($(feature-bionic), 1)
  181. BIONIC := 1
  182. EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
  183. EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
  184. endif
  185. endif
  186. ifdef NO_LIBELF
  187. NO_DWARF := 1
  188. NO_DEMANGLE := 1
  189. NO_LIBUNWIND := 1
  190. NO_LIBDW_DWARF_UNWIND := 1
  191. NO_LIBBPF := 1
  192. else
  193. ifeq ($(feature-libelf), 0)
  194. ifeq ($(feature-glibc), 1)
  195. LIBC_SUPPORT := 1
  196. endif
  197. ifeq ($(BIONIC),1)
  198. LIBC_SUPPORT := 1
  199. endif
  200. ifeq ($(LIBC_SUPPORT),1)
  201. msg := $(warning No libelf found, disables 'probe' tool and BPF support in 'perf record', please install elfutils-libelf-devel/libelf-dev);
  202. NO_LIBELF := 1
  203. NO_DWARF := 1
  204. NO_DEMANGLE := 1
  205. NO_LIBUNWIND := 1
  206. NO_LIBDW_DWARF_UNWIND := 1
  207. NO_LIBBPF := 1
  208. else
  209. ifneq ($(filter s% -static%,$(LDFLAGS),),)
  210. msg := $(error No static glibc found, please install glibc-static);
  211. else
  212. msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
  213. endif
  214. endif
  215. else
  216. ifndef NO_LIBDW_DWARF_UNWIND
  217. ifneq ($(feature-libdw-dwarf-unwind),1)
  218. NO_LIBDW_DWARF_UNWIND := 1
  219. msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
  220. endif
  221. endif
  222. ifneq ($(feature-dwarf), 1)
  223. msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
  224. NO_DWARF := 1
  225. endif # Dwarf support
  226. endif # libelf support
  227. endif # NO_LIBELF
  228. ifdef NO_DWARF
  229. NO_LIBDW_DWARF_UNWIND := 1
  230. endif
  231. ifndef NO_LIBELF
  232. CFLAGS += -DHAVE_LIBELF_SUPPORT
  233. EXTLIBS += -lelf
  234. $(call detected,CONFIG_LIBELF)
  235. ifeq ($(feature-libelf-mmap), 1)
  236. CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
  237. endif
  238. ifeq ($(feature-libelf-getphdrnum), 1)
  239. CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
  240. endif
  241. # include ARCH specific config
  242. -include $(src-perf)/arch/$(ARCH)/Makefile
  243. ifndef NO_DWARF
  244. ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
  245. msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
  246. NO_DWARF := 1
  247. else
  248. CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
  249. LDFLAGS += $(LIBDW_LDFLAGS)
  250. DWARFLIBS := -ldw
  251. ifeq ($(findstring -static,${LDFLAGS}),-static)
  252. DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
  253. endif
  254. EXTLIBS += ${DWARFLIBS}
  255. $(call detected,CONFIG_DWARF)
  256. endif # PERF_HAVE_DWARF_REGS
  257. endif # NO_DWARF
  258. ifndef NO_LIBBPF
  259. ifeq ($(feature-bpf), 1)
  260. CFLAGS += -DHAVE_LIBBPF_SUPPORT
  261. $(call detected,CONFIG_LIBBPF)
  262. endif
  263. ifndef NO_DWARF
  264. ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
  265. CFLAGS += -DHAVE_BPF_PROLOGUE
  266. $(call detected,CONFIG_BPF_PROLOGUE)
  267. else
  268. msg := $(warning BPF prologue is not supported by architecture $(ARCH), missing regs_query_register_offset());
  269. endif
  270. else
  271. msg := $(warning DWARF support is off, BPF prologue is disabled);
  272. endif
  273. endif # NO_LIBBPF
  274. endif # NO_LIBELF
  275. ifdef PERF_HAVE_JITDUMP
  276. ifndef NO_DWARF
  277. $(call detected,CONFIG_JITDUMP)
  278. CFLAGS += -DHAVE_JITDUMP
  279. endif
  280. endif
  281. ifeq ($(ARCH),powerpc)
  282. ifndef NO_DWARF
  283. CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
  284. endif
  285. endif
  286. ifndef NO_LIBUNWIND
  287. ifneq ($(feature-libunwind), 1)
  288. msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
  289. NO_LIBUNWIND := 1
  290. endif
  291. endif
  292. ifndef NO_LIBBPF
  293. ifneq ($(feature-bpf), 1)
  294. msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
  295. NO_LIBBPF := 1
  296. endif
  297. endif
  298. dwarf-post-unwind := 1
  299. dwarf-post-unwind-text := BUG
  300. # setup DWARF post unwinder
  301. ifdef NO_LIBUNWIND
  302. ifdef NO_LIBDW_DWARF_UNWIND
  303. msg := $(warning Disabling post unwind, no support found.);
  304. dwarf-post-unwind := 0
  305. else
  306. dwarf-post-unwind-text := libdw
  307. $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
  308. endif
  309. else
  310. dwarf-post-unwind-text := libunwind
  311. $(call detected,CONFIG_LIBUNWIND)
  312. # Enable libunwind support by default.
  313. ifndef NO_LIBDW_DWARF_UNWIND
  314. NO_LIBDW_DWARF_UNWIND := 1
  315. endif
  316. endif
  317. ifeq ($(dwarf-post-unwind),1)
  318. CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
  319. $(call detected,CONFIG_DWARF_UNWIND)
  320. else
  321. NO_DWARF_UNWIND := 1
  322. endif
  323. ifndef NO_LIBUNWIND
  324. ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
  325. $(call feature_check,libunwind-debug-frame)
  326. ifneq ($(feature-libunwind-debug-frame), 1)
  327. msg := $(warning No debug_frame support found in libunwind);
  328. CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
  329. endif
  330. else
  331. # non-ARM has no dwarf_find_debug_frame() function:
  332. CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
  333. endif
  334. CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
  335. EXTLIBS += $(LIBUNWIND_LIBS)
  336. CFLAGS += $(LIBUNWIND_CFLAGS)
  337. LDFLAGS += $(LIBUNWIND_LDFLAGS)
  338. endif
  339. ifndef NO_LIBAUDIT
  340. ifneq ($(feature-libaudit), 1)
  341. msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
  342. NO_LIBAUDIT := 1
  343. else
  344. CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
  345. EXTLIBS += -laudit
  346. $(call detected,CONFIG_AUDIT)
  347. endif
  348. endif
  349. ifndef NO_LIBCRYPTO
  350. ifneq ($(feature-libcrypto), 1)
  351. msg := $(warning No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev);
  352. NO_LIBCRYPTO := 1
  353. else
  354. CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
  355. EXTLIBS += -lcrypto
  356. $(call detected,CONFIG_CRYPTO)
  357. endif
  358. endif
  359. ifdef NO_NEWT
  360. NO_SLANG=1
  361. endif
  362. ifndef NO_SLANG
  363. ifneq ($(feature-libslang), 1)
  364. msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
  365. NO_SLANG := 1
  366. else
  367. # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
  368. CFLAGS += -I/usr/include/slang
  369. CFLAGS += -DHAVE_SLANG_SUPPORT
  370. EXTLIBS += -lslang
  371. $(call detected,CONFIG_SLANG)
  372. endif
  373. endif
  374. ifndef NO_GTK2
  375. FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
  376. ifneq ($(feature-gtk2), 1)
  377. msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
  378. NO_GTK2 := 1
  379. else
  380. ifeq ($(feature-gtk2-infobar), 1)
  381. GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
  382. endif
  383. CFLAGS += -DHAVE_GTK2_SUPPORT
  384. GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
  385. GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
  386. EXTLIBS += -ldl
  387. endif
  388. endif
  389. grep-libs = $(filter -l%,$(1))
  390. strip-libs = $(filter-out -l%,$(1))
  391. ifdef NO_LIBPERL
  392. CFLAGS += -DNO_LIBPERL
  393. else
  394. PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
  395. PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
  396. PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
  397. PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
  398. FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
  399. ifneq ($(feature-libperl), 1)
  400. CFLAGS += -DNO_LIBPERL
  401. NO_LIBPERL := 1
  402. msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
  403. else
  404. LDFLAGS += $(PERL_EMBED_LDFLAGS)
  405. EXTLIBS += $(PERL_EMBED_LIBADD)
  406. $(call detected,CONFIG_LIBPERL)
  407. endif
  408. endif
  409. ifeq ($(feature-timerfd), 1)
  410. CFLAGS += -DHAVE_TIMERFD_SUPPORT
  411. else
  412. msg := $(warning No timerfd support. Disables 'perf kvm stat live');
  413. endif
  414. disable-python = $(eval $(disable-python_code))
  415. define disable-python_code
  416. CFLAGS += -DNO_LIBPYTHON
  417. $(warning $1)
  418. NO_LIBPYTHON := 1
  419. endef
  420. ifdef NO_LIBPYTHON
  421. $(call disable-python,Python support disabled by user)
  422. else
  423. ifndef PYTHON
  424. $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
  425. else
  426. PYTHON_WORD := $(call shell-wordify,$(PYTHON))
  427. ifndef PYTHON_CONFIG
  428. $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
  429. else
  430. PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
  431. PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
  432. PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
  433. PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
  434. PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
  435. FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
  436. ifneq ($(feature-libpython), 1)
  437. $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
  438. else
  439. ifneq ($(feature-libpython-version), 1)
  440. $(warning Python 3 is not yet supported; please set)
  441. $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
  442. $(warning If you also have Python 2 installed, then)
  443. $(warning try something like:)
  444. $(warning $(and ,))
  445. $(warning $(and ,) make PYTHON=python2)
  446. $(warning $(and ,))
  447. $(warning Otherwise, disable Python support entirely:)
  448. $(warning $(and ,))
  449. $(warning $(and ,) make NO_LIBPYTHON=1)
  450. $(warning $(and ,))
  451. $(error $(and ,))
  452. else
  453. LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
  454. EXTLIBS += $(PYTHON_EMBED_LIBADD)
  455. LANG_BINDINGS += $(obj-perf)python/perf.so
  456. $(call detected,CONFIG_LIBPYTHON)
  457. endif
  458. endif
  459. endif
  460. endif
  461. endif
  462. ifeq ($(feature-libbfd), 1)
  463. EXTLIBS += -lbfd
  464. # call all detections now so we get correct
  465. # status in VF output
  466. $(call feature_check,liberty)
  467. $(call feature_check,liberty-z)
  468. $(call feature_check,cplus-demangle)
  469. ifeq ($(feature-liberty), 1)
  470. EXTLIBS += -liberty
  471. else
  472. ifeq ($(feature-liberty-z), 1)
  473. EXTLIBS += -liberty -lz
  474. endif
  475. endif
  476. endif
  477. ifdef NO_DEMANGLE
  478. CFLAGS += -DNO_DEMANGLE
  479. else
  480. ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
  481. EXTLIBS += -liberty
  482. CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
  483. else
  484. ifneq ($(feature-libbfd), 1)
  485. ifneq ($(feature-liberty), 1)
  486. ifneq ($(feature-liberty-z), 1)
  487. # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
  488. # or any of 'bfd iberty z' trinity
  489. ifeq ($(feature-cplus-demangle), 1)
  490. EXTLIBS += -liberty
  491. CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
  492. else
  493. msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
  494. CFLAGS += -DNO_DEMANGLE
  495. endif
  496. endif
  497. endif
  498. endif
  499. endif
  500. endif
  501. ifneq ($(filter -lbfd,$(EXTLIBS)),)
  502. CFLAGS += -DHAVE_LIBBFD_SUPPORT
  503. endif
  504. ifndef NO_ZLIB
  505. ifeq ($(feature-zlib), 1)
  506. CFLAGS += -DHAVE_ZLIB_SUPPORT
  507. EXTLIBS += -lz
  508. $(call detected,CONFIG_ZLIB)
  509. else
  510. NO_ZLIB := 1
  511. endif
  512. endif
  513. ifndef NO_LZMA
  514. ifeq ($(feature-lzma), 1)
  515. CFLAGS += -DHAVE_LZMA_SUPPORT
  516. EXTLIBS += -llzma
  517. $(call detected,CONFIG_LZMA)
  518. else
  519. msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
  520. NO_LZMA := 1
  521. endif
  522. endif
  523. ifndef NO_BACKTRACE
  524. ifeq ($(feature-backtrace), 1)
  525. CFLAGS += -DHAVE_BACKTRACE_SUPPORT
  526. endif
  527. endif
  528. ifndef NO_LIBNUMA
  529. ifeq ($(feature-libnuma), 0)
  530. msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
  531. NO_LIBNUMA := 1
  532. else
  533. ifeq ($(feature-numa_num_possible_cpus), 0)
  534. msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
  535. NO_LIBNUMA := 1
  536. else
  537. CFLAGS += -DHAVE_LIBNUMA_SUPPORT
  538. EXTLIBS += -lnuma
  539. $(call detected,CONFIG_NUMA)
  540. endif
  541. endif
  542. endif
  543. ifdef HAVE_KVM_STAT_SUPPORT
  544. CFLAGS += -DHAVE_KVM_STAT_SUPPORT
  545. endif
  546. ifeq (${IS_64_BIT}, 1)
  547. ifndef NO_PERF_READ_VDSO32
  548. $(call feature_check,compile-32)
  549. ifeq ($(feature-compile-32), 1)
  550. CFLAGS += -DHAVE_PERF_READ_VDSO32
  551. else
  552. NO_PERF_READ_VDSO32 := 1
  553. endif
  554. endif
  555. ifneq ($(ARCH), x86)
  556. NO_PERF_READ_VDSOX32 := 1
  557. endif
  558. ifndef NO_PERF_READ_VDSOX32
  559. $(call feature_check,compile-x32)
  560. ifeq ($(feature-compile-x32), 1)
  561. CFLAGS += -DHAVE_PERF_READ_VDSOX32
  562. else
  563. NO_PERF_READ_VDSOX32 := 1
  564. endif
  565. endif
  566. else
  567. NO_PERF_READ_VDSO32 := 1
  568. NO_PERF_READ_VDSOX32 := 1
  569. endif
  570. ifdef LIBBABELTRACE
  571. $(call feature_check,libbabeltrace)
  572. ifeq ($(feature-libbabeltrace), 1)
  573. CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
  574. LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
  575. EXTLIBS += -lbabeltrace-ctf
  576. $(call detected,CONFIG_LIBBABELTRACE)
  577. else
  578. msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
  579. endif
  580. endif
  581. ifndef NO_AUXTRACE
  582. ifeq ($(feature-get_cpuid), 0)
  583. msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
  584. NO_AUXTRACE := 1
  585. else
  586. $(call detected,CONFIG_AUXTRACE)
  587. CFLAGS += -DHAVE_AUXTRACE_SUPPORT
  588. endif
  589. endif
  590. # Among the variables below, these:
  591. # perfexecdir
  592. # template_dir
  593. # mandir
  594. # infodir
  595. # htmldir
  596. # ETC_PERFCONFIG (but not sysconfdir)
  597. # can be specified as a relative path some/where/else;
  598. # this is interpreted as relative to $(prefix) and "perf" at
  599. # runtime figures out where they are based on the path to the executable.
  600. # This can help installing the suite in a relocatable way.
  601. # Make the path relative to DESTDIR, not to prefix
  602. ifndef DESTDIR
  603. prefix ?= $(HOME)
  604. endif
  605. bindir_relative = bin
  606. bindir = $(abspath $(prefix)/$(bindir_relative))
  607. mandir = share/man
  608. infodir = share/info
  609. perfexecdir = libexec/perf-core
  610. sharedir = $(prefix)/share
  611. template_dir = share/perf-core/templates
  612. STRACE_GROUPS_DIR = share/perf-core/strace/groups
  613. htmldir = share/doc/perf-doc
  614. tipdir = share/doc/perf-tip
  615. srcdir = $(srctree)/tools/perf
  616. ifeq ($(prefix),/usr)
  617. sysconfdir = /etc
  618. ETC_PERFCONFIG = $(sysconfdir)/perfconfig
  619. else
  620. sysconfdir = $(prefix)/etc
  621. ETC_PERFCONFIG = etc/perfconfig
  622. endif
  623. ifndef lib
  624. ifeq ($(ARCH)$(IS_64_BIT), x861)
  625. lib = lib64
  626. else
  627. lib = lib
  628. endif
  629. endif # lib
  630. libdir = $(prefix)/$(lib)
  631. # Shell quote (do not use $(call) to accommodate ancient setups);
  632. ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
  633. STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
  634. DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  635. bindir_SQ = $(subst ','\'',$(bindir))
  636. mandir_SQ = $(subst ','\'',$(mandir))
  637. infodir_SQ = $(subst ','\'',$(infodir))
  638. perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
  639. template_dir_SQ = $(subst ','\'',$(template_dir))
  640. htmldir_SQ = $(subst ','\'',$(htmldir))
  641. tipdir_SQ = $(subst ','\'',$(tipdir))
  642. prefix_SQ = $(subst ','\'',$(prefix))
  643. sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
  644. libdir_SQ = $(subst ','\'',$(libdir))
  645. srcdir_SQ = $(subst ','\'',$(srcdir))
  646. ifneq ($(filter /%,$(firstword $(perfexecdir))),)
  647. perfexec_instdir = $(perfexecdir)
  648. STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
  649. tip_instdir = $(tipdir)
  650. else
  651. perfexec_instdir = $(prefix)/$(perfexecdir)
  652. STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
  653. tip_instdir = $(prefix)/$(tipdir)
  654. endif
  655. perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
  656. STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
  657. tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
  658. # If we install to $(HOME) we keep the traceevent default:
  659. # $(HOME)/.traceevent/plugins
  660. # Otherwise we install plugins into the global $(libdir).
  661. ifdef DESTDIR
  662. plugindir=$(libdir)/traceevent/plugins
  663. plugindir_SQ= $(subst ','\'',$(plugindir))
  664. endif
  665. print_var = $(eval $(print_var_code)) $(info $(MSG))
  666. define print_var_code
  667. MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
  668. endef
  669. ifeq ($(VF),1)
  670. $(call print_var,prefix)
  671. $(call print_var,bindir)
  672. $(call print_var,libdir)
  673. $(call print_var,sysconfdir)
  674. $(call print_var,LIBUNWIND_DIR)
  675. $(call print_var,LIBDW_DIR)
  676. ifeq ($(dwarf-post-unwind),1)
  677. $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
  678. endif
  679. $(info )
  680. endif
  681. $(call detected_var,bindir_SQ)
  682. $(call detected_var,PYTHON_WORD)
  683. ifneq ($(OUTPUT),)
  684. $(call detected_var,OUTPUT)
  685. endif
  686. $(call detected_var,htmldir_SQ)
  687. $(call detected_var,infodir_SQ)
  688. $(call detected_var,mandir_SQ)
  689. $(call detected_var,ETC_PERFCONFIG_SQ)
  690. $(call detected_var,STRACE_GROUPS_DIR_SQ)
  691. $(call detected_var,prefix_SQ)
  692. $(call detected_var,perfexecdir_SQ)
  693. $(call detected_var,tipdir_SQ)
  694. $(call detected_var,srcdir_SQ)
  695. $(call detected_var,LIBDIR)
  696. $(call detected_var,GTK_CFLAGS)
  697. $(call detected_var,PERL_EMBED_CCOPTS)
  698. $(call detected_var,PYTHON_EMBED_CCOPTS)