Commit | Line | Data |
---|---|---|
b2441318 | 1 | # SPDX-License-Identifier: GPL-2.0 |
211a741c SD |
2 | include ../../scripts/Makefile.include |
3 | ||
2fedf79b JO |
4 | FILES= \ |
5 | test-all.bin \ | |
6 | test-backtrace.bin \ | |
7 | test-bionic.bin \ | |
8 | test-dwarf.bin \ | |
9 | test-dwarf_getlocations.bin \ | |
11c6cbe7 | 10 | test-eventfd.bin \ |
2fedf79b | 11 | test-fortify-source.bin \ |
8feb8efe | 12 | test-get_current_dir_name.bin \ |
2fedf79b JO |
13 | test-glibc.bin \ |
14 | test-gtk2.bin \ | |
15 | test-gtk2-infobar.bin \ | |
16 | test-hello.bin \ | |
17 | test-libaudit.bin \ | |
18 | test-libbfd.bin \ | |
e71e19a9 | 19 | test-libbfd-buildid.bin \ |
fb982666 | 20 | test-disassembler-four-args.bin \ |
cfd59ca9 | 21 | test-disassembler-init-styled.bin \ |
531b014e | 22 | test-reallocarray.bin \ |
14541b1e SF |
23 | test-libbfd-liberty.bin \ |
24 | test-libbfd-liberty-z.bin \ | |
2fedf79b | 25 | test-cplus-demangle.bin \ |
4c72e2b3 | 26 | test-cxa-demangle.bin \ |
74d5f3d0 | 27 | test-libcap.bin \ |
2fedf79b JO |
28 | test-libelf.bin \ |
29 | test-libelf-getphdrnum.bin \ | |
30 | test-libelf-gelf_getnote.bin \ | |
31 | test-libelf-getshdrstrndx.bin \ | |
c7a14fdc | 32 | test-libdebuginfod.bin \ |
2fedf79b JO |
33 | test-libnuma.bin \ |
34 | test-numa_num_possible_cpus.bin \ | |
35 | test-libperl.bin \ | |
36 | test-libpython.bin \ | |
2fedf79b | 37 | test-libslang.bin \ |
cbefd24f | 38 | test-libslang-include-subdir.bin \ |
56d32d4c | 39 | test-libtraceevent.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 \ | |
54 | test-libdw-dwarf-unwind.bin \ | |
55 | test-libbabeltrace.bin \ | |
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 \ | |
2a07d814 | 74 | test-llvm-version.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 |
81 | FILES := $(addprefix $(OUTPUT),$(FILES)) |
82 | ||
9961aa66 | 83 | PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config |
8b6eb56a | 84 | |
b6aa9979 IM |
85 | all: $(FILES) |
86 | ||
9961aa66 | 87 | __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) |
1925459b | 88 | BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 |
629b98e2 RS |
89 | BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl |
90 | 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 | |
b6aa9979 | 91 | |
9961aa66 | 92 | __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) |
87095f7d WN |
93 | BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 |
94 | ||
b6aa9979 IM |
95 | ############################### |
96 | ||
1925459b | 97 | $(OUTPUT)test-all.bin: |
629b98e2 | 98 | $(BUILD_ALL) || $(BUILD_ALL) -lopcodes -liberty |
baa9c30e | 99 | |
1925459b | 100 | $(OUTPUT)test-hello.bin: |
b6aa9979 IM |
101 | $(BUILD) |
102 | ||
1925459b | 103 | $(OUTPUT)test-pthread-attr-setaffinity-np.bin: |
b49f1a4b | 104 | $(BUILD) -D_GNU_SOURCE -lpthread |
459a3df7 | 105 | |
25ab5abf ACM |
106 | $(OUTPUT)test-pthread-barrier.bin: |
107 | $(BUILD) -lpthread | |
108 | ||
1925459b | 109 | $(OUTPUT)test-stackprotector-all.bin: |
b49f1a4b | 110 | $(BUILD) -fstack-protector-all |
90ac5422 | 111 | |
1925459b | 112 | $(OUTPUT)test-fortify-source.bin: |
b49f1a4b | 113 | $(BUILD) -O2 -D_FORTIFY_SOURCE=2 |
1ea6f99e | 114 | |
1925459b | 115 | $(OUTPUT)test-bionic.bin: |
78e9d655 IM |
116 | $(BUILD) |
117 | ||
74d5f3d0 IL |
118 | $(OUTPUT)test-libcap.bin: |
119 | $(BUILD) -lcap | |
120 | ||
1925459b | 121 | $(OUTPUT)test-libelf.bin: |
8f7f8005 IM |
122 | $(BUILD) -lelf |
123 | ||
11c6cbe7 ACM |
124 | $(OUTPUT)test-eventfd.bin: |
125 | $(BUILD) | |
126 | ||
8feb8efe ACM |
127 | $(OUTPUT)test-get_current_dir_name.bin: |
128 | $(BUILD) | |
129 | ||
1925459b | 130 | $(OUTPUT)test-glibc.bin: |
e12762cf IM |
131 | $(BUILD) |
132 | ||
9e03608e ACM |
133 | $(OUTPUT)test-scandirat.bin: |
134 | $(BUILD) | |
135 | ||
120010cb ACM |
136 | $(OUTPUT)test-sched_getcpu.bin: |
137 | $(BUILD) | |
138 | ||
86bcdb5a ACM |
139 | $(OUTPUT)test-setns.bin: |
140 | $(BUILD) | |
141 | ||
aa6292f4 MP |
142 | $(OUTPUT)test-libopencsd.bin: |
143 | $(BUILD) # -lopencsd_c_api -lopencsd provided by | |
144 | # $(FEATURE_CHECK_LDFLAGS-libopencsd) | |
145 | ||
7aec51cb AK |
146 | DWARFLIBS := -ldw |
147 | ifeq ($(findstring -static,${LDFLAGS}),-static) | |
148 | DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 | |
149 | endif | |
150 | ||
1925459b | 151 | $(OUTPUT)test-dwarf.bin: |
7aec51cb | 152 | $(BUILD) $(DWARFLIBS) |
8295d4e2 | 153 | |
bd0419e2 ACM |
154 | $(OUTPUT)test-dwarf_getlocations.bin: |
155 | $(BUILD) $(DWARFLIBS) | |
156 | ||
1925459b | 157 | $(OUTPUT)test-libelf-getphdrnum.bin: |
b7bcef6f IM |
158 | $(BUILD) -lelf |
159 | ||
1c1a3a47 ACM |
160 | $(OUTPUT)test-libelf-gelf_getnote.bin: |
161 | $(BUILD) -lelf | |
162 | ||
2492c465 ACM |
163 | $(OUTPUT)test-libelf-getshdrstrndx.bin: |
164 | $(BUILD) -lelf | |
165 | ||
c7a14fdc FCE |
166 | $(OUTPUT)test-libdebuginfod.bin: |
167 | $(BUILD) -ldebuginfod | |
168 | ||
1925459b | 169 | $(OUTPUT)test-libnuma.bin: |
3ae069cf IM |
170 | $(BUILD) -lnuma |
171 | ||
1925459b | 172 | $(OUTPUT)test-numa_num_possible_cpus.bin: |
f8ac8606 ACM |
173 | $(BUILD) -lnuma |
174 | ||
1925459b | 175 | $(OUTPUT)test-libunwind.bin: |
1448fef4 | 176 | $(BUILD) -lelf |
058f952d | 177 | |
1925459b | 178 | $(OUTPUT)test-libunwind-debug-frame.bin: |
1448fef4 | 179 | $(BUILD) -lelf |
b1d96000 HK |
180 | $(OUTPUT)test-libunwind-x86.bin: |
181 | $(BUILD) -lelf -lunwind-x86 | |
182 | ||
183 | $(OUTPUT)test-libunwind-x86_64.bin: | |
184 | $(BUILD) -lelf -lunwind-x86_64 | |
185 | ||
186 | $(OUTPUT)test-libunwind-arm.bin: | |
187 | $(BUILD) -lelf -lunwind-arm | |
188 | ||
189 | $(OUTPUT)test-libunwind-aarch64.bin: | |
190 | $(BUILD) -lelf -lunwind-aarch64 | |
191 | ||
f9be7eef HK |
192 | $(OUTPUT)test-libunwind-debug-frame-arm.bin: |
193 | $(BUILD) -lelf -lunwind-arm | |
194 | ||
195 | $(OUTPUT)test-libunwind-debug-frame-aarch64.bin: | |
196 | $(BUILD) -lelf -lunwind-aarch64 | |
e310718d | 197 | |
1925459b | 198 | $(OUTPUT)test-libaudit.bin: |
d795a658 IM |
199 | $(BUILD) -laudit |
200 | ||
1925459b | 201 | $(OUTPUT)test-libslang.bin: |
1955c8cf | 202 | $(BUILD) -lslang |
b9498b50 | 203 | |
cbefd24f ACM |
204 | $(OUTPUT)test-libslang-include-subdir.bin: |
205 | $(BUILD) -lslang | |
206 | ||
56d32d4c MP |
207 | $(OUTPUT)test-libtraceevent.bin: |
208 | $(BUILD) -ltraceevent | |
209 | ||
b758a61b | 210 | $(OUTPUT)test-libtracefs.bin: |
a87834d1 | 211 | $(BUILD) $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null) -ltracefs |
b758a61b | 212 | |
8ee46460 SE |
213 | $(OUTPUT)test-libcrypto.bin: |
214 | $(BUILD) -lcrypto | |
215 | ||
1925459b | 216 | $(OUTPUT)test-gtk2.bin: |
93e843f9 | 217 | $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations |
7ef9e055 | 218 | |
1925459b | 219 | $(OUTPUT)test-gtk2-infobar.bin: |
a8a5cd8b | 220 | $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) |
c7a79e96 | 221 | |
7181a671 IM |
222 | grep-libs = $(filter -l%,$(1)) |
223 | strip-libs = $(filter-out -l%,$(1)) | |
224 | ||
225 | PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) | |
226 | PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) | |
227 | PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) | |
541f695c | 228 | PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) |
7181a671 IM |
229 | FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) |
230 | ||
41caff45 ACM |
231 | ifeq ($(CC_NO_CLANG), 0) |
232 | PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) | |
233 | PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS)) | |
234 | PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) | |
235 | FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro | |
236 | endif | |
237 | ||
1925459b | 238 | $(OUTPUT)test-libperl.bin: |
7181a671 IM |
239 | $(BUILD) $(FLAGS_PERL_EMBED) |
240 | ||
1925459b | 241 | $(OUTPUT)test-libpython.bin: |
7be6b316 | 242 | $(BUILD) $(FLAGS_PYTHON_EMBED) |
9734163b | 243 | |
1925459b | 244 | $(OUTPUT)test-libbfd.bin: |
629b98e2 | 245 | $(BUILD_BFD) |
3b7646e4 | 246 | |
e71e19a9 | 247 | $(OUTPUT)test-libbfd-buildid.bin: |
629b98e2 | 248 | $(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz |
e71e19a9 | 249 | |
fb982666 | 250 | $(OUTPUT)test-disassembler-four-args.bin: |
629b98e2 RS |
251 | $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \ |
252 | $(BUILD_BFD) -lopcodes -liberty -lz | |
fb982666 | 253 | |
cfd59ca9 | 254 | $(OUTPUT)test-disassembler-init-styled.bin: |
629b98e2 RS |
255 | $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \ |
256 | $(BUILD_BFD) -lopcodes -liberty -lz | |
cfd59ca9 | 257 | |
531b014e JK |
258 | $(OUTPUT)test-reallocarray.bin: |
259 | $(BUILD) | |
260 | ||
14541b1e | 261 | $(OUTPUT)test-libbfd-liberty.bin: |
1925459b | 262 | $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty |
1c47661a | 263 | |
14541b1e | 264 | $(OUTPUT)test-libbfd-liberty-z.bin: |
1925459b | 265 | $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz |
1c47661a | 266 | |
1925459b | 267 | $(OUTPUT)test-cplus-demangle.bin: |
1c47661a IM |
268 | $(BUILD) -liberty |
269 | ||
4c72e2b3 IR |
270 | $(OUTPUT)test-cxa-demangle.bin: |
271 | $(BUILDXX) | |
272 | ||
1925459b | 273 | $(OUTPUT)test-backtrace.bin: |
4cc9117a IM |
274 | $(BUILD) |
275 | ||
1925459b | 276 | $(OUTPUT)test-timerfd.bin: |
87419c9a DA |
277 | $(BUILD) |
278 | ||
1925459b | 279 | $(OUTPUT)test-libdw-dwarf-unwind.bin: |
53d0a573 JO |
280 | $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind) |
281 | ||
1925459b | 282 | $(OUTPUT)test-libbabeltrace.bin: |
53d0a573 | 283 | $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace) |
45757895 | 284 | |
1925459b JP |
285 | $(OUTPUT)test-compile-32.bin: |
286 | $(CC) -m32 -o $@ test-compile.c | |
e477f3f0 | 287 | |
1925459b JP |
288 | $(OUTPUT)test-compile-x32.bin: |
289 | $(CC) -mx32 -o $@ test-compile.c | |
e477f3f0 | 290 | |
1925459b | 291 | $(OUTPUT)test-zlib.bin: |
e92ce12e NK |
292 | $(BUILD) -lz |
293 | ||
1925459b | 294 | $(OUTPUT)test-lzma.bin: |
6c6f0f61 JO |
295 | $(BUILD) -llzma |
296 | ||
1925459b | 297 | $(OUTPUT)test-get_cpuid.bin: |
b0063dbf ACM |
298 | $(BUILD) |
299 | ||
1925459b | 300 | $(OUTPUT)test-bpf.bin: |
1b76c13e WN |
301 | $(BUILD) |
302 | ||
7b65e203 JO |
303 | $(OUTPUT)test-libbpf.bin: |
304 | $(BUILD) -lbpf | |
305 | ||
0ae065a5 ACM |
306 | $(OUTPUT)test-libbpf-btf__load_from_kernel_by_id.bin: |
307 | $(BUILD) -lbpf | |
308 | ||
5c83eff3 JO |
309 | $(OUTPUT)test-libbpf-bpf_prog_load.bin: |
310 | $(BUILD) -lbpf | |
311 | ||
df76e003 ACM |
312 | $(OUTPUT)test-libbpf-bpf_map_create.bin: |
313 | $(BUILD) -lbpf | |
314 | ||
8916d725 JO |
315 | $(OUTPUT)test-libbpf-bpf_object__next_program.bin: |
316 | $(BUILD) -lbpf | |
317 | ||
739c9180 JO |
318 | $(OUTPUT)test-libbpf-bpf_object__next_map.bin: |
319 | $(BUILD) -lbpf | |
320 | ||
f1bdebbb ACM |
321 | $(OUTPUT)test-libbpf-bpf_program__set_insns.bin: |
322 | $(BUILD) -lbpf | |
323 | ||
982be477 JO |
324 | $(OUTPUT)test-libbpf-btf__raw_data.bin: |
325 | $(BUILD) -lbpf | |
326 | ||
e26e63be MH |
327 | $(OUTPUT)test-sdt.bin: |
328 | $(BUILD) | |
329 | ||
87095f7d WN |
330 | $(OUTPUT)test-cxx.bin: |
331 | $(BUILDXX) -std=gnu++11 | |
332 | ||
4541a8bb ACM |
333 | $(OUTPUT)test-gettid.bin: |
334 | $(BUILD) | |
335 | ||
285932a2 JO |
336 | $(OUTPUT)test-jvmti.bin: |
337 | $(BUILD) | |
338 | ||
dd1d0044 JO |
339 | $(OUTPUT)test-jvmti-cmlr.bin: |
340 | $(BUILD) | |
341 | ||
cb40d55b | 342 | $(OUTPUT)test-llvm.bin: |
d0d0f0c1 | 343 | $(BUILDXX) -std=gnu++14 \ |
cb40d55b WN |
344 | -I$(shell $(LLVM_CONFIG) --includedir) \ |
345 | -L$(shell $(LLVM_CONFIG) --libdir) \ | |
346 | $(shell $(LLVM_CONFIG) --libs Core BPF) \ | |
5fb3d8b7 JO |
347 | $(shell $(LLVM_CONFIG) --system-libs) \ |
348 | > $(@:.bin=.make.output) 2>&1 | |
cb40d55b | 349 | |
a940cad3 | 350 | $(OUTPUT)test-llvm-version.bin: |
d0d0f0c1 | 351 | $(BUILDXX) -std=gnu++14 \ |
5fb3d8b7 JO |
352 | -I$(shell $(LLVM_CONFIG) --includedir) \ |
353 | > $(@:.bin=.make.output) 2>&1 | |
a940cad3 | 354 | |
c7fb4f62 | 355 | $(OUTPUT)test-clang.bin: |
d0d0f0c1 | 356 | $(BUILDXX) -std=gnu++14 \ |
c7fb4f62 WN |
357 | -I$(shell $(LLVM_CONFIG) --includedir) \ |
358 | -L$(shell $(LLVM_CONFIG) --libdir) \ | |
359 | -Wl,--start-group -lclangBasic -lclangDriver \ | |
360 | -lclangFrontend -lclangEdit -lclangLex \ | |
361 | -lclangAST -Wl,--end-group \ | |
362 | $(shell $(LLVM_CONFIG) --libs Core option) \ | |
5fb3d8b7 JO |
363 | $(shell $(LLVM_CONFIG) --system-libs) \ |
364 | > $(@:.bin=.make.output) 2>&1 | |
c7fb4f62 | 365 | |
1925459b | 366 | -include $(OUTPUT)*.d |
8b6eb56a | 367 | |
2a07d814 AB |
368 | $(OUTPUT)test-libaio.bin: |
369 | $(BUILD) -lrt | |
370 | ||
3b1c5d96 AB |
371 | $(OUTPUT)test-libzstd.bin: |
372 | $(BUILD) -lzstd | |
373 | ||
05aca6da | 374 | $(OUTPUT)test-clang-bpf-co-re.bin: |
14e5728f SL |
375 | $(CLANG) -S -g -target bpf -o - $(patsubst %.bin,%.c,$(@F)) | \ |
376 | grep BTF_KIND_VAR | |
377 | ||
49f550ea NK |
378 | $(OUTPUT)test-file-handle.bin: |
379 | $(BUILD) | |
14e5728f | 380 | |
5ef86146 SE |
381 | $(OUTPUT)test-libpfm4.bin: |
382 | $(BUILD) -lpfm | |
383 | ||
b6aa9979 IM |
384 | ############################### |
385 | ||
386 | clean: | |
1925459b | 387 | rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output) |