1 # SPDX-License-Identifier: GPL-2.0
2 include ../../scripts/Makefile.include
9 test-dwarf_getlocations.bin \
11 test-fortify-source.bin \
12 test-get_current_dir_name.bin \
15 test-gtk2-infobar.bin \
19 test-libbfd-buildid.bin \
20 test-disassembler-four-args.bin \
21 test-disassembler-init-styled.bin \
22 test-reallocarray.bin \
23 test-libbfd-liberty.bin \
24 test-libbfd-liberty-z.bin \
25 test-cplus-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 \
42 test-libunwind-debug-frame.bin \
43 test-libunwind-x86.bin \
44 test-libunwind-x86_64.bin \
45 test-libunwind-arm.bin \
46 test-libunwind-aarch64.bin \
47 test-libunwind-debug-frame-arm.bin \
48 test-libunwind-debug-frame-aarch64.bin \
49 test-pthread-attr-setaffinity-np.bin \
50 test-pthread-barrier.bin \
51 test-stackprotector-all.bin \
53 test-libdw-dwarf-unwind.bin \
54 test-libbabeltrace.bin \
56 test-compile-x32.bin \
61 test-libbpf-btf__load_from_kernel_by_id.bin \
62 test-libbpf-bpf_prog_load.bin \
63 test-libbpf-bpf_map_create.bin \
64 test-libbpf-bpf_object__next_program.bin \
65 test-libbpf-bpf_object__next_map.bin \
66 test-libbpf-btf__raw_data.bin \
73 test-sched_getcpu.bin \
78 test-llvm-version.bin \
81 test-clang-bpf-co-re.bin \
82 test-file-handle.bin \
85 FILES := $(addprefix $(OUTPUT),$(FILES))
87 PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
91 __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
92 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
94 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
95 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
97 ###############################
99 $(OUTPUT)test-all.bin:
100 $(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
102 $(OUTPUT)test-hello.bin:
105 $(OUTPUT)test-pthread-attr-setaffinity-np.bin:
106 $(BUILD) -D_GNU_SOURCE -lpthread
108 $(OUTPUT)test-pthread-barrier.bin:
111 $(OUTPUT)test-stackprotector-all.bin:
112 $(BUILD) -fstack-protector-all
114 $(OUTPUT)test-fortify-source.bin:
115 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
117 $(OUTPUT)test-bionic.bin:
120 $(OUTPUT)test-libcap.bin:
123 $(OUTPUT)test-libelf.bin:
126 $(OUTPUT)test-eventfd.bin:
129 $(OUTPUT)test-get_current_dir_name.bin:
132 $(OUTPUT)test-glibc.bin:
135 $(OUTPUT)test-sched_getcpu.bin:
138 $(OUTPUT)test-setns.bin:
141 $(OUTPUT)test-libopencsd.bin:
142 $(BUILD) # -lopencsd_c_api -lopencsd provided by
143 # $(FEATURE_CHECK_LDFLAGS-libopencsd)
146 ifeq ($(findstring -static,${LDFLAGS}),-static)
147 DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
150 $(OUTPUT)test-dwarf.bin:
151 $(BUILD) $(DWARFLIBS)
153 $(OUTPUT)test-dwarf_getlocations.bin:
154 $(BUILD) $(DWARFLIBS)
156 $(OUTPUT)test-libelf-getphdrnum.bin:
159 $(OUTPUT)test-libelf-gelf_getnote.bin:
162 $(OUTPUT)test-libelf-getshdrstrndx.bin:
165 $(OUTPUT)test-libdebuginfod.bin:
166 $(BUILD) -ldebuginfod
168 $(OUTPUT)test-libnuma.bin:
171 $(OUTPUT)test-numa_num_possible_cpus.bin:
174 $(OUTPUT)test-libunwind.bin:
177 $(OUTPUT)test-libunwind-debug-frame.bin:
179 $(OUTPUT)test-libunwind-x86.bin:
180 $(BUILD) -lelf -lunwind-x86
182 $(OUTPUT)test-libunwind-x86_64.bin:
183 $(BUILD) -lelf -lunwind-x86_64
185 $(OUTPUT)test-libunwind-arm.bin:
186 $(BUILD) -lelf -lunwind-arm
188 $(OUTPUT)test-libunwind-aarch64.bin:
189 $(BUILD) -lelf -lunwind-aarch64
191 $(OUTPUT)test-libunwind-debug-frame-arm.bin:
192 $(BUILD) -lelf -lunwind-arm
194 $(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
195 $(BUILD) -lelf -lunwind-aarch64
197 $(OUTPUT)test-libaudit.bin:
200 $(OUTPUT)test-libslang.bin:
203 $(OUTPUT)test-libslang-include-subdir.bin:
206 $(OUTPUT)test-libtraceevent.bin:
207 $(BUILD) -ltraceevent
209 $(OUTPUT)test-libtracefs.bin:
212 $(OUTPUT)test-libcrypto.bin:
215 $(OUTPUT)test-gtk2.bin:
216 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
218 $(OUTPUT)test-gtk2-infobar.bin:
219 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
221 grep-libs = $(filter -l%,$(1))
222 strip-libs = $(filter-out -l%,$(1))
224 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
225 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
226 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
227 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
228 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
230 ifeq ($(CC_NO_CLANG), 0)
231 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
232 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
233 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
234 FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro
237 $(OUTPUT)test-libperl.bin:
238 $(BUILD) $(FLAGS_PERL_EMBED)
240 $(OUTPUT)test-libpython.bin:
241 $(BUILD) $(FLAGS_PYTHON_EMBED)
243 $(OUTPUT)test-libbfd.bin:
244 $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
246 $(OUTPUT)test-libbfd-buildid.bin:
247 $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
249 $(OUTPUT)test-disassembler-four-args.bin:
250 $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
252 $(OUTPUT)test-disassembler-init-styled.bin:
253 $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
255 $(OUTPUT)test-reallocarray.bin:
258 $(OUTPUT)test-libbfd-liberty.bin:
259 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
261 $(OUTPUT)test-libbfd-liberty-z.bin:
262 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
264 $(OUTPUT)test-cplus-demangle.bin:
267 $(OUTPUT)test-backtrace.bin:
270 $(OUTPUT)test-timerfd.bin:
273 $(OUTPUT)test-libdw-dwarf-unwind.bin:
274 $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
276 $(OUTPUT)test-libbabeltrace.bin:
277 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
279 $(OUTPUT)test-compile-32.bin:
280 $(CC) -m32 -o $@ test-compile.c
282 $(OUTPUT)test-compile-x32.bin:
283 $(CC) -mx32 -o $@ test-compile.c
285 $(OUTPUT)test-zlib.bin:
288 $(OUTPUT)test-lzma.bin:
291 $(OUTPUT)test-get_cpuid.bin:
294 $(OUTPUT)test-bpf.bin:
297 $(OUTPUT)test-libbpf.bin:
300 $(OUTPUT)test-libbpf-btf__load_from_kernel_by_id.bin:
303 $(OUTPUT)test-libbpf-bpf_prog_load.bin:
306 $(OUTPUT)test-libbpf-bpf_map_create.bin:
309 $(OUTPUT)test-libbpf-bpf_object__next_program.bin:
312 $(OUTPUT)test-libbpf-bpf_object__next_map.bin:
315 $(OUTPUT)test-libbpf-btf__raw_data.bin:
318 $(OUTPUT)test-sdt.bin:
321 $(OUTPUT)test-cxx.bin:
322 $(BUILDXX) -std=gnu++11
324 $(OUTPUT)test-gettid.bin:
327 $(OUTPUT)test-jvmti.bin:
330 $(OUTPUT)test-jvmti-cmlr.bin:
333 $(OUTPUT)test-llvm.bin:
334 $(BUILDXX) -std=gnu++14 \
335 -I$(shell $(LLVM_CONFIG) --includedir) \
336 -L$(shell $(LLVM_CONFIG) --libdir) \
337 $(shell $(LLVM_CONFIG) --libs Core BPF) \
338 $(shell $(LLVM_CONFIG) --system-libs) \
339 > $(@:.bin=.make.output) 2>&1
341 $(OUTPUT)test-llvm-version.bin:
342 $(BUILDXX) -std=gnu++14 \
343 -I$(shell $(LLVM_CONFIG) --includedir) \
344 > $(@:.bin=.make.output) 2>&1
346 $(OUTPUT)test-clang.bin:
347 $(BUILDXX) -std=gnu++14 \
348 -I$(shell $(LLVM_CONFIG) --includedir) \
349 -L$(shell $(LLVM_CONFIG) --libdir) \
350 -Wl,--start-group -lclangBasic -lclangDriver \
351 -lclangFrontend -lclangEdit -lclangLex \
352 -lclangAST -Wl,--end-group \
353 $(shell $(LLVM_CONFIG) --libs Core option) \
354 $(shell $(LLVM_CONFIG) --system-libs) \
355 > $(@:.bin=.make.output) 2>&1
357 -include $(OUTPUT)*.d
359 $(OUTPUT)test-libaio.bin:
362 $(OUTPUT)test-libzstd.bin:
365 $(OUTPUT)test-clang-bpf-co-re.bin:
366 $(CLANG) -S -g -target bpf -o - $(patsubst %.bin,%.c,$(@F)) | \
369 $(OUTPUT)test-file-handle.bin:
372 $(OUTPUT)test-libpfm4.bin:
375 ###############################
378 rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)