Makefile.config 41 KB

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