1 # SPDX-License-Identifier: GPL-2.0
2 include ..
/..
/scripts
/Makefile.
include
10 test-fortify-source.bin \
11 test-get_current_dir_name.bin \
14 test-gtk2-infobar.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 \
28 test-libelf-getphdrnum.bin \
29 test-libelf-gelf_getnote.bin \
30 test-libelf-getshdrstrndx.bin \
31 test-libdebuginfod.bin \
33 test-numa_num_possible_cpus.bin \
37 test-libslang-include-subdir.bin \
38 test-libtraceevent.bin \
39 test-libcpupower.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 \
54 test-libbabeltrace.bin \
55 test-libcapstone.bin \
57 test-compile-x32.bin \
69 test-sched_getcpu.bin \
77 test-clang-bpf-co-re.bin \
78 test-file-handle.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
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.
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
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
:
126 $(OUTPUT
)test-pthread-attr-setaffinity-np.bin
:
127 $(BUILD
) -D_GNU_SOURCE
-lpthread
129 $(OUTPUT
)test-pthread-barrier.bin
:
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
:
141 $(OUTPUT
)test-libcap.bin
:
144 $(OUTPUT
)test-libelf.bin
:
147 $(OUTPUT
)test-eventfd.bin
:
150 $(OUTPUT
)test-get_current_dir_name.bin
:
153 $(OUTPUT
)test-glibc.bin
:
156 $(OUTPUT
)test-scandirat.bin
:
159 $(OUTPUT
)test-sched_getcpu.bin
:
162 $(OUTPUT
)test-setns.bin
:
165 $(OUTPUT
)test-libopencsd.bin
:
166 $(BUILD
) # -lopencsd_c_api -lopencsd provided by
167 # $(FEATURE_CHECK_LDFLAGS-libopencsd)
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)
183 # Must put -ldl after -lebl for dependency
187 $(OUTPUT
)test-libdw.bin
:
190 $(OUTPUT
)test-libelf-getphdrnum.bin
:
193 $(OUTPUT
)test-libelf-gelf_getnote.bin
:
196 $(OUTPUT
)test-libelf-getshdrstrndx.bin
:
199 $(OUTPUT
)test-libdebuginfod.bin
:
200 $(BUILD
) -ldebuginfod
202 $(OUTPUT
)test-libnuma.bin
:
205 $(OUTPUT
)test-numa_num_possible_cpus.bin
:
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
:
234 $(OUTPUT
)test-libslang.bin
:
237 $(OUTPUT
)test-libslang-include-subdir.bin
:
240 $(OUTPUT
)test-libtraceevent.bin
:
241 $(BUILD
) -ltraceevent
243 $(OUTPUT
)test-libcpupower.bin
:
246 $(OUTPUT
)test-libtracefs.bin
:
247 $(BUILD
) $(shell $(PKG_CONFIG
) --cflags libtracefs
2>/dev
/null
) -ltracefs
249 $(OUTPUT
)test-libcrypto.bin
:
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
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
:
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
:
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
:
306 $(OUTPUT
)test-cxa-demangle.bin
:
309 $(OUTPUT
)test-backtrace.bin
:
312 $(OUTPUT
)test-timerfd.bin
:
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
:
330 $(OUTPUT
)test-lzma.bin
:
333 $(OUTPUT
)test-get_cpuid.bin
:
336 $(OUTPUT
)test-bpf.bin
:
339 $(OUTPUT
)test-libbpf.bin
:
342 $(OUTPUT
)test-libbpf-btf__load_from_kernel_by_id.bin
:
345 $(OUTPUT
)test-libbpf-bpf_prog_load.bin
:
348 $(OUTPUT
)test-libbpf-bpf_map_create.bin
:
351 $(OUTPUT
)test-libbpf-bpf_object__next_program.bin
:
354 $(OUTPUT
)test-libbpf-bpf_object__next_map.bin
:
357 $(OUTPUT
)test-libbpf-bpf_program__set_insns.bin
:
360 $(OUTPUT
)test-libbpf-btf__raw_data.bin
:
363 $(OUTPUT
)test-sdt.bin
:
366 $(OUTPUT
)test-cxx.bin
:
367 $(BUILDXX
) -std
=gnu
++11
369 $(OUTPUT
)test-gettid.bin
:
372 $(OUTPUT
)test-jvmti.bin
:
375 $(OUTPUT
)test-jvmti-cmlr.bin
:
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
:
408 $(OUTPUT
)test-libzstd.bin
:
411 $(OUTPUT
)test-clang-bpf-co-re.bin
:
412 $(CLANG
) -S
-g
--target
=bpf
-o
- $(patsubst %.bin
,%.c
,$(@F
)) | \
415 $(OUTPUT
)test-file-handle.bin
:
418 $(OUTPUT
)test-libpfm4.bin
:
421 ###############################
424 rm -f
$(FILES
) $(OUTPUT
)*.d
$(FILES
:.bin
=.make.output
)