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