Makefile 9.3 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3 4 5 6 7
FILES=                                          \
         test-all.bin                           \
         test-backtrace.bin                     \
         test-bionic.bin                        \
         test-dwarf.bin                         \
         test-dwarf_getlocations.bin            \
8
         test-eventfd.bin                       \
9 10
         test-fortify-source.bin                \
         test-sync-compare-and-swap.bin         \
11
         test-get_current_dir_name.bin          \
12 13 14 15 16 17
         test-glibc.bin                         \
         test-gtk2.bin                          \
         test-gtk2-infobar.bin                  \
         test-hello.bin                         \
         test-libaudit.bin                      \
         test-libbfd.bin                        \
18
         test-disassembler-four-args.bin        \
19
         test-reallocarray.bin			\
20 21
         test-libbfd-liberty.bin                \
         test-libbfd-liberty-z.bin              \
22
         test-cplus-demangle.bin                \
23
         test-libcap.bin			\
24 25 26 27 28 29 30 31 32 33 34
         test-libelf.bin                        \
         test-libelf-getphdrnum.bin             \
         test-libelf-gelf_getnote.bin           \
         test-libelf-getshdrstrndx.bin          \
         test-libelf-mmap.bin                   \
         test-libnuma.bin                       \
         test-numa_num_possible_cpus.bin        \
         test-libperl.bin                       \
         test-libpython.bin                     \
         test-libpython-version.bin             \
         test-libslang.bin                      \
35
         test-libslang-include-subdir.bin       \
36 37 38 39 40 41 42 43 44 45
         test-libcrypto.bin                     \
         test-libunwind.bin                     \
         test-libunwind-debug-frame.bin         \
         test-libunwind-x86.bin                 \
         test-libunwind-x86_64.bin              \
         test-libunwind-arm.bin                 \
         test-libunwind-aarch64.bin             \
         test-libunwind-debug-frame-arm.bin     \
         test-libunwind-debug-frame-aarch64.bin \
         test-pthread-attr-setaffinity-np.bin   \
46
         test-pthread-barrier.bin		\
47 48 49 50 51 52 53 54 55
         test-stackprotector-all.bin            \
         test-timerfd.bin                       \
         test-libdw-dwarf-unwind.bin            \
         test-libbabeltrace.bin                 \
         test-compile-32.bin                    \
         test-compile-x32.bin                   \
         test-zlib.bin                          \
         test-lzma.bin                          \
         test-bpf.bin                           \
56
         test-libbpf.bin                        \
57 58 59
         test-get_cpuid.bin                     \
         test-sdt.bin                           \
         test-cxx.bin                           \
60
         test-gettid.bin			\
61
         test-jvmti.bin				\
J
Jiri Olsa 已提交
62
         test-jvmti-cmlr.bin			\
63
         test-sched_getcpu.bin			\
64
         test-setns.bin				\
65 66 67
         test-libopencsd.bin			\
         test-clang.bin				\
         test-llvm.bin				\
68
         test-llvm-version.bin			\
69
         test-libaio.bin			\
70
         test-libzstd.bin			\
71
         test-clang-bpf-co-re.bin		\
72 73
         test-file-handle.bin			\
         test-libpfm4.bin
74

75 76
FILES := $(addprefix $(OUTPUT),$(FILES))

77 78 79
CC ?= $(CROSS_COMPILE)gcc
CXX ?= $(CROSS_COMPILE)g++
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
80
LLVM_CONFIG ?= llvm-config
81
CLANG ?= clang
82

83 84
all: $(FILES)

85
__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
86
  BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
87

88
__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
89 90
  BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1

91 92
###############################

93
$(OUTPUT)test-all.bin:
94
	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -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
95

96
$(OUTPUT)test-hello.bin:
97 98
	$(BUILD)

99
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
100
	$(BUILD) -D_GNU_SOURCE -lpthread
101

102 103 104
$(OUTPUT)test-pthread-barrier.bin:
	$(BUILD) -lpthread

105
$(OUTPUT)test-stackprotector-all.bin:
106
	$(BUILD) -fstack-protector-all
