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