Makefile.config 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. ifeq ($(src-perf),)
  3. src-perf := $(srctree)/tools/perf
  4. endif
  5. ifeq ($(obj-perf),)
  6. obj-perf := $(OUTPUT)
  7. endif
  8. ifneq ($(obj-perf),)
  9. obj-perf := $(abspath $(obj-perf))/
  10. endif
  11. $(shell printf "" > $(OUTPUT).config-detected)
  12. detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
  13. detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
  14. CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
  15. include $(srctree)/tools/scripts/Makefile.arch
  16. $(call detected_var,SRCARCH)
  17. NO_PERF_REGS := 1
  18. ifneq ($(NO_SYSCALL_TABLE),1)
  19. NO_SYSCALL_TABLE := 1
  20. ifeq ($(SRCARCH),x86)
  21. ifeq (${IS_64_BIT}, 1)
  22. NO_SYSCALL_TABLE := 0
  23. endif
  24. else
  25. ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390))
  26. NO_SYSCALL_TABLE := 0
  27. endif
  28. endif
  29. ifneq ($(NO_SYSCALL_TABLE),1)
  30. CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT
  31. endif
  32. endif
  33. # Additional ARCH settings for ppc
  34. ifeq ($(SRCARCH),powerpc)
  35. NO_PERF_REGS := 0
  36. CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated
  37. LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
  38. endif
  39. # Additional ARCH settings for x86
  40. ifeq ($(SRCARCH),x86)
  41. $(call detected,CONFIG_X86)
  42. ifeq (${IS_64_BIT}, 1)
  43. CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated
  44. ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
  45. LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
  46. $(call detected,CONFIG_X86_64)
  47. else
  48. LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
  49. endif
  50. NO_PERF_REGS := 0
  51. endif
  52. ifeq ($(SRCARCH),arm)
  53. NO_PERF_REGS := 0
  54. LIBUNWIND_LIBS = -lunwind -lunwind-arm
  55. endif
  56. ifeq ($(SRCARCH),arm64)
  57. NO_PERF_REGS := 0
  58. CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
  59. LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
  60. endif
  61. ifeq ($(SRCARCH),riscv)
  62. NO_PERF_REGS := 0
  63. endif
  64. ifeq ($(SRCARCH),csky)
  65. NO_PERF_REGS := 0
  66. endif
  67. ifeq ($(ARCH),s390)
  68. NO_PERF_REGS := 0
  69. CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
  70. endif
  71. ifeq ($(NO_PERF_REGS),0)
  72. $(call detected,CONFIG_PERF_REGS)
  73. endif
  74. # So far there's only x86 and arm libdw unwind support merged in perf.
  75. # Disable it on all other architectures in case libdw unwind
  76. # support is detected in system. Add supported architectures
  77. # to the check.
  78. ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv))
  79. NO_LIBDW_DWARF_UNWIND := 1
  80. endif
  81. ifeq ($(LIBUNWIND_LIBS),)
  82. NO_LIBUNWIND := 1
  83. endif
  84. #
  85. # For linking with debug library, run like:
  86. #
  87. # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
  88. #
  89. libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
  90. define libunwind_arch_set_flags_code
  91. FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
  92. FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib
  93. endef
  94. ifdef LIBUNWIND_DIR
  95. LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
  96. LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
  97. LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64
  98. $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
  99. endif
  100. # Set per-feature check compilation flags
  101. FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
  102. FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
  103. FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
  104. FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
  105. FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm
  106. FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
  107. FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
  108. FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
  109. FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
  110. ifdef CSINCLUDES
  111. LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
  112. endif
  113. OPENCSDLIBS := -lopencsd_c_api -lopencsd
  114. ifdef CSLIBS
  115. LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
  116. endif
  117. FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)
  118. FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)
  119. ifeq ($(NO_PERF_REGS),0)
  120. CFLAGS += -DHAVE_PERF_REGS_SUPPORT
  121. endif
  122. # for linking with debug library, run like:
  123. # make DEBUG=1 LIBDW_DIR=/opt/libdw/
  124. ifdef LIBDW_DIR
  125. LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
  126. LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
  127. endif
  128. DWARFLIBS := -ldw
  129. ifeq ($(findstring -static,${LDFLAGS}),-static)
  130. DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
  131. endif
  132. FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
  133. FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
  134. # for linking with debug library, run like:
  135. # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
  136. ifdef LIBBABELTRACE_DIR
  137. LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
  138. LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
  139. endif
  140. FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
  141. FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
  142. ifdef LIBZSTD_DIR
  143. LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib
  144. LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
  145. endif
  146. FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
  147. FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
  148. FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
  149. # include ARCH specific config
  150. -include $(src-perf)/arch/$(SRCARCH)/Makefile
  151. ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
  152. CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
  153. endif
  154. include $(srctree)/tools/scripts/utilities.mak
  155. ifeq ($(call get-executable,$(FLEX)),)
  156. dummy := $(error Error: $(FLEX) is missing on this system, please install it)
  157. endif
  158. ifeq ($(call get-executable,$(BISON)),)
  159. dummy := $(error Error: $(BISON) is missing on this system, please install it)
  160. endif
  161. # Treat warnings as errors unless directed not to
  162. ifneq ($(WERROR),0)
  163. CORE_CFLAGS += -Werror
  164. CXXFLAGS += -Werror
  165. endif
  166. ifndef DEBUG
  167. DEBUG := 0
  168. endif
  169. ifeq ($(DEBUG),0)
  170. ifeq ($(CC_NO_CLANG), 0)
  171. CORE_CFLAGS += -O3
  172. else
  173. CORE_CFLAGS += -O6
  174. endif
  175. endif
  176. ifdef PARSER_DEBUG
  177. PARSER_DEBUG_BISON := -t
  178. PARSER_DEBUG_FLEX := -d
  179. CFLAGS += -DPARSER_DEBUG
  180. $(call detected_var,PARSER_DEBUG_BISON)
  181. $(call detected_var,PARSER_DEBUG_FLEX)
  182. endif
  183. # Try different combinations to accommodate systems that only have
  184. # python[2][-config] in weird combinations but always preferring
  185. # python2 and python2-config as per pep-0394. If python2 or python
  186. # aren't found, then python3 is used.
  187. PYTHON_AUTO := python
  188. PYTHON_AUTO := $(if $(call get-executable,python3),python3,$(PYTHON_AUTO))
  189. PYTHON_AUTO := $(if $(call get-executable,python),python,$(PYTHON_AUTO))
  190. PYTHON_AUTO := $(if $(call get-executable,python2),python2,$(PYTHON_AUTO))
  191. override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON_AUTO))
  192. PYTHON_AUTO_CONFIG := \
  193. $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
  194. override PYTHON_CONFIG := \
  195. $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO_CONFIG))
  196. grep-libs = $(filter -l%,$(1))
  197. strip-libs = $(filter-out -l%,$(1))
  198. PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
  199. # Python 3.8 changed the output of `python-config --ldflags` to not include the
  200. # '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
  201. # libpython fails if that flag is not included in LDFLAGS
  202. ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
  203. PYTHON_CONFIG_LDFLAGS := --ldflags --embed
  204. else
  205. PYTHON_CONFIG_LDFLAGS := --ldflags
  206. endif
  207. ifdef PYTHON_CONFIG
  208. PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
  209. PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
  210. PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
  211. PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
  212. FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
  213. ifeq ($(CC_NO_CLANG), 0)
  214. PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS))
  215. endif
  216. endif
  217. FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
  218. FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
  219. FEATURE_CHECK_LDFLAGS-libaio = -lrt
  220. FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
  221. CORE_CFLAGS += -fno-omit-frame-pointer
  222. CORE_CFLAGS += -ggdb3
  223. CORE_CFLAGS += -funwind-tables
  224. CORE_CFLAGS += -Wall
  225. CORE_CFLAGS += -Wextra
  226. CORE_CFLAGS += -std=gnu99
  227. CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
  228. CXXFLAGS += -Wall
  229. CXXFLAGS += -fno-omit-frame-pointer
  230. CXXFLAGS += -ggdb3
  231. CXXFLAGS += -funwind-tables
  232. CXXFLAGS += -Wno-strict-aliasing
  233. # Enforce a non-executable stack, as we may regress (again) in the future by
  234. # adding assembler files missing the .GNU-stack linker note.
  235. LDFLAGS += -Wl,-z,noexecstack
  236. EXTLIBS = -lpthread -lrt -lm -ldl
  237. ifneq ($(TCMALLOC),)
  238. CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
  239. EXTLIBS += -ltcmalloc
  240. endif
  241. ifeq ($(FEATURES_DUMP),)
  242. include $(srctree)/tools/build/Makefile.feature
  243. else
  244. include $(FEATURES_DUMP)
  245. endif
  246. ifeq ($(feature-stackprotector-all), 1)
  247. CORE_CFLAGS += -fstack-protector-all
  248. endif
  249. ifeq ($(DEBUG),0)
  250. ifeq ($(feature-fortify-source), 1)
  251. CORE_CFLAGS += -D_FORTIFY_SOURCE=2
  252. endif
  253. endif
  254. INC_FLAGS += -I$(srctree)/tools/lib/perf/include
  255. INC_FLAGS += -I$(src-perf)/util/include
  256. INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
  257. INC_FLAGS += -I$(srctree)/tools/include/
  258. INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
  259. INC_FLAGS += -I$(srctree)/tools/include/uapi
  260. INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
  261. INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
  262. # $(obj-perf) for generated common-cmds.h
  263. # $(obj-perf)/util for generated bison/flex headers
  264. ifneq ($(OUTPUT),)
  265. INC_FLAGS += -I$(obj-perf)/util
  266. INC_FLAGS += -I$(obj-perf)
  267. endif
  268. INC_FLAGS += -I$(src-perf)/util
  269. INC_FLAGS += -I$(src-perf)
  270. INC_FLAGS += -I$(srctree)/tools/lib/
  271. CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
  272. CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)
  273. CXXFLAGS += $(INC_FLAGS)
  274. LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)
  275. ifeq ($(feature-sync-compare-and-swap), 1)
  276. CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
  277. endif
  278. ifeq ($(feature-pthread-attr-setaffinity-np), 1)
  279. CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
  280. endif
  281. ifeq ($(feature-pthread-barrier), 1)
  282. CFLAGS += -DHAVE_PTHREAD_BARRIER
  283. endif
  284. ifndef NO_BIONIC
  285. $(call feature_check,bionic)
  286. ifeq ($(feature-bionic), 1)
  287. BIONIC := 1
  288. CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
  289. CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
  290. EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
  291. EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
  292. endif
  293. endif
  294. ifeq ($(feature-eventfd), 1)
  295. CFLAGS += -DHAVE_EVENTFD_SUPPORT
  296. endif
  297. ifeq ($(feature-get_current_dir_name), 1)
  298. CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
  299. endif
  300. ifeq ($(feature-gettid), 1)
  301. CFLAGS += -DHAVE_GETTID
  302. endif
  303. ifeq ($(feature-file-handle), 1)
  304. CFLAGS += -DHAVE_FILE_HANDLE
  305. endif
  306. ifdef NO_LIBELF
  307. NO_DWARF := 1
  308. NO_DEMANGLE := 1
  309. NO_LIBUNWIND := 1
  310. NO_LIBDW_DWARF_UNWIND := 1
  311. NO_LIBBPF := 1
  312. NO_JVMTI := 1
  313. else
  314. ifeq ($(feature-libelf), 0)
  315. ifeq ($(feature-glibc), 1)
  316. LIBC_SUPPORT := 1
  317. endif
  318. ifeq ($(BIONIC),1)
  319. LIBC_SUPPORT := 1
  320. endif
  321. ifeq ($(LIBC_SUPPORT),1)
  322. 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);
  323. NO_LIBELF := 1
  324. NO_DWARF := 1
  325. NO_DEMANGLE := 1
  326. NO_LIBUNWIND := 1
  327. NO_LIBDW_DWARF_UNWIND := 1
  328. NO_LIBBPF := 1
  329. NO_JVMTI := 1
  330. else
  331. ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)
  332. ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)
  333. msg := $(error No libasan found, please install libasan);
  334. endif
  335. endif
  336. ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),)
  337. ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0)
  338. msg := $(error No libubsan found, please install libubsan);
  339. endif
  340. endif
  341. ifneq ($(filter s% -static%,$(LDFLAGS),),)
  342. msg := $(error No static glibc found, please install glibc-static);
  343. else
  344. msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
  345. endif
  346. endif
  347. else
  348. ifndef NO_LIBDW_DWARF_UNWIND
  349. ifneq ($(feature-libdw-dwarf-unwind),1)
  350. NO_LIBDW_DWARF_UNWIND := 1
  351. msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
  352. endif
  353. endif
  354. ifneq ($(feature-dwarf), 1)
  355. ifndef NO_DWARF
  356. 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);
  357. NO_DWARF := 1
  358. endif
  359. else
  360. ifneq ($(feature-dwarf_getlocations), 1)
  361. msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
  362. else
  363. CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
  364. endif # dwarf_getlocations
  365. endif # Dwarf support
  366. endif # libelf support
  367. endif # NO_LIBELF
  368. ifeq ($(feature-glibc), 1)
  369. CFLAGS += -DHAVE_GLIBC_SUPPORT
  370. endif
  371. ifeq ($(feature-libaio), 1)
  372. ifndef NO_AIO
  373. CFLAGS += -DHAVE_AIO_SUPPORT
  374. endif
  375. endif
  376. ifdef NO_DWARF
  377. NO_LIBDW_DWARF_UNWIND := 1
  378. endif
  379. ifeq ($(feature-sched_getcpu), 1)
  380. CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
  381. endif
  382. ifeq ($(feature-setns), 1)
  383. CFLAGS += -DHAVE_SETNS_SUPPORT
  384. $(call detected,CONFIG_SETNS)
  385. endif
  386. ifdef CORESIGHT
  387. $(call feature_check,libopencsd)
  388. ifeq ($(feature-libopencsd), 1)
  389. CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
  390. ifeq ($(feature-reallocarray), 0)
  391. CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
  392. endif
  393. LDFLAGS += $(LIBOPENCSD_LDFLAGS)
  394. EXTLIBS += $(OPENCSDLIBS)
  395. $(call detected,CONFIG_LIBOPENCSD)
  396. ifdef CSTRACE_RAW
  397. CFLAGS += -DCS_DEBUG_RAW
  398. ifeq (${CSTRACE_RAW}, packed)
  399. CFLAGS += -DCS_RAW_PACKED
  400. endif
  401. endif
  402. endif
  403. endif
  404. ifndef NO_LIBELF
  405. CFLAGS += -DHAVE_LIBELF_SUPPORT
  406. EXTLIBS += -lelf
  407. $(call detected,CONFIG_LIBELF)
  408. ifeq ($(feature-libelf-getphdrnum), 1)
  409. CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
  410. endif
  411. ifeq ($(feature-libelf-gelf_getnote), 1)
  412. CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
  413. else
  414. msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
  415. endif
  416. ifeq ($(feature-libelf-getshdrstrndx), 1)
  417. CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
  418. endif
  419. ifndef NO_LIBDEBUGINFOD
  420. $(call feature_check,libdebuginfod)
  421. ifeq ($(feature-libdebuginfod), 1)
  422. CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT
  423. EXTLIBS += -ldebuginfod
  424. endif
  425. endif
  426. ifndef NO_DWARF
  427. ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
  428. msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
  429. NO_DWARF := 1
  430. else
  431. CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
  432. LDFLAGS += $(LIBDW_LDFLAGS)
  433. EXTLIBS += ${DWARFLIBS}
  434. $(call detected,CONFIG_DWARF)
  435. endif # PERF_HAVE_DWARF_REGS
  436. endif # NO_DWARF
  437. ifndef NO_LIBBPF
  438. ifeq ($(feature-bpf), 1)
  439. CFLAGS += -DHAVE_LIBBPF_SUPPORT
  440. $(call detected,CONFIG_LIBBPF)
  441. # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status
  442. $(call feature_check,libbpf)
  443. ifdef LIBBPF_DYNAMIC
  444. ifeq ($(feature-libbpf), 1)
  445. EXTLIBS += -lbpf
  446. $(call detected,CONFIG_LIBBPF_DYNAMIC)
  447. else
  448. dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
  449. endif
  450. endif
  451. endif
  452. ifndef NO_DWARF
  453. ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
  454. CFLAGS += -DHAVE_BPF_PROLOGUE
  455. $(call detected,CONFIG_BPF_PROLOGUE)
  456. else
  457. msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
  458. endif
  459. else
  460. msg := $(warning DWARF support is off, BPF prologue is disabled);
  461. endif
  462. endif # NO_LIBBPF
  463. endif # NO_LIBELF
  464. ifndef NO_SDT
  465. ifneq ($(feature-sdt), 1)
  466. msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
  467. NO_SDT := 1;
  468. else
  469. CFLAGS += -DHAVE_SDT_EVENT
  470. $(call detected,CONFIG_SDT_EVENT)
  471. endif
  472. endif
  473. ifdef PERF_HAVE_JITDUMP
  474. ifndef NO_LIBELF
  475. $(call detected,CONFIG_JITDUMP)
  476. CFLAGS += -DHAVE_JITDUMP
  477. endif
  478. endif
  479. ifeq ($(SRCARCH),powerpc)
  480. ifndef NO_DWARF
  481. CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
  482. endif
  483. endif
  484. ifndef NO_LIBUNWIND
  485. have_libunwind :=
  486. $(call feature_check,libunwind-x86)
  487. ifeq ($(feature-libunwind-x86), 1)
  488. $(call detected,CONFIG_LIBUNWIND_X86)
  489. CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
  490. LDFLAGS += -lunwind-x86
  491. EXTLIBS_LIBUNWIND += -lunwind-x86
  492. have_libunwind = 1
  493. endif
  494. $(call feature_check,libunwind-aarch64)
  495. ifeq ($(feature-libunwind-aarch64), 1)
  496. $(call detected,CONFIG_LIBUNWIND_AARCH64)
  497. CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
  498. LDFLAGS += -lunwind-aarch64
  499. EXTLIBS_LIBUNWIND += -lunwind-aarch64
  500. have_libunwind = 1
  501. $(call feature_check,libunwind-debug-frame-aarch64)
  502. ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
  503. msg := $(warning No debug_frame support found in libunwind-aarch64);
  504. CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
  505. endif
  506. endif
  507. ifneq ($(feature-libunwind), 1)
  508. msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
  509. NO_LOCAL_LIBUNWIND := 1
  510. else
  511. have_libunwind := 1
  512. $(call detected,CONFIG_LOCAL_LIBUNWIND)
  513. endif
  514. ifneq ($(have_libunwind), 1)
  515. NO_LIBUNWIND := 1
  516. endif
  517. else
  518. NO_LOCAL_LIBUNWIND := 1
  519. endif
  520. ifndef NO_LIBBPF
  521. ifneq ($(feature-bpf), 1)
  522. msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
  523. NO_LIBBPF := 1
  524. endif
  525. endif
  526. dwarf-post-unwind := 1
  527. dwarf-post-unwind-text := BUG
  528. # setup DWARF post unwinder
  529. ifdef NO_LIBUNWIND
  530. ifdef NO_LIBDW_DWARF_UNWIND
  531. msg := $(warning Disabling post unwind, no support found.);
  532. dwarf-post-unwind := 0
  533. else
  534. dwarf-post-unwind-text := libdw
  535. $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
  536. endif
  537. else
  538. dwarf-post-unwind-text := libunwind
  539. $(call detected,CONFIG_LIBUNWIND)
  540. # Enable libunwind support by default.
  541. ifndef NO_LIBDW_DWARF_UNWIND
  542. NO_LIBDW_DWARF_UNWIND := 1
  543. endif
  544. endif
  545. ifeq ($(dwarf-post-unwind),1)
  546. CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
  547. $(call detected,CONFIG_DWARF_UNWIND)
  548. else
  549. NO_DWARF_UNWIND := 1
  550. endif
  551. ifndef NO_LOCAL_LIBUNWIND
  552. ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
  553. $(call feature_check,libunwind-debug-frame)
  554. ifneq ($(feature-libunwind-debug-frame), 1)
  555. msg := $(warning No debug_frame support found in libunwind);
  556. CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
  557. endif
  558. else
  559. # non-ARM has no dwarf_find_debug_frame() function:
  560. CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
  561. endif
  562. EXTLIBS += $(LIBUNWIND_LIBS)
  563. LDFLAGS += $(LIBUNWIND_LIBS)
  564. endif
  565. ifeq ($(findstring -static,${LDFLAGS}),-static)
  566. # gcc -static links libgcc_eh which contans piece of libunwind
  567. LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
  568. endif
  569. ifndef NO_LIBUNWIND
  570. CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
  571. CFLAGS += $(LIBUNWIND_CFLAGS)
  572. LDFLAGS += $(LIBUNWIND_LDFLAGS)
  573. EXTLIBS += $(EXTLIBS_LIBUNWIND)
  574. endif
  575. ifeq ($(NO_SYSCALL_TABLE),0)
  576. $(call detected,CONFIG_TRACE)
  577. else
  578. ifndef NO_LIBAUDIT
  579. $(call feature_check,libaudit)
  580. ifneq ($(feature-libaudit), 1)
  581. msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
  582. NO_LIBAUDIT := 1
  583. else
  584. CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
  585. EXTLIBS += -laudit
  586. $(call detected,CONFIG_TRACE)
  587. endif
  588. endif
  589. endif
  590. ifndef NO_LIBCRYPTO
  591. ifneq ($(feature-libcrypto), 1)
  592. msg := $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev);
  593. NO_LIBCRYPTO := 1
  594. else
  595. CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
  596. EXTLIBS += -lcrypto
  597. $(call detected,CONFIG_CRYPTO)
  598. endif
  599. endif
  600. ifdef NO_NEWT
  601. NO_SLANG=1
  602. endif
  603. ifndef NO_SLANG
  604. ifneq ($(feature-libslang), 1)
  605. ifneq ($(feature-libslang-include-subdir), 1)
  606. msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
  607. NO_SLANG := 1
  608. else
  609. CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR
  610. endif
  611. endif
  612. ifndef NO_SLANG
  613. # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
  614. CFLAGS += -DHAVE_SLANG_SUPPORT
  615. EXTLIBS += -lslang
  616. $(call detected,CONFIG_SLANG)
  617. endif
  618. endif
  619. ifdef GTK2
  620. FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
  621. $(call feature_check,gtk2)
  622. ifneq ($(feature-gtk2), 1)
  623. msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
  624. NO_GTK2 := 1
  625. else
  626. $(call feature_check,gtk2-infobar)
  627. ifeq ($(feature-gtk2-infobar), 1)
  628. GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
  629. endif
  630. CFLAGS += -DHAVE_GTK2_SUPPORT
  631. GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
  632. GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
  633. EXTLIBS += -ldl
  634. endif
  635. endif
  636. ifdef NO_LIBPERL
  637. CFLAGS += -DNO_LIBPERL
  638. else
  639. PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
  640. PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
  641. PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
  642. PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
  643. PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
  644. PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
  645. PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
  646. FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
  647. ifneq ($(feature-libperl), 1)
  648. CFLAGS += -DNO_LIBPERL
  649. NO_LIBPERL := 1
  650. msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
  651. else
  652. LDFLAGS += $(PERL_EMBED_LDFLAGS)
  653. EXTLIBS += $(PERL_EMBED_LIBADD)
  654. CFLAGS += -DHAVE_LIBPERL_SUPPORT
  655. ifeq ($(CC_NO_CLANG), 0)
  656. CFLAGS += -Wno-compound-token-split-by-macro
  657. endif
  658. $(call detected,CONFIG_LIBPERL)
  659. endif
  660. endif
  661. ifeq ($(feature-timerfd), 1)
  662. CFLAGS += -DHAVE_TIMERFD_SUPPORT
  663. else
  664. msg := $(warning No timerfd support. Disables 'perf kvm stat live');
  665. endif
  666. disable-python = $(eval $(disable-python_code))
  667. define disable-python_code
  668. CFLAGS += -DNO_LIBPYTHON
  669. $(warning $1)
  670. NO_LIBPYTHON := 1
  671. endef
  672. ifdef NO_LIBPYTHON
  673. $(call disable-python,Python support disabled by user)
  674. else
  675. ifndef PYTHON
  676. $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
  677. else
  678. PYTHON_WORD := $(call shell-wordify,$(PYTHON))
  679. ifndef PYTHON_CONFIG
  680. $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
  681. else
  682. ifneq ($(feature-libpython), 1)
  683. $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
  684. else
  685. LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
  686. EXTLIBS += $(PYTHON_EMBED_LIBADD)
  687. LANG_BINDINGS += $(obj-perf)python/perf.so
  688. CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
  689. $(call detected,CONFIG_LIBPYTHON)
  690. endif
  691. endif
  692. endif
  693. endif
  694. ifeq ($(feature-libbfd), 1)
  695. EXTLIBS += -lbfd -lopcodes
  696. else
  697. # we are on a system that requires -liberty and (maybe) -lz
  698. # to link against -lbfd; test each case individually here
  699. # call all detections now so we get correct
  700. # status in VF output
  701. $(call feature_check,libbfd-liberty)
  702. $(call feature_check,libbfd-liberty-z)
  703. ifeq ($(feature-libbfd-liberty), 1)
  704. EXTLIBS += -lbfd -lopcodes -liberty
  705. FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
  706. else
  707. ifeq ($(feature-libbfd-liberty-z), 1)
  708. EXTLIBS += -lbfd -lopcodes -liberty -lz
  709. FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
  710. endif
  711. endif
  712. $(call feature_check,disassembler-four-args)
  713. endif
  714. ifeq ($(feature-libbfd-buildid), 1)
  715. CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
  716. else
  717. msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available);
  718. endif
  719. ifdef NO_DEMANGLE
  720. CFLAGS += -DNO_DEMANGLE
  721. else
  722. ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
  723. EXTLIBS += -liberty
  724. else
  725. ifeq ($(filter -liberty,$(EXTLIBS)),)
  726. $(call feature_check,cplus-demangle)
  727. # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
  728. # or any of 'bfd iberty z' trinity
  729. ifeq ($(feature-cplus-demangle), 1)
  730. EXTLIBS += -liberty
  731. else
  732. msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
  733. CFLAGS += -DNO_DEMANGLE
  734. endif
  735. endif
  736. endif
  737. ifneq ($(filter -liberty,$(EXTLIBS)),)
  738. CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
  739. endif
  740. endif
  741. ifneq ($(filter -lbfd,$(EXTLIBS)),)
  742. CFLAGS += -DHAVE_LIBBFD_SUPPORT
  743. endif
  744. ifndef NO_ZLIB
  745. ifeq ($(feature-zlib), 1)
  746. CFLAGS += -DHAVE_ZLIB_SUPPORT
  747. EXTLIBS += -lz
  748. $(call detected,CONFIG_ZLIB)
  749. else
  750. NO_ZLIB := 1
  751. endif
  752. endif
  753. ifndef NO_LZMA
  754. ifeq ($(feature-lzma), 1)
  755. CFLAGS += -DHAVE_LZMA_SUPPORT
  756. EXTLIBS += -llzma
  757. $(call detected,CONFIG_LZMA)
  758. else
  759. msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
  760. NO_LZMA := 1
  761. endif
  762. endif
  763. ifndef NO_LIBZSTD
  764. ifeq ($(feature-libzstd), 1)
  765. CFLAGS += -DHAVE_ZSTD_SUPPORT
  766. CFLAGS += $(LIBZSTD_CFLAGS)
  767. LDFLAGS += $(LIBZSTD_LDFLAGS)
  768. EXTLIBS += -lzstd
  769. $(call detected,CONFIG_ZSTD)
  770. else
  771. msg := $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR);
  772. NO_LIBZSTD := 1
  773. endif
  774. endif
  775. ifndef NO_LIBCAP
  776. ifeq ($(feature-libcap), 1)
  777. CFLAGS += -DHAVE_LIBCAP_SUPPORT
  778. EXTLIBS += -lcap
  779. $(call detected,CONFIG_LIBCAP)
  780. else
  781. msg := $(warning No libcap found, disables capability support, please install libcap-devel/libcap-dev);
  782. NO_LIBCAP := 1
  783. endif
  784. endif
  785. ifndef NO_BACKTRACE
  786. ifeq ($(feature-backtrace), 1)
  787. CFLAGS += -DHAVE_BACKTRACE_SUPPORT
  788. endif
  789. endif
  790. ifndef NO_LIBNUMA
  791. ifeq ($(feature-libnuma), 0)
  792. msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
  793. NO_LIBNUMA := 1
  794. else
  795. ifeq ($(feature-numa_num_possible_cpus), 0)
  796. msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
  797. NO_LIBNUMA := 1
  798. else
  799. CFLAGS += -DHAVE_LIBNUMA_SUPPORT
  800. EXTLIBS += -lnuma
  801. $(call detected,CONFIG_NUMA)
  802. endif
  803. endif
  804. endif
  805. ifdef HAVE_KVM_STAT_SUPPORT
  806. CFLAGS += -DHAVE_KVM_STAT_SUPPORT
  807. endif
  808. ifeq ($(feature-disassembler-four-args), 1)
  809. CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
  810. endif
  811. ifeq (${IS_64_BIT}, 1)
  812. ifndef NO_PERF_READ_VDSO32
  813. $(call feature_check,compile-32)
  814. ifeq ($(feature-compile-32), 1)
  815. CFLAGS += -DHAVE_PERF_READ_VDSO32
  816. else
  817. NO_PERF_READ_VDSO32 := 1
  818. endif
  819. endif
  820. ifneq ($(SRCARCH), x86)
  821. NO_PERF_READ_VDSOX32 := 1
  822. endif
  823. ifndef NO_PERF_READ_VDSOX32
  824. $(call feature_check,compile-x32)
  825. ifeq ($(feature-compile-x32), 1)
  826. CFLAGS += -DHAVE_PERF_READ_VDSOX32
  827. else
  828. NO_PERF_READ_VDSOX32 := 1
  829. endif
  830. endif
  831. else
  832. NO_PERF_READ_VDSO32 := 1
  833. NO_PERF_READ_VDSOX32 := 1
  834. endif
  835. ifndef NO_LIBBABELTRACE
  836. $(call feature_check,libbabeltrace)
  837. ifeq ($(feature-libbabeltrace), 1)
  838. CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
  839. LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
  840. EXTLIBS += -lbabeltrace-ctf
  841. $(call detected,CONFIG_LIBBABELTRACE)
  842. else
  843. msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
  844. endif
  845. endif
  846. ifndef NO_AUXTRACE
  847. ifeq ($(SRCARCH),x86)
  848. ifeq ($(feature-get_cpuid), 0)
  849. msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
  850. NO_AUXTRACE := 1
  851. endif
  852. endif
  853. ifndef NO_AUXTRACE
  854. $(call detected,CONFIG_AUXTRACE)
  855. CFLAGS += -DHAVE_AUXTRACE_SUPPORT
  856. endif
  857. endif
  858. ifndef NO_JVMTI
  859. ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
  860. JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
  861. else
  862. ifneq (,$(wildcard /usr/sbin/alternatives))
  863. 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')
  864. endif
  865. endif
  866. ifndef JDIR
  867. $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
  868. NO_JVMTI := 1
  869. endif
  870. endif
  871. ifndef NO_JVMTI
  872. FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
  873. $(call feature_check,jvmti)
  874. ifeq ($(feature-jvmti), 1)
  875. $(call detected_var,JDIR)
  876. ifndef NO_JVMTI_CMLR
  877. FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
  878. $(call feature_check,jvmti-cmlr)
  879. ifeq ($(feature-jvmti-cmlr), 1)
  880. CFLAGS += -DHAVE_JVMTI_CMLR
  881. endif
  882. endif # NO_JVMTI_CMLR
  883. else
  884. $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
  885. NO_JVMTI := 1
  886. endif
  887. endif
  888. USE_CXX = 0
  889. USE_CLANGLLVM = 0
  890. ifdef LIBCLANGLLVM
  891. $(call feature_check,cxx)
  892. ifneq ($(feature-cxx), 1)
  893. msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
  894. else
  895. $(call feature_check,llvm)
  896. $(call feature_check,llvm-version)
  897. ifneq ($(feature-llvm), 1)
  898. msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
  899. else
  900. $(call feature_check,clang)
  901. ifneq ($(feature-clang), 1)
  902. msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
  903. else
  904. CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
  905. CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
  906. $(call detected,CONFIG_CXX)
  907. $(call detected,CONFIG_CLANGLLVM)
  908. USE_CXX = 1
  909. USE_LLVM = 1
  910. USE_CLANG = 1
  911. ifneq ($(feature-llvm-version),1)
  912. msg := $(warning This version of LLVM is not tested. May cause build errors)
  913. endif
  914. endif
  915. endif
  916. endif
  917. endif
  918. ifdef LIBPFM4
  919. $(call feature_check,libpfm4)
  920. ifeq ($(feature-libpfm4), 1)
  921. CFLAGS += -DHAVE_LIBPFM
  922. EXTLIBS += -lpfm
  923. ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1
  924. $(call detected,CONFIG_LIBPFM4)
  925. else
  926. msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev);
  927. NO_LIBPFM4 := 1
  928. endif
  929. endif
  930. # Among the variables below, these:
  931. # perfexecdir
  932. # perf_include_dir
  933. # perf_examples_dir
  934. # template_dir
  935. # mandir
  936. # infodir
  937. # htmldir
  938. # ETC_PERFCONFIG (but not sysconfdir)
  939. # can be specified as a relative path some/where/else;
  940. # this is interpreted as relative to $(prefix) and "perf" at
  941. # runtime figures out where they are based on the path to the executable.
  942. # This can help installing the suite in a relocatable way.
  943. # Make the path relative to DESTDIR, not to prefix
  944. ifndef DESTDIR
  945. prefix ?= $(HOME)
  946. endif
  947. bindir_relative = bin
  948. bindir = $(abspath $(prefix)/$(bindir_relative))
  949. mandir = share/man
  950. infodir = share/info
  951. perfexecdir = libexec/perf-core
  952. perf_include_dir = lib/perf/include
  953. perf_examples_dir = lib/perf/examples
  954. sharedir = $(prefix)/share
  955. template_dir = share/perf-core/templates
  956. STRACE_GROUPS_DIR = share/perf-core/strace/groups
  957. htmldir = share/doc/perf-doc
  958. tipdir = share/doc/perf-tip
  959. srcdir = $(srctree)/tools/perf
  960. ifeq ($(prefix),/usr)
  961. sysconfdir = /etc
  962. ETC_PERFCONFIG = $(sysconfdir)/perfconfig
  963. else
  964. sysconfdir = $(prefix)/etc
  965. ETC_PERFCONFIG = etc/perfconfig
  966. endif
  967. ifndef lib
  968. ifeq ($(SRCARCH)$(IS_64_BIT), x861)
  969. lib = lib64
  970. else
  971. lib = lib
  972. endif
  973. endif # lib
  974. libdir = $(prefix)/$(lib)
  975. # Shell quote (do not use $(call) to accommodate ancient setups);
  976. ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
  977. STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
  978. DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  979. bindir_SQ = $(subst ','\'',$(bindir))
  980. mandir_SQ = $(subst ','\'',$(mandir))
  981. infodir_SQ = $(subst ','\'',$(infodir))
  982. perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
  983. perf_include_dir_SQ = $(subst ','\'',$(perf_include_dir))
  984. perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))
  985. template_dir_SQ = $(subst ','\'',$(template_dir))
  986. htmldir_SQ = $(subst ','\'',$(htmldir))
  987. tipdir_SQ = $(subst ','\'',$(tipdir))
  988. prefix_SQ = $(subst ','\'',$(prefix))
  989. sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
  990. libdir_SQ = $(subst ','\'',$(libdir))
  991. srcdir_SQ = $(subst ','\'',$(srcdir))
  992. ifneq ($(filter /%,$(firstword $(perfexecdir))),)
  993. perfexec_instdir = $(perfexecdir)
  994. perf_include_instdir = $(perf_include_dir)
  995. perf_examples_instdir = $(perf_examples_dir)
  996. STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
  997. tip_instdir = $(tipdir)
  998. else
  999. perfexec_instdir = $(prefix)/$(perfexecdir)
  1000. perf_include_instdir = $(prefix)/$(perf_include_dir)
  1001. perf_examples_instdir = $(prefix)/$(perf_examples_dir)
  1002. STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
  1003. tip_instdir = $(prefix)/$(tipdir)
  1004. endif
  1005. perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
  1006. perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))
  1007. perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))
  1008. STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
  1009. tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
  1010. # If we install to $(HOME) we keep the traceevent default:
  1011. # $(HOME)/.traceevent/plugins
  1012. # Otherwise we install plugins into the global $(libdir).
  1013. ifdef DESTDIR
  1014. plugindir=$(libdir)/traceevent/plugins
  1015. plugindir_SQ= $(subst ','\'',$(plugindir))
  1016. endif
  1017. print_var = $(eval $(print_var_code)) $(info $(MSG))
  1018. define print_var_code
  1019. MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
  1020. endef
  1021. ifeq ($(VF),1)
  1022. # Display EXTRA features which are detected manualy
  1023. # from here with feature_check call and thus cannot
  1024. # be partof global state output.
  1025. $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),))
  1026. $(call print_var,prefix)
  1027. $(call print_var,bindir)
  1028. $(call print_var,libdir)
  1029. $(call print_var,sysconfdir)
  1030. $(call print_var,LIBUNWIND_DIR)
  1031. $(call print_var,LIBDW_DIR)
  1032. $(call print_var,JDIR)
  1033. ifeq ($(dwarf-post-unwind),1)
  1034. $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
  1035. endif
  1036. $(info )
  1037. endif
  1038. $(call detected_var,bindir_SQ)
  1039. $(call detected_var,PYTHON_WORD)
  1040. ifneq ($(OUTPUT),)
  1041. $(call detected_var,OUTPUT)
  1042. endif
  1043. $(call detected_var,htmldir_SQ)
  1044. $(call detected_var,infodir_SQ)
  1045. $(call detected_var,mandir_SQ)
  1046. $(call detected_var,ETC_PERFCONFIG_SQ)
  1047. $(call detected_var,STRACE_GROUPS_DIR_SQ)
  1048. $(call detected_var,prefix_SQ)
  1049. $(call detected_var,perfexecdir_SQ)
  1050. $(call detected_var,perf_include_dir_SQ)
  1051. $(call detected_var,perf_examples_dir_SQ)
  1052. $(call detected_var,tipdir_SQ)
  1053. $(call detected_var,srcdir_SQ)
  1054. $(call detected_var,LIBDIR)
  1055. $(call detected_var,GTK_CFLAGS)
  1056. $(call detected_var,PERL_EMBED_CCOPTS)
  1057. $(call detected_var,PYTHON_EMBED_CCOPTS)