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