107

108
$(OUTPUT)test-fortify-source.bin:
109
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
110

111
$(OUTPUT)test-bionic.bin:
112 113
	$(BUILD)

114 115 116
$(OUTPUT)test-libcap.bin:
	$(BUILD) -lcap

117
$(OUTPUT)test-libelf.bin:
118 119
	$(BUILD) -lelf

120 121 122
$(OUTPUT)test-eventfd.bin:
	$(BUILD)

123 124 125
$(OUTPUT)test-get_current_dir_name.bin:
	$(BUILD)

126
$(OUTPUT)test-glibc.bin:
127 128
	$(BUILD)

129 130 131
$(OUTPUT)test-sched_getcpu.bin:
	$(BUILD)

132 133 134
$(OUTPUT)test-setns.bin:
	$(BUILD)

135 136 137 138
$(OUTPUT)test-libopencsd.bin:
	$(BUILD) # -lopencsd_c_api -lopencsd provided by
		 # $(FEATURE_CHECK_LDFLAGS-libopencsd)

139 140 141 142 143
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

144
$(OUTPUT)test-dwarf.bin:
145
	$(BUILD) $(DWARFLIBS)
146

147 148 149
$(OUTPUT)test-dwarf_getlocations.bin:
	$(BUILD) $(DWARFLIBS)

150
$(OUTPUT)test-libelf-mmap.bin:
151 152
	$(BUILD) -lelf

153
$(OUTPUT)test-libelf-getphdrnum.bin:
154 155
	$(BUILD) -lelf

156 157 158
$(OUTPUT)test-libelf-gelf_getnote.bin:
	$(BUILD) -lelf

159 160 161
$(OUTPUT)test-libelf-getshdrstrndx.bin:
	$(BUILD) -lelf

162
$(OUTPUT)test-libnuma.bin:
163 164
	$(BUILD) -lnuma

165
$(OUTPUT)test-numa_num_possible_cpus.bin:
166 167
	$(BUILD) -lnuma

168
$(OUTPUT)test-libunwind.bin:
169
	$(BUILD) -lelf
170

171
$(OUTPUT)test-libunwind-debug-frame.bin:
172
	$(BUILD) -lelf
173 174 175 176 177 178 179 180 181 182 183 184
$(OUTPUT)test-libunwind-x86.bin:
	$(BUILD) -lelf -lunwind-x86

$(OUTPUT)test-libunwind-x86_64.bin:
	$(BUILD) -lelf -lunwind-x86_64

$(OUTPUT)test-libunwind-arm.bin:
	$(BUILD) -lelf -lunwind-arm

$(OUTPUT)test-libunwind-aarch64.bin:
	$(BUILD) -lelf -lunwind-aarch64

185 186 187 188 189
$(OUTPUT)test-libunwind-debug-frame-arm.bin:
	$(BUILD) -lelf -lunwind-arm

$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
	$(BUILD) -lelf -lunwind-aarch64
190

191
$(OUTPUT)test-libaudit.bin:
192 193
	$(BUILD) -laudit

194
$(OUTPUT)test-libslang.bin:
195
	$(BUILD) -lslang
196

197 198 199
$(OUTPUT)test-libslang-include-subdir.bin:
	$(BUILD) -lslang

200 201 202
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

203
$(OUTPUT)test-gtk2.bin:
J
Jiri Olsa 已提交
204
	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
205

206
$(OUTPUT)test-gtk2-infobar.bin:
M
Mark Rutland 已提交
207
	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
208

209 210 211 212 213 214 215 216 217
grep-libs  = $(filter -l%,$(1))
strip-libs = $(filter-out -l%,$(1))

PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)

218
$(OUTPUT)test-libperl.bin:
219 220
	$(BUILD) $(FLAGS_PERL_EMBED)

221
$(OUTPUT)test-libpython.bin:
222
	$(BUILD) $(FLAGS_PYTHON_EMBED)
223

224
$(OUTPUT)test-libpython-version.bin:
225
	$(BUILD)
226

227
$(OUTPUT)test-libbfd.bin:
228
	$(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
229

230
$(OUTPUT)test-disassembler-four-args.bin:
231
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
232

233 234 235
$(OUTPUT)test-reallocarray.bin:
	$(BUILD)

236
$(OUTPUT)test-libbfd-liberty.bin:
237
	$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
238

239
$(OUTPUT)test-libbfd-liberty-z.bin:
240
	$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
241

242
$(OUTPUT)test-cplus-demangle.bin:
243 244
	$(BUILD) -liberty

245
$(OUTPUT)test-backtrace.bin:
246 247
	$(BUILD)

248
$(OUTPUT)test-timerfd.bin:
249 250
	$(BUILD)

251
$(OUTPUT)test-libdw-dwarf-unwind.bin:
252 253
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

254
$(OUTPUT)test-libbabeltrace.bin:
255
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
256

257
$(OUTPUT)test-sync-compare-and-swap.bin:
258
	$(BUILD)
259

260 261
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
262

263 264
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
265

266
$(OUTPUT)test-zlib.bin:
267 268
	$(BUILD) -lz

269
$(OUTPUT)test-lzma.bin:
270 271
	$(BUILD) -llzma

272
$(OUTPUT)test-get_cpuid.bin:
273 274
	$(BUILD)

275
$(OUTPUT)test-bpf.bin:
276 277
	$(BUILD)

278 279 280
$(OUTPUT)test-libbpf.bin:
	$(BUILD) -lbpf

281 282 283
$(OUTPUT)test-sdt.bin:
	$(BUILD)

284 285 286
$(OUTPUT)test-cxx.bin:
	$(BUILDXX) -std=gnu++11

287 288 289
$(OUTPUT)test-gettid.bin:
	$(BUILD)

290 291 292
$(OUTPUT)test-jvmti.bin:
	$(BUILD)

J
Jiri Olsa 已提交
293 294 295
$(OUTPUT)test-jvmti-cmlr.bin:
	$(BUILD)

296
$(OUTPUT)test-llvm.bin:
297
	$(BUILDXX) -std=gnu++11 				\
298 299 300
		-I$(shell $(LLVM_CONFIG) --includedir) 		\
		-L$(shell $(LLVM_CONFIG) --libdir)		\
		$(shell $(LLVM_CONFIG) --libs Core BPF)		\
301 302
		$(shell $(LLVM_CONFIG) --system-libs)		\
		> $(@:.bin=.make.output) 2>&1
303

304 305
$(OUTPUT)test-llvm-version.bin:
	$(BUILDXX) -std=gnu++11 				\
306 307
		-I$(shell $(LLVM_CONFIG) --includedir)		\
		> $(@:.bin=.make.output) 2>&1
308

309
$(OUTPUT)test-clang.bin:
310
	$(BUILDXX) -std=gnu++11 				\
311 312 313 314 315 316
		-I$(shell $(LLVM_CONFIG) --includedir) 		\
		-L$(shell $(LLVM_CONFIG) --libdir)		\
		-Wl,--start-group -lclangBasic -lclangDriver	\
		  -lclangFrontend -lclangEdit -lclangLex	\
		  -lclangAST -Wl,--end-group 			\
		$(shell $(LLVM_CONFIG) --libs Core option)	\
317 318
		$(shell $(LLVM_CONFIG) --system-libs)		\
		> $(@:.bin=.make.output) 2>&1
319

320
-include $(OUTPUT)*.d
321

322 323 324
$(OUTPUT)test-libaio.bin:
	$(BUILD) -lrt

325 326 327
$(OUTPUT)test-libzstd.bin:
	$(BUILD) -lzstd

328
$(OUTPUT)test-clang-bpf-co-re.bin:
329 330 331
	$(CLANG) -S -g -target bpf -o - $(patsubst %.bin,%.c,$(@F)) |	\
		grep BTF_KIND_VAR

332 333
$(OUTPUT)test-file-handle.bin:
	$(BUILD)
334

335 336 337
$(OUTPUT)test-libpfm4.bin:
	$(BUILD) -lpfm

338 339 340
###############################

clean:
341
	rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)