Makefile (10558B)
1# SPDX-License-Identifier: GPL-2.0 2include ../../scripts/Makefile.include 3 4FILES= \ 5 test-all.bin \ 6 test-backtrace.bin \ 7 test-bionic.bin \ 8 test-dwarf.bin \ 9 test-dwarf_getlocations.bin \ 10 test-eventfd.bin \ 11 test-fortify-source.bin \ 12 test-get_current_dir_name.bin \ 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 \ 19 test-libbfd-buildid.bin \ 20 test-disassembler-four-args.bin \ 21 test-reallocarray.bin \ 22 test-libbfd-liberty.bin \ 23 test-libbfd-liberty-z.bin \ 24 test-cplus-demangle.bin \ 25 test-libcap.bin \ 26 test-libelf.bin \ 27 test-libelf-getphdrnum.bin \ 28 test-libelf-gelf_getnote.bin \ 29 test-libelf-getshdrstrndx.bin \ 30 test-libdebuginfod.bin \ 31 test-libnuma.bin \ 32 test-numa_num_possible_cpus.bin \ 33 test-libperl.bin \ 34 test-libpython.bin \ 35 test-libslang.bin \ 36 test-libslang-include-subdir.bin \ 37 test-libtraceevent.bin \ 38 test-libtracefs.bin \ 39 test-libcrypto.bin \ 40 test-libunwind.bin \ 41 test-libunwind-debug-frame.bin \ 42 test-libunwind-x86.bin \ 43 test-libunwind-x86_64.bin \ 44 test-libunwind-arm.bin \ 45 test-libunwind-aarch64.bin \ 46 test-libunwind-debug-frame-arm.bin \ 47 test-libunwind-debug-frame-aarch64.bin \ 48 test-pthread-attr-setaffinity-np.bin \ 49 test-pthread-barrier.bin \ 50 test-stackprotector-all.bin \ 51 test-timerfd.bin \ 52 test-libdw-dwarf-unwind.bin \ 53 test-libbabeltrace.bin \ 54 test-compile-32.bin \ 55 test-compile-x32.bin \ 56 test-zlib.bin \ 57 test-lzma.bin \ 58 test-bpf.bin \ 59 test-libbpf.bin \ 60 test-libbpf-btf__load_from_kernel_by_id.bin \ 61 test-libbpf-bpf_prog_load.bin \ 62 test-libbpf-bpf_map_create.bin \ 63 test-libbpf-bpf_object__next_program.bin \ 64 test-libbpf-bpf_object__next_map.bin \ 65 test-libbpf-btf__raw_data.bin \ 66 test-get_cpuid.bin \ 67 test-sdt.bin \ 68 test-cxx.bin \ 69 test-gettid.bin \ 70 test-jvmti.bin \ 71 test-jvmti-cmlr.bin \ 72 test-sched_getcpu.bin \ 73 test-setns.bin \ 74 test-libopencsd.bin \ 75 test-clang.bin \ 76 test-llvm.bin \ 77 test-llvm-version.bin \ 78 test-libaio.bin \ 79 test-libzstd.bin \ 80 test-clang-bpf-co-re.bin \ 81 test-file-handle.bin \ 82 test-libpfm4.bin 83 84FILES := $(addprefix $(OUTPUT),$(FILES)) 85 86PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config 87 88all: $(FILES) 89 90__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) 91 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 92 93__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) 94 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 95 96############################### 97 98$(OUTPUT)test-all.bin: 99 $(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 100 101$(OUTPUT)test-hello.bin: 102 $(BUILD) 103 104$(OUTPUT)test-pthread-attr-setaffinity-np.bin: 105 $(BUILD) -D_GNU_SOURCE -lpthread 106 107$(OUTPUT)test-pthread-barrier.bin: 108 $(BUILD) -lpthread 109 110$(OUTPUT)test-stackprotector-all.bin: 111 $(BUILD) -fstack-protector-all 112 113$(OUTPUT)test-fortify-source.bin: 114 $(BUILD) -O2 -D_FORTIFY_SOURCE=2 115 116$(OUTPUT)test-bionic.bin: 117 $(BUILD) 118 119$(OUTPUT)test-libcap.bin: 120 $(BUILD) -lcap 121 122$(OUTPUT)test-libelf.bin: 123 $(BUILD) -lelf 124 125$(OUTPUT)test-eventfd.bin: 126 $(BUILD) 127 128$(OUTPUT)test-get_current_dir_name.bin: 129 $(BUILD) 130 131$(OUTPUT)test-glibc.bin: 132 $(BUILD) 133 134$(OUTPUT)test-sched_getcpu.bin: 135 $(BUILD) 136 137$(OUTPUT)test-setns.bin: 138 $(BUILD) 139 140$(OUTPUT)test-libopencsd.bin: 141 $(BUILD) # -lopencsd_c_api -lopencsd provided by 142 # $(FEATURE_CHECK_LDFLAGS-libopencsd) 143 144DWARFLIBS := -ldw 145ifeq ($(findstring -static,${LDFLAGS}),-static) 146DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 147endif 148 149$(OUTPUT)test-dwarf.bin: 150 $(BUILD) $(DWARFLIBS) 151 152$(OUTPUT)test-dwarf_getlocations.bin: 153 $(BUILD) $(DWARFLIBS) 154 155$(OUTPUT)test-libelf-getphdrnum.bin: 156 $(BUILD) -lelf 157 158$(OUTPUT)test-libelf-gelf_getnote.bin: 159 $(BUILD) -lelf 160 161$(OUTPUT)test-libelf-getshdrstrndx.bin: 162 $(BUILD) -lelf 163 164$(OUTPUT)test-libdebuginfod.bin: 165 $(BUILD) -ldebuginfod 166 167$(OUTPUT)test-libnuma.bin: 168 $(BUILD) -lnuma 169 170$(OUTPUT)test-numa_num_possible_cpus.bin: 171 $(BUILD) -lnuma 172 173$(OUTPUT)test-libunwind.bin: 174 $(BUILD) -lelf 175 176$(OUTPUT)test-libunwind-debug-frame.bin: 177 $(BUILD) -lelf 178$(OUTPUT)test-libunwind-x86.bin: 179 $(BUILD) -lelf -lunwind-x86 180 181$(OUTPUT)test-libunwind-x86_64.bin: 182 $(BUILD) -lelf -lunwind-x86_64 183 184$(OUTPUT)test-libunwind-arm.bin: 185 $(BUILD) -lelf -lunwind-arm 186 187$(OUTPUT)test-libunwind-aarch64.bin: 188 $(BUILD) -lelf -lunwind-aarch64 189 190$(OUTPUT)test-libunwind-debug-frame-arm.bin: 191 $(BUILD) -lelf -lunwind-arm 192 193$(OUTPUT)test-libunwind-debug-frame-aarch64.bin: 194 $(BUILD) -lelf -lunwind-aarch64 195 196$(OUTPUT)test-libaudit.bin: 197 $(BUILD) -laudit 198 199$(OUTPUT)test-libslang.bin: 200 $(BUILD) -lslang 201 202$(OUTPUT)test-libslang-include-subdir.bin: 203 $(BUILD) -lslang 204 205$(OUTPUT)test-libtraceevent.bin: 206 $(BUILD) -ltraceevent 207 208$(OUTPUT)test-libtracefs.bin: 209 $(BUILD) -ltracefs 210 211$(OUTPUT)test-libcrypto.bin: 212 $(BUILD) -lcrypto 213 214$(OUTPUT)test-gtk2.bin: 215 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations 216 217$(OUTPUT)test-gtk2-infobar.bin: 218 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) 219 220grep-libs = $(filter -l%,$(1)) 221strip-libs = $(filter-out -l%,$(1)) 222 223PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) 224PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) 225PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) 226PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) 227FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) 228 229ifeq ($(CC_NO_CLANG), 0) 230 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) 231 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS)) 232 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) 233 FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro 234endif 235 236$(OUTPUT)test-libperl.bin: 237 $(BUILD) $(FLAGS_PERL_EMBED) 238 239$(OUTPUT)test-libpython.bin: 240 $(BUILD) $(FLAGS_PYTHON_EMBED) 241 242$(OUTPUT)test-libbfd.bin: 243 $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl 244 245$(OUTPUT)test-libbfd-buildid.bin: 246 $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl 247 248$(OUTPUT)test-disassembler-four-args.bin: 249 $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes 250 251$(OUTPUT)test-reallocarray.bin: 252 $(BUILD) 253 254$(OUTPUT)test-libbfd-liberty.bin: 255 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty 256 257$(OUTPUT)test-libbfd-liberty-z.bin: 258 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz 259 260$(OUTPUT)test-cplus-demangle.bin: 261 $(BUILD) -liberty 262 263$(OUTPUT)test-backtrace.bin: 264 $(BUILD) 265 266$(OUTPUT)test-timerfd.bin: 267 $(BUILD) 268 269$(OUTPUT)test-libdw-dwarf-unwind.bin: 270 $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind) 271 272$(OUTPUT)test-libbabeltrace.bin: 273 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace) 274 275$(OUTPUT)test-compile-32.bin: 276 $(CC) -m32 -o $@ test-compile.c 277 278$(OUTPUT)test-compile-x32.bin: 279 $(CC) -mx32 -o $@ test-compile.c 280 281$(OUTPUT)test-zlib.bin: 282 $(BUILD) -lz 283 284$(OUTPUT)test-lzma.bin: 285 $(BUILD) -llzma 286 287$(OUTPUT)test-get_cpuid.bin: 288 $(BUILD) 289 290$(OUTPUT)test-bpf.bin: 291 $(BUILD) 292 293$(OUTPUT)test-libbpf.bin: 294 $(BUILD) -lbpf 295 296$(OUTPUT)test-libbpf-btf__load_from_kernel_by_id.bin: 297 $(BUILD) -lbpf 298 299$(OUTPUT)test-libbpf-bpf_prog_load.bin: 300 $(BUILD) -lbpf 301 302$(OUTPUT)test-libbpf-bpf_map_create.bin: 303 $(BUILD) -lbpf 304 305$(OUTPUT)test-libbpf-bpf_object__next_program.bin: 306 $(BUILD) -lbpf 307 308$(OUTPUT)test-libbpf-bpf_object__next_map.bin: 309 $(BUILD) -lbpf 310 311$(OUTPUT)test-libbpf-btf__raw_data.bin: 312 $(BUILD) -lbpf 313 314$(OUTPUT)test-sdt.bin: 315 $(BUILD) 316 317$(OUTPUT)test-cxx.bin: 318 $(BUILDXX) -std=gnu++11 319 320$(OUTPUT)test-gettid.bin: 321 $(BUILD) 322 323$(OUTPUT)test-jvmti.bin: 324 $(BUILD) 325 326$(OUTPUT)test-jvmti-cmlr.bin: 327 $(BUILD) 328 329$(OUTPUT)test-llvm.bin: 330 $(BUILDXX) -std=gnu++14 \ 331 -I$(shell $(LLVM_CONFIG) --includedir) \ 332 -L$(shell $(LLVM_CONFIG) --libdir) \ 333 $(shell $(LLVM_CONFIG) --libs Core BPF) \ 334 $(shell $(LLVM_CONFIG) --system-libs) \ 335 > $(@:.bin=.make.output) 2>&1 336 337$(OUTPUT)test-llvm-version.bin: 338 $(BUILDXX) -std=gnu++14 \ 339 -I$(shell $(LLVM_CONFIG) --includedir) \ 340 > $(@:.bin=.make.output) 2>&1 341 342$(OUTPUT)test-clang.bin: 343 $(BUILDXX) -std=gnu++14 \ 344 -I$(shell $(LLVM_CONFIG) --includedir) \ 345 -L$(shell $(LLVM_CONFIG) --libdir) \ 346 -Wl,--start-group -lclangBasic -lclangDriver \ 347 -lclangFrontend -lclangEdit -lclangLex \ 348 -lclangAST -Wl,--end-group \ 349 $(shell $(LLVM_CONFIG) --libs Core option) \ 350 $(shell $(LLVM_CONFIG) --system-libs) \ 351 > $(@:.bin=.make.output) 2>&1 352 353-include $(OUTPUT)*.d 354 355$(OUTPUT)test-libaio.bin: 356 $(BUILD) -lrt 357 358$(OUTPUT)test-libzstd.bin: 359 $(BUILD) -lzstd 360 361$(OUTPUT)test-clang-bpf-co-re.bin: 362 $(CLANG) -S -g -target bpf -o - $(patsubst %.bin,%.c,$(@F)) | \ 363 grep BTF_KIND_VAR 364 365$(OUTPUT)test-file-handle.bin: 366 $(BUILD) 367 368$(OUTPUT)test-libpfm4.bin: 369 $(BUILD) -lpfm 370 371############################### 372 373clean: 374 rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)