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