Makefile.config 28 KB

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