Makefile.config 25 KB

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