Makefile 8.5 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 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
         test-liberty.bin                       \
         test-liberty-z.bin                     \
         test-cplus-demangle.bin                \
         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                      \
         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   \
44
         test-pthread-barrier.bin		\
45 46 47 48 49 50 51 52 53 54 55 56
         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                           \
         test-get_cpuid.bin                     \
         test-sdt.bin                           \
         test-cxx.bin                           \
57
         test-jvmti.bin				\
J
Jiri Olsa 已提交
58
         test-jvmti-cmlr.bin			\
59
         test-sched_getcpu.bin			\
60
         test-setns.bin				\
61 62 63 64
         test-libopencsd.bin			\
         test-clang.bin				\
         test-llvm.bin				\
         test-llvm-version.bin
65

66 67
FILES := $(addprefix $(OUTPUT),$(FILES))

68 69 70
CC ?= $(CROSS_COMPILE)gcc
CXX ?= $(CROSS_COMPILE)g++
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
71
LLVM_CONFIG ?= llvm-config
72

73 74
all: $(FILES)

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

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

81 82
###############################

83
$(OUTPUT)test-all.bin:
84
	$(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
85

86
$(OUTPUT)test-hello.bin:
87 88
	$(BUILD)

89
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
90
	$(BUILD) -D_GNU_SOURCE -lpthread
91

92 93 94
$(OUTPUT)test-pthread-barrier.bin:
	$(BUILD) -lpthread

95
$(OUTPUT)test-stackprotector-all.bin:
96
	$(BUILD) -fstack-protector-all
97

98
$(OUTPUT)test-fortify-source.bin:
99
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
100

101
$(OUTPUT)test-bionic.bin:
102 103
	$(BUILD)

104
$(OUTPUT)test-libelf.bin:
105 106
	$(BUILD) -lelf

107 108 109
$(OUTPUT)test-eventfd.bin:
	$(BUILD)

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

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

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

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

122 123 124 125
$(OUTPUT)test-libopencsd.bin:
	$(BUILD) # -lopencsd_c_api -lopencsd provided by
		 # $(FEATURE_CHECK_LDFLAGS-libopencsd)

126 127 128 129 130
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

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

134 135 136
$(OUTPUT)test-dwarf_getlocations.bin:
	$(BUILD) $(DWARFLIBS)

137
$(OUTPUT)test-libelf-mmap.bin:
138 139
	$(BUILD) -lelf

140
$(OUTPUT)test-libelf-getphdrnum.bin:
141 142
	$(BUILD) -lelf

143 144 145
$(OUTPUT)test-libelf-gelf_getnote.bin:
	$(BUILD) -lelf

146 147 148
$(OUTPUT)test-libelf-getshdrstrndx.bin:
	$(BUILD) -lelf

149
$(OUTPUT)test-libnuma.bin:
150 151
	$(BUILD) -lnuma

152
$(OUTPUT)test-numa_num_possible_cpus.bin:
153 154
	$(BUILD) -lnuma

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

158
$(OUTPUT)test-libunwind-debug-frame.bin:
159
	$(BUILD) -lelf
160 161 162 163 164 165 166 167 168 169 170 171
$(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

172 173 174 175 176
$(OUTPUT)test-libunwind-debug-frame-arm.bin:
	$(BUILD) -lelf -lunwind-arm

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

178
$(OUTPUT)test-libaudit.bin:
179 180
	$(BUILD) -laudit

181
$(OUTPUT)test-libslang.bin:
182 183
	$(BUILD) -I/usr/include/slang -lslang

184 185 186
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

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

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

193 194 195 196 197 198 199 200 201
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)

202
$(OUTPUT)test-libperl.bin:
203 204
	$(BUILD) $(FLAGS_PERL_EMBED)

205
$(OUTPUT)test-libpython.bin:
206
	$(BUILD) $(FLAGS_PYTHON_EMBED)
207

208
$(OUTPUT)test-libpython-version.bin:
209
	$(BUILD)
210

211
$(OUTPUT)test-libbfd.bin:
212
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
213

214
$(OUTPUT)test-disassembler-four-args.bin:
215
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
216

217 218 219
$(OUTPUT)test-reallocarray.bin:
	$(BUILD)

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

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

226
$(OUTPUT)test-cplus-demangle.bin:
227 228
	$(BUILD) -liberty

229
$(OUTPUT)test-backtrace.bin:
230 231
	$(BUILD)

232
$(OUTPUT)test-timerfd.bin:
233 234
	$(BUILD)

235
$(OUTPUT)test-libdw-dwarf-unwind.bin:
236 237
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

238
$(OUTPUT)test-libbabeltrace.bin:
239
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
240

241
$(OUTPUT)test-sync-compare-and-swap.bin:
242
	$(BUILD)
243

244 245
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
246

247 248
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
249

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

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

256
$(OUTPUT)test-get_cpuid.bin:
257 258
	$(BUILD)

259
$(OUTPUT)test-bpf.bin:
260 261
	$(BUILD)

262 263 264
$(OUTPUT)test-sdt.bin:
	$(BUILD)

265 266 267
$(OUTPUT)test-cxx.bin:
	$(BUILDXX) -std=gnu++11

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

J
Jiri Olsa 已提交
271 272 273
$(OUTPUT)test-jvmti-cmlr.bin:
	$(BUILD)

274
$(OUTPUT)test-llvm.bin:
275
	$(BUILDXX) -std=gnu++11 				\
276 277 278
		-I$(shell $(LLVM_CONFIG) --includedir) 		\
		-L$(shell $(LLVM_CONFIG) --libdir)		\
		$(shell $(LLVM_CONFIG) --libs Core BPF)		\
279 280
		$(shell $(LLVM_CONFIG) --system-libs)		\
		> $(@:.bin=.make.output) 2>&1
281

282 283
$(OUTPUT)test-llvm-version.bin:
	$(BUILDXX) -std=gnu++11 				\
284 285
		-I$(shell $(LLVM_CONFIG) --includedir)		\
		> $(@:.bin=.make.output) 2>&1
286

287
$(OUTPUT)test-clang.bin:
288
	$(BUILDXX) -std=gnu++11 				\
289 290 291 292 293 294
		-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)	\
295 296
		$(shell $(LLVM_CONFIG) --system-libs)		\
		> $(@:.bin=.make.output) 2>&1
297

298
-include $(OUTPUT)*.d
299

300 301 302
###############################

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