Makefile 9.3 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3
include ../../scripts/Makefile.include

4 5 6 7 8 9
FILES=                                          \
         test-all.bin                           \
         test-backtrace.bin                     \
         test-bionic.bin                        \
         test-dwarf.bin                         \
         test-dwarf_getlocations.bin            \
10
         test-eventfd.bin                       \
11
         test-fortify-source.bin                \
12
         test-get_current_dir_name.bin          \
13 14 15 16 17 18
         test-glibc.bin                         \
         test-gtk2.bin                          \
         test-gtk2-infobar.bin                  \
         test-hello.bin                         \
         test-libaudit.bin                      \
         test-libbfd.bin                        \
19
         test-libbfd-buildid.bin		\
20
         test-disassembler-four-args.bin        \
21
         test-reallocarray.bin			\
22 23
         test-libbfd-liberty.bin                \
         test-libbfd-liberty-z.bin              \
24
         test-cplus-demangle.bin                \
25
         test-libcap.bin			\
26 27 28 29
         test-libelf.bin                        \
         test-libelf-getphdrnum.bin             \
         test-libelf-gelf_getnote.bin           \
         test-libelf-getshdrstrndx.bin          \
30
         test-libdebuginfod.bin                 \
31 32 33 34 35
         test-libnuma.bin                       \
         test-numa_num_possible_cpus.bin        \
         test-libperl.bin                       \
         test-libpython.bin                     \
         test-libslang.bin                      \
36
         test-libslang-include-subdir.bin       \
37
         test-libtraceevent.bin                 \
38
         test-libtracefs.bin                    \
39 40 41 42 43 44 45 46 47 48
         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   \
49
         test-pthread-barrier.bin		\
50 51 52 53 54 55 56 57 58
         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                           \
59
         test-libbpf.bin                        \
60 61 62
         test-get_cpuid.bin                     \
         test-sdt.bin                           \
         test-cxx.bin                           \
63
         test-gettid.bin			\
64
         test-jvmti.bin				\
J
Jiri Olsa 已提交
65
         test-jvmti-cmlr.bin			\
66
         test-sched_getcpu.bin			\
67
         test-setns.bin				\
68 69 70
         test-libopencsd.bin			\
         test-clang.bin				\
         test-llvm.bin				\
71
         test-llvm-version.bin			\
72
         test-libaio.bin			\
73
         test-libzstd.bin			\
74
         test-clang-bpf-co-re.bin		\
75 76
         test-file-handle.bin			\
         test-libpfm4.bin
77

78 79
FILES := $(addprefix $(OUTPUT),$(FILES))

80
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
81

82 83
all: $(FILES)

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

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

90 91
###############################

92
$(OUTPUT)test-all.bin:
93
	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd -lcap
94

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

149
$(OUTPUT)test-libelf-getphdrnum.bin:
150 151
	$(BUILD) -lelf

152 153 154
$(OUTPUT)test-libelf-gelf_getnote.bin:
	$(BUILD) -lelf

155 156 157
$(OUTPUT)test-libelf-getshdrstrndx.bin:
	$(BUILD) -lelf

158 159 160
$(OUTPUT)test-libdebuginfod.bin:
	$(BUILD) -ldebuginfod

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

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

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

170
$(OUTPUT)test-libunwind-debug-frame.bin:
171
	$(BUILD) -lelf
172 173 174 175 176 177 178 179 180 181 182 183
$(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

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

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

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

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

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

199 200 201
$(OUTPUT)test-libtraceevent.bin:
	$(BUILD) -ltraceevent

202 203 204
$(OUTPUT)test-libtracefs.bin:
	$(BUILD) -ltracefs

205 206 207
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

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

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

214 215 216 217 218 219 220 221 222
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)

223
$(OUTPUT)test-libperl.bin:
224 225
	$(BUILD) $(FLAGS_PERL_EMBED)

226
$(OUTPUT)test-libpython.bin:
227
	$(BUILD) $(FLAGS_PYTHON_EMBED)
228

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

232 233 234
$(OUTPUT)test-libbfd-buildid.bin:
	$(BUILD) -DPACKAGE='"perf"' -lbfd -ldl

235
$(OUTPUT)test-disassembler-four-args.bin:
236
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
237

238 239 240
$(OUTPUT)test-reallocarray.bin:
	$(BUILD)

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

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

247
$(OUTPUT)test-cplus-demangle.bin:
248 249
	$(BUILD) -liberty

250
$(OUTPUT)test-backtrace.bin:
251 252
	$(BUILD)

253
$(OUTPUT)test-timerfd.bin:
254 255
	$(BUILD)

256
$(OUTPUT)test-libdw-dwarf-unwind.bin:
257 258
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

259
$(OUTPUT)test-libbabeltrace.bin:
260
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
261

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

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

268
$(OUTPUT)test-zlib.bin:
269 270
	$(BUILD) -lz

271
$(OUTPUT)test-lzma.bin:
272 273
	$(BUILD) -llzma

274
$(OUTPUT)test-get_cpuid.bin:
275 276
	$(BUILD)

277
$(OUTPUT)test-bpf.bin:
278 279
	$(BUILD)

280 281 282
$(OUTPUT)test-libbpf.bin:
	$(BUILD) -lbpf

283 284 285
$(OUTPUT)test-sdt.bin:
	$(BUILD)

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

289 290 291
$(OUTPUT)test-gettid.bin:
	$(BUILD)

292 293 294
$(OUTPUT)test-jvmti.bin:
	$(BUILD)

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

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

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

311
$(OUTPUT)test-clang.bin:
312
	$(BUILDXX) -std=gnu++14					\
313 314 315 316 317 318
		-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)	\
319 320
		$(shell $(LLVM_CONFIG) --system-libs)		\
		> $(@:.bin=.make.output) 2>&1
321

322
-include $(OUTPUT)*.d
323

324 325 326
$(OUTPUT)test-libaio.bin:
	$(BUILD) -lrt

327 328 329
$(OUTPUT)test-libzstd.bin:
	$(BUILD) -lzstd

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

334 335
$(OUTPUT)test-file-handle.bin:
	$(BUILD)
336

337 338 339
$(OUTPUT)test-libpfm4.bin:
	$(BUILD) -lpfm

340 341 342
###############################

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