Makefile.config 27 KB

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