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