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