Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / build / feature / Makefile
blob043dfd00fce72d8f651ccd9b3265a0183f500e5c
1 # SPDX-License-Identifier: GPL-2.0
2 include ../../scripts/Makefile.include
4 FILES= \
5 test-all.bin \
6 test-backtrace.bin \
7 test-bionic.bin \
8 test-libdw.bin \
9 test-eventfd.bin \
10 test-fortify-source.bin \
11 test-get_current_dir_name.bin \
12 test-glibc.bin \
13 test-gtk2.bin \
14 test-gtk2-infobar.bin \
15 test-hello.bin \
16 test-libaudit.bin \
17 test-libbfd.bin \
18 test-libbfd-buildid.bin \
19 test-disassembler-four-args.bin \
20 test-disassembler-init-styled.bin \
21 test-reallocarray.bin \
22 test-libbfd-liberty.bin \
23 test-libbfd-liberty-z.bin \
24 test-cplus-demangle.bin \
25 test-cxa-demangle.bin \
26 test-libcap.bin \
27 test-libelf.bin \
28 test-libelf-getphdrnum.bin \
29 test-libelf-gelf_getnote.bin \
30 test-libelf-getshdrstrndx.bin \
31 test-libdebuginfod.bin \
32 test-libnuma.bin \
33 test-numa_num_possible_cpus.bin \
34 test-libperl.bin \
35 test-libpython.bin \
36 test-libslang.bin \
37 test-libslang-include-subdir.bin \
38 test-libtraceevent.bin \
39 test-libcpupower.bin \
40 test-libtracefs.bin \
41 test-libcrypto.bin \
42 test-libunwind.bin \
43 test-libunwind-debug-frame.bin \
44 test-libunwind-x86.bin \
45 test-libunwind-x86_64.bin \
46 test-libunwind-arm.bin \
47 test-libunwind-aarch64.bin \
48 test-libunwind-debug-frame-arm.bin \
49 test-libunwind-debug-frame-aarch64.bin \
50 test-pthread-attr-setaffinity-np.bin \
51 test-pthread-barrier.bin \
52 test-stackprotector-all.bin \
53 test-timerfd.bin \
54 test-libbabeltrace.bin \
55 test-libcapstone.bin \
56 test-compile-32.bin \
57 test-compile-x32.bin \
58 test-zlib.bin \
59 test-lzma.bin \
60 test-bpf.bin \
61 test-libbpf.bin \
62 test-get_cpuid.bin \
63 test-sdt.bin \
64 test-cxx.bin \
65 test-gettid.bin \
66 test-jvmti.bin \
67 test-jvmti-cmlr.bin \
68 test-scandirat.bin \
69 test-sched_getcpu.bin \
70 test-setns.bin \
71 test-libopencsd.bin \
72 test-clang.bin \
73 test-llvm.bin \
74 test-llvm-perf.bin \
75 test-libaio.bin \
76 test-libzstd.bin \
77 test-clang-bpf-co-re.bin \
78 test-file-handle.bin \
79 test-libpfm4.bin
81 FILES := $(addprefix $(OUTPUT),$(FILES))
83 # Some distros provide the command $(CROSS_COMPILE)pkg-config for
84 # searching packges installed with Multiarch. Use it for cross
85 # compilation if it is existed.
86 ifneq (, $(shell which $(CROSS_COMPILE)pkg-config))
87 PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
88 else
89 PKG_CONFIG ?= pkg-config
91 # PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR
92 # for modified system root, are required for the cross compilation.
93 # If these PKG_CONFIG environment variables are not set, Multiarch library
94 # paths are used instead.
95 ifdef CROSS_COMPILE
96 ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),)
97 CROSS_ARCH = $(shell $(CC) -dumpmachine)
98 PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
99 PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
100 PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
101 PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/
102 PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/
103 export PKG_CONFIG_LIBDIR
104 endif
105 endif
106 endif
108 all: $(FILES)
110 __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
111 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
112 BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
113 BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd -lcap
115 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
116 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
118 ###############################
120 $(OUTPUT)test-all.bin:
121 $(BUILD_ALL) || $(BUILD_ALL) -lopcodes -liberty
123 $(OUTPUT)test-hello.bin:
124 $(BUILD)
126 $(OUTPUT)test-pthread-attr-setaffinity-np.bin:
127 $(BUILD) -D_GNU_SOURCE -lpthread
129 $(OUTPUT)test-pthread-barrier.bin:
130 $(BUILD) -lpthread
132 $(OUTPUT)test-stackprotector-all.bin:
133 $(BUILD) -fstack-protector-all
135 $(OUTPUT)test-fortify-source.bin:
136 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
138 $(OUTPUT)test-bionic.bin:
139 $(BUILD)
141 $(OUTPUT)test-libcap.bin:
142 $(BUILD) -lcap
144 $(OUTPUT)test-libelf.bin:
145 $(BUILD) -lelf
147 $(OUTPUT)test-eventfd.bin:
148 $(BUILD)
150 $(OUTPUT)test-get_current_dir_name.bin:
151 $(BUILD)
153 $(OUTPUT)test-glibc.bin:
154 $(BUILD)
156 $(OUTPUT)test-scandirat.bin:
157 $(BUILD)
159 $(OUTPUT)test-sched_getcpu.bin:
160 $(BUILD)
162 $(OUTPUT)test-setns.bin:
163 $(BUILD)
165 $(OUTPUT)test-libopencsd.bin:
166 $(BUILD) # -lopencsd_c_api -lopencsd provided by
167 # $(FEATURE_CHECK_LDFLAGS-libopencsd)
169 DWLIBS := -ldw
170 ifeq ($(findstring -static,${LDFLAGS}),-static)
171 DWLIBS += -lelf -lz -llzma -lbz2 -lzstd
173 LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
174 LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
175 LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
177 # Elfutils merged libebl.a into libdw.a starting from version 0.177,
178 # Link libebl.a only if libdw is older than this version.
179 ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
180 DWLIBS += -lebl
181 endif
183 # Must put -ldl after -lebl for dependency
184 DWARFLIBS += -ldl
185 endif
187 $(OUTPUT)test-libdw.bin:
188 $(BUILD) $(DWLIBS)
190 $(OUTPUT)test-libelf-getphdrnum.bin:
191 $(BUILD) -lelf
193 $(OUTPUT)test-libelf-gelf_getnote.bin:
194 $(BUILD) -lelf
196 $(OUTPUT)test-libelf-getshdrstrndx.bin:
197 $(BUILD) -lelf
199 $(OUTPUT)test-libdebuginfod.bin:
200 $(BUILD) -ldebuginfod
202 $(OUTPUT)test-libnuma.bin:
203 $(BUILD) -lnuma
205 $(OUTPUT)test-numa_num_possible_cpus.bin:
206 $(BUILD) -lnuma
208 $(OUTPUT)test-libunwind.bin:
209 $(BUILD) -lelf -llzma
211 $(OUTPUT)test-libunwind-debug-frame.bin:
212 $(BUILD) -lelf -llzma
213 $(OUTPUT)test-libunwind-x86.bin:
214 $(BUILD) -lelf -llzma -lunwind-x86
216 $(OUTPUT)test-libunwind-x86_64.bin:
217 $(BUILD) -lelf -llzma -lunwind-x86_64
219 $(OUTPUT)test-libunwind-arm.bin:
220 $(BUILD) -lelf -llzma -lunwind-arm
222 $(OUTPUT)test-libunwind-aarch64.bin:
223 $(BUILD) -lelf -llzma -lunwind-aarch64
225 $(OUTPUT)test-libunwind-debug-frame-arm.bin:
226 $(BUILD) -lelf -llzma -lunwind-arm
228 $(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
229 $(BUILD) -lelf -llzma -lunwind-aarch64
231 $(OUTPUT)test-libaudit.bin:
232 $(BUILD) -laudit
234 $(OUTPUT)test-libslang.bin:
235 $(BUILD) -lslang
237 $(OUTPUT)test-libslang-include-subdir.bin:
238 $(BUILD) -lslang
240 $(OUTPUT)test-libtraceevent.bin:
241 $(BUILD) -ltraceevent
243 $(OUTPUT)test-libcpupower.bin:
244 $(BUILD) -lcpupower
246 $(OUTPUT)test-libtracefs.bin:
247 $(BUILD) $(shell $(PKG_CONFIG) --cflags libtracefs 2>/dev/null) -ltracefs
249 $(OUTPUT)test-libcrypto.bin:
250 $(BUILD) -lcrypto
252 $(OUTPUT)test-gtk2.bin:
253 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
255 $(OUTPUT)test-gtk2-infobar.bin:
256 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
258 grep-libs = $(filter -l%,$(1))
259 strip-libs = $(filter-out -l%,$(1))
261 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
262 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
263 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
264 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
265 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
267 ifeq ($(CC_NO_CLANG), 0)
268 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
269 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
270 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
271 FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro
272 endif
274 $(OUTPUT)test-libperl.bin:
275 $(BUILD) $(FLAGS_PERL_EMBED)
277 $(OUTPUT)test-libpython.bin:
278 $(BUILD) $(FLAGS_PYTHON_EMBED)
280 $(OUTPUT)test-libbfd.bin:
281 $(BUILD_BFD)
283 $(OUTPUT)test-libbfd-buildid.bin:
284 $(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz
286 $(OUTPUT)test-disassembler-four-args.bin:
287 $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
288 $(BUILD_BFD) -lopcodes -liberty -lz
290 $(OUTPUT)test-disassembler-init-styled.bin:
291 $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
292 $(BUILD_BFD) -lopcodes -liberty -lz
294 $(OUTPUT)test-reallocarray.bin:
295 $(BUILD)
297 $(OUTPUT)test-libbfd-liberty.bin:
298 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
300 $(OUTPUT)test-libbfd-liberty-z.bin:
301 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
303 $(OUTPUT)test-cplus-demangle.bin:
304 $(BUILD) -liberty
306 $(OUTPUT)test-cxa-demangle.bin:
307 $(BUILDXX)
309 $(OUTPUT)test-backtrace.bin:
310 $(BUILD)
312 $(OUTPUT)test-timerfd.bin:
313 $(BUILD)
315 $(OUTPUT)test-libbabeltrace.bin:
316 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
318 $(OUTPUT)test-libcapstone.bin:
319 $(BUILD) # -lcapstone provided by $(FEATURE_CHECK_LDFLAGS-libcapstone)
321 $(OUTPUT)test-compile-32.bin:
322 $(CC) -m32 -o $@ test-compile.c
324 $(OUTPUT)test-compile-x32.bin:
325 $(CC) -mx32 -o $@ test-compile.c
327 $(OUTPUT)test-zlib.bin:
328 $(BUILD) -lz
330 $(OUTPUT)test-lzma.bin:
331 $(BUILD) -llzma
333 $(OUTPUT)test-get_cpuid.bin:
334 $(BUILD)
336 $(OUTPUT)test-bpf.bin:
337 $(BUILD)
339 $(OUTPUT)test-libbpf.bin:
340 $(BUILD) -lbpf
342 $(OUTPUT)test-libbpf-btf__load_from_kernel_by_id.bin:
343 $(BUILD) -lbpf
345 $(OUTPUT)test-libbpf-bpf_prog_load.bin:
346 $(BUILD) -lbpf
348 $(OUTPUT)test-libbpf-bpf_map_create.bin:
349 $(BUILD) -lbpf
351 $(OUTPUT)test-libbpf-bpf_object__next_program.bin:
352 $(BUILD) -lbpf
354 $(OUTPUT)test-libbpf-bpf_object__next_map.bin:
355 $(BUILD) -lbpf
357 $(OUTPUT)test-libbpf-bpf_program__set_insns.bin:
358 $(BUILD) -lbpf
360 $(OUTPUT)test-libbpf-btf__raw_data.bin:
361 $(BUILD) -lbpf
363 $(OUTPUT)test-sdt.bin:
364 $(BUILD)
366 $(OUTPUT)test-cxx.bin:
367 $(BUILDXX) -std=gnu++11
369 $(OUTPUT)test-gettid.bin:
370 $(BUILD)
372 $(OUTPUT)test-jvmti.bin:
373 $(BUILD)
375 $(OUTPUT)test-jvmti-cmlr.bin:
376 $(BUILD)
378 $(OUTPUT)test-llvm.bin:
379 $(BUILDXX) -std=gnu++17 \
380 -I$(shell $(LLVM_CONFIG) --includedir) \
381 -L$(shell $(LLVM_CONFIG) --libdir) \
382 $(shell $(LLVM_CONFIG) --libs Core BPF) \
383 $(shell $(LLVM_CONFIG) --system-libs) \
384 > $(@:.bin=.make.output) 2>&1
386 $(OUTPUT)test-llvm-perf.bin:
387 $(BUILDXX) -std=gnu++17 \
388 -I$(shell $(LLVM_CONFIG) --includedir) \
389 -L$(shell $(LLVM_CONFIG) --libdir) \
390 $(shell $(LLVM_CONFIG) --libs Core BPF) \
391 $(shell $(LLVM_CONFIG) --system-libs) \
392 > $(@:.bin=.make.output) 2>&1
394 $(OUTPUT)test-clang.bin:
395 $(BUILDXX) -std=gnu++17 \
396 -I$(shell $(LLVM_CONFIG) --includedir) \
397 -L$(shell $(LLVM_CONFIG) --libdir) \
398 -Wl,--start-group -lclang-cpp -Wl,--end-group \
399 $(shell $(LLVM_CONFIG) --libs Core option) \
400 $(shell $(LLVM_CONFIG) --system-libs) \
401 > $(@:.bin=.make.output) 2>&1
403 -include $(OUTPUT)*.d
405 $(OUTPUT)test-libaio.bin:
406 $(BUILD) -lrt
408 $(OUTPUT)test-libzstd.bin:
409 $(BUILD) -lzstd
411 $(OUTPUT)test-clang-bpf-co-re.bin:
412 $(CLANG) -S -g --target=bpf -o - $(patsubst %.bin,%.c,$(@F)) | \
413 grep BTF_KIND_VAR
415 $(OUTPUT)test-file-handle.bin:
416 $(BUILD)
418 $(OUTPUT)test-libpfm4.bin:
419 $(BUILD) -lpfm
421 ###############################
423 clean:
424 rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)