Makefile 20 KB

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