Merge tag 'pci-v6.16-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
[linux-block.git] / tools / build / feature / Makefile
CommitLineData
b2441318 1# SPDX-License-Identifier: GPL-2.0
211a741c
SD
2include ../../scripts/Makefile.include
3
2fedf79b
JO
4FILES= \
5 test-all.bin \
6 test-backtrace.bin \
7 test-bionic.bin \
7c943261 8 test-libdw.bin \
11c6cbe7 9 test-eventfd.bin \
2fedf79b 10 test-fortify-source.bin \
8feb8efe 11 test-get_current_dir_name.bin \
2fedf79b
JO
12 test-glibc.bin \
13 test-gtk2.bin \
14 test-gtk2-infobar.bin \
15 test-hello.bin \
2fedf79b 16 test-libbfd.bin \
e71e19a9 17 test-libbfd-buildid.bin \
fb982666 18 test-disassembler-four-args.bin \
cfd59ca9 19 test-disassembler-init-styled.bin \
531b014e 20 test-reallocarray.bin \
14541b1e
SF
21 test-libbfd-liberty.bin \
22 test-libbfd-liberty-z.bin \
2fedf79b 23 test-cplus-demangle.bin \
4c72e2b3 24 test-cxa-demangle.bin \
0fd77ae4 25 test-libcap.bin \
2fedf79b
JO
26 test-libelf.bin \
27 test-libelf-getphdrnum.bin \
28 test-libelf-gelf_getnote.bin \
29 test-libelf-getshdrstrndx.bin \
d557814c 30 test-libelf-zstd.bin \
c7a14fdc 31 test-libdebuginfod.bin \
2fedf79b
JO
32 test-libnuma.bin \
33 test-numa_num_possible_cpus.bin \
34 test-libperl.bin \
35 test-libpython.bin \
2fedf79b 36 test-libslang.bin \
cbefd24f 37 test-libslang-include-subdir.bin \
56d32d4c 38 test-libtraceevent.bin \
0f59a6c9 39 test-libcpupower.bin \
b758a61b 40 test-libtracefs.bin \
2fedf79b
JO
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 \
25ab5abf 51 test-pthread-barrier.bin \
2fedf79b
JO
52 test-stackprotector-all.bin \
53 test-timerfd.bin \
2fedf79b 54 test-libbabeltrace.bin \
8b767db3 55 test-libcapstone.bin \
2fedf79b
JO
56 test-compile-32.bin \
57 test-compile-x32.bin \
58 test-zlib.bin \
59 test-lzma.bin \
60 test-bpf.bin \
7b65e203 61 test-libbpf.bin \
2fedf79b
JO
62 test-get_cpuid.bin \
63 test-sdt.bin \
64 test-cxx.bin \
4541a8bb 65 test-gettid.bin \
120010cb 66 test-jvmti.bin \
dd1d0044 67 test-jvmti-cmlr.bin \
9e03608e 68 test-scandirat.bin \
86bcdb5a 69 test-sched_getcpu.bin \
aa6292f4 70 test-setns.bin \
36f9dc33
JO
71 test-libopencsd.bin \
72 test-clang.bin \
73 test-llvm.bin \
206dcfca 74 test-llvm-perf.bin \
3b1c5d96 75 test-libaio.bin \
14e5728f 76 test-libzstd.bin \
05aca6da 77 test-clang-bpf-co-re.bin \
5ef86146
SE
78 test-file-handle.bin \
79 test-libpfm4.bin
b6aa9979 80
1925459b
JP
81FILES := $(addprefix $(OUTPUT),$(FILES))
82
440cf776
LY
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.
86ifneq (, $(shell which $(CROSS_COMPILE)pkg-config))
87 PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
88else
89 PKG_CONFIG ?= pkg-config
90
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
106endif
8b6eb56a 107
b6aa9979
IM
108all: $(FILES)
109
9961aa66 110__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
1925459b 111 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
629b98e2 112 BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
b1ef2559 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
b6aa9979 114
9961aa66 115__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
87095f7d
WN
116 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
117
b6aa9979
IM
118###############################
119
1925459b 120$(OUTPUT)test-all.bin:
629b98e2 121 $(BUILD_ALL) || $(BUILD_ALL) -lopcodes -liberty
baa9c30e 122
1925459b 123$(OUTPUT)test-hello.bin:
b6aa9979
IM
124 $(BUILD)
125
1925459b 126$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
b49f1a4b 127 $(BUILD) -D_GNU_SOURCE -lpthread
459a3df7 128
25ab5abf
ACM
129$(OUTPUT)test-pthread-barrier.bin:
130 $(BUILD) -lpthread
131
1925459b 132$(OUTPUT)test-stackprotector-all.bin:
b49f1a4b 133 $(BUILD) -fstack-protector-all
90ac5422 134
1925459b 135$(OUTPUT)test-fortify-source.bin:
b49f1a4b 136 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
1ea6f99e 137
1925459b 138$(OUTPUT)test-bionic.bin:
78e9d655
IM
139 $(BUILD)
140
0fd77ae4
ACM
141$(OUTPUT)test-libcap.bin:
142 $(BUILD) -lcap
143
1925459b 144$(OUTPUT)test-libelf.bin:
8f7f8005
IM
145 $(BUILD) -lelf
146
11c6cbe7
ACM
147$(OUTPUT)test-eventfd.bin:
148 $(BUILD)
149
8feb8efe
ACM
150$(OUTPUT)test-get_current_dir_name.bin:
151 $(BUILD)
152
1925459b 153$(OUTPUT)test-glibc.bin:
e12762cf
IM
154 $(BUILD)
155
9e03608e
ACM
156$(OUTPUT)test-scandirat.bin:
157 $(BUILD)
158
120010cb
ACM
159$(OUTPUT)test-sched_getcpu.bin:
160 $(BUILD)
161
86bcdb5a
ACM
162$(OUTPUT)test-setns.bin:
163 $(BUILD)
164
aa6292f4
MP
165$(OUTPUT)test-libopencsd.bin:
166 $(BUILD) # -lopencsd_c_api -lopencsd provided by
167 # $(FEATURE_CHECK_LDFLAGS-libopencsd)
168
7c943261 169DWLIBS := -ldw
7aec51cb 170ifeq ($(findstring -static,${LDFLAGS}),-static)
7c943261 171 DWLIBS += -lelf -lz -llzma -lbz2 -lzstd
536661da 172
43f6564f 173 LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
536661da
LY
174 LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
175 LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
176
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)
7c943261 180 DWLIBS += -lebl
536661da 181 endif
a530337b
YJ
182
183 # Must put -ldl after -lebl for dependency
184 DWARFLIBS += -ldl
7aec51cb
AK
185endif
186
7c943261
IR
187$(OUTPUT)test-libdw.bin:
188 $(BUILD) $(DWLIBS)
f67f2fda 189
1925459b 190$(OUTPUT)test-libelf-getphdrnum.bin:
b7bcef6f
IM
191 $(BUILD) -lelf
192
1c1a3a47
ACM
193$(OUTPUT)test-libelf-gelf_getnote.bin:
194 $(BUILD) -lelf
195
2492c465
ACM
196$(OUTPUT)test-libelf-getshdrstrndx.bin:
197 $(BUILD) -lelf
198
d557814c
LY
199$(OUTPUT)test-libelf-zstd.bin:
200 $(BUILD) -lelf -lz -lzstd
201
c7a14fdc
FCE
202$(OUTPUT)test-libdebuginfod.bin:
203 $(BUILD) -ldebuginfod
204
1925459b 205$(OUTPUT)test-libnuma.bin:
3ae069cf
IM
206 $(BUILD) -lnuma
207
1925459b 208$(OUTPUT)test-numa_num_possible_cpus.bin:
f8ac8606
ACM
209 $(BUILD) -lnuma
210
1925459b 211$(OUTPUT)test-libunwind.bin:
91b6a536 212 $(BUILD) -lelf -llzma
058f952d 213
1925459b 214$(OUTPUT)test-libunwind-debug-frame.bin:
91b6a536 215 $(BUILD) -lelf -llzma
b1d96000 216$(OUTPUT)test-libunwind-x86.bin:
91b6a536 217 $(BUILD) -lelf -llzma -lunwind-x86
b1d96000
HK
218
219$(OUTPUT)test-libunwind-x86_64.bin:
91b6a536 220 $(BUILD) -lelf -llzma -lunwind-x86_64
b1d96000
HK
221
222$(OUTPUT)test-libunwind-arm.bin:
91b6a536 223 $(BUILD) -lelf -llzma -lunwind-arm
b1d96000
HK
224
225$(OUTPUT)test-libunwind-aarch64.bin:
91b6a536 226 $(BUILD) -lelf -llzma -lunwind-aarch64
b1d96000 227
f9be7eef 228$(OUTPUT)test-libunwind-debug-frame-arm.bin:
91b6a536 229 $(BUILD) -lelf -llzma -lunwind-arm
f9be7eef
HK
230
231$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
91b6a536 232 $(BUILD) -lelf -llzma -lunwind-aarch64
e310718d 233
1925459b 234$(OUTPUT)test-libslang.bin:
1955c8cf 235 $(BUILD) -lslang
b9498b50 236
cbefd24f
ACM
237$(OUTPUT)test-libslang-include-subdir.bin:
238 $(BUILD) -lslang
239
56d32d4c
MP
240$(OUTPUT)test-libtraceevent.bin:
241 $(BUILD) -ltraceevent
242
0f59a6c9
TG
243$(OUTPUT)test-libcpupower.bin:
244 $(BUILD) -lcpupower
245
b758a61b 246$(OUTPUT)test-libtracefs.bin:
28beb730 247 $(BUILD) $(shell $(PKG_CONFIG) --cflags libtracefs 2>/dev/null) -ltracefs
b758a61b 248
8ee46460
SE
249$(OUTPUT)test-libcrypto.bin:
250 $(BUILD) -lcrypto
251
1925459b 252$(OUTPUT)test-gtk2.bin:
93e843f9 253 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
7ef9e055 254
1925459b 255$(OUTPUT)test-gtk2-infobar.bin:
a8a5cd8b 256 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
c7a79e96 257
7181a671
IM
258grep-libs = $(filter -l%,$(1))
259strip-libs = $(filter-out -l%,$(1))
260
261PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
262PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
263PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
541f695c 264PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
7181a671
IM
265FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
266
41caff45
ACM
267ifeq ($(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
272endif
273
1925459b 274$(OUTPUT)test-libperl.bin:
7181a671
IM
275 $(BUILD) $(FLAGS_PERL_EMBED)
276
1925459b 277$(OUTPUT)test-libpython.bin:
7be6b316 278 $(BUILD) $(FLAGS_PYTHON_EMBED)
9734163b 279
1925459b 280$(OUTPUT)test-libbfd.bin:
629b98e2 281 $(BUILD_BFD)
3b7646e4 282
e71e19a9 283$(OUTPUT)test-libbfd-buildid.bin:
629b98e2 284 $(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz
e71e19a9 285
fb982666 286$(OUTPUT)test-disassembler-four-args.bin:
629b98e2
RS
287 $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
288 $(BUILD_BFD) -lopcodes -liberty -lz
fb982666 289
cfd59ca9 290$(OUTPUT)test-disassembler-init-styled.bin:
629b98e2
RS
291 $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
292 $(BUILD_BFD) -lopcodes -liberty -lz
cfd59ca9 293
531b014e
JK
294$(OUTPUT)test-reallocarray.bin:
295 $(BUILD)
296
14541b1e 297$(OUTPUT)test-libbfd-liberty.bin:
1925459b 298 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
1c47661a 299
14541b1e 300$(OUTPUT)test-libbfd-liberty-z.bin:
1925459b 301 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
1c47661a 302
1925459b 303$(OUTPUT)test-cplus-demangle.bin:
1c47661a
IM
304 $(BUILD) -liberty
305
4c72e2b3
IR
306$(OUTPUT)test-cxa-demangle.bin:
307 $(BUILDXX)
308
1925459b 309$(OUTPUT)test-backtrace.bin:
4cc9117a
IM
310 $(BUILD)
311
1925459b 312$(OUTPUT)test-timerfd.bin:
87419c9a
DA
313 $(BUILD)
314
1925459b 315$(OUTPUT)test-libbabeltrace.bin:
53d0a573 316 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
45757895 317
8b767db3
CD
318$(OUTPUT)test-libcapstone.bin:
319 $(BUILD) # -lcapstone provided by $(FEATURE_CHECK_LDFLAGS-libcapstone)
320
1925459b
JP
321$(OUTPUT)test-compile-32.bin:
322 $(CC) -m32 -o $@ test-compile.c
e477f3f0 323
1925459b
JP
324$(OUTPUT)test-compile-x32.bin:
325 $(CC) -mx32 -o $@ test-compile.c
e477f3f0 326
1925459b 327$(OUTPUT)test-zlib.bin:
e92ce12e
NK
328 $(BUILD) -lz
329
1925459b 330$(OUTPUT)test-lzma.bin:
6c6f0f61
JO
331 $(BUILD) -llzma
332
1925459b 333$(OUTPUT)test-get_cpuid.bin:
b0063dbf
ACM
334 $(BUILD)
335
1925459b 336$(OUTPUT)test-bpf.bin:
1b76c13e
WN
337 $(BUILD)
338
7b65e203
JO
339$(OUTPUT)test-libbpf.bin:
340 $(BUILD) -lbpf
341
0ae065a5
ACM
342$(OUTPUT)test-libbpf-btf__load_from_kernel_by_id.bin:
343 $(BUILD) -lbpf
344
5c83eff3
JO
345$(OUTPUT)test-libbpf-bpf_prog_load.bin:
346 $(BUILD) -lbpf
347
df76e003
ACM
348$(OUTPUT)test-libbpf-bpf_map_create.bin:
349 $(BUILD) -lbpf
350
8916d725
JO
351$(OUTPUT)test-libbpf-bpf_object__next_program.bin:
352 $(BUILD) -lbpf
353
739c9180
JO
354$(OUTPUT)test-libbpf-bpf_object__next_map.bin:
355 $(BUILD) -lbpf
356
f1bdebbb
ACM
357$(OUTPUT)test-libbpf-bpf_program__set_insns.bin:
358 $(BUILD) -lbpf
359
982be477
JO
360$(OUTPUT)test-libbpf-btf__raw_data.bin:
361 $(BUILD) -lbpf
362
e26e63be
MH
363$(OUTPUT)test-sdt.bin:
364 $(BUILD)
365
87095f7d
WN
366$(OUTPUT)test-cxx.bin:
367 $(BUILDXX) -std=gnu++11
368
4541a8bb
ACM
369$(OUTPUT)test-gettid.bin:
370 $(BUILD)
371
285932a2
JO
372$(OUTPUT)test-jvmti.bin:
373 $(BUILD)
374
dd1d0044
JO
375$(OUTPUT)test-jvmti-cmlr.bin:
376 $(BUILD)
377
cb40d55b 378$(OUTPUT)test-llvm.bin:
4e95ed4f 379 $(BUILDXX) -std=gnu++17 \
cb40d55b
WN
380 -I$(shell $(LLVM_CONFIG) --includedir) \
381 -L$(shell $(LLVM_CONFIG) --libdir) \
206dcfca
JC
382 $(shell $(LLVM_CONFIG) --libs Core BPF) \
383 $(shell $(LLVM_CONFIG) --system-libs) \
384 > $(@:.bin=.make.output) 2>&1
385
386$(OUTPUT)test-llvm-perf.bin:
387 $(BUILDXX) -std=gnu++17 \
388 -I$(shell $(LLVM_CONFIG) --includedir) \
389 -L$(shell $(LLVM_CONFIG) --libdir) \
cb40d55b 390 $(shell $(LLVM_CONFIG) --libs Core BPF) \
5fb3d8b7
JO
391 $(shell $(LLVM_CONFIG) --system-libs) \
392 > $(@:.bin=.make.output) 2>&1
cb40d55b 393
c7fb4f62 394$(OUTPUT)test-clang.bin:
4e95ed4f 395 $(BUILDXX) -std=gnu++17 \
c7fb4f62
WN
396 -I$(shell $(LLVM_CONFIG) --includedir) \
397 -L$(shell $(LLVM_CONFIG) --libdir) \
4e95ed4f 398 -Wl,--start-group -lclang-cpp -Wl,--end-group \
c7fb4f62 399 $(shell $(LLVM_CONFIG) --libs Core option) \
5fb3d8b7
JO
400 $(shell $(LLVM_CONFIG) --system-libs) \
401 > $(@:.bin=.make.output) 2>&1
c7fb4f62 402
1925459b 403-include $(OUTPUT)*.d
8b6eb56a 404
2a07d814
AB
405$(OUTPUT)test-libaio.bin:
406 $(BUILD) -lrt
407
3b1c5d96
AB
408$(OUTPUT)test-libzstd.bin:
409 $(BUILD) -lzstd
410
05aca6da 411$(OUTPUT)test-clang-bpf-co-re.bin:
bbaf1ff0 412 $(CLANG) -S -g --target=bpf -o - $(patsubst %.bin,%.c,$(@F)) | \
14e5728f
SL
413 grep BTF_KIND_VAR
414
49f550ea
NK
415$(OUTPUT)test-file-handle.bin:
416 $(BUILD)
14e5728f 417
5ef86146
SE
418$(OUTPUT)test-libpfm4.bin:
419 $(BUILD) -lpfm
420
8a635c38 421$(OUTPUT)test-bpftool-skeletons.bin:
814d051e 422 $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
8a635c38 423 > $(@:.bin=.make.output) 2>&1
b6aa9979
IM
424###############################
425
426clean:
1925459b 427 rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)