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