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