Makefile 21 KB

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