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