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				\
58
         test-sched_getcpu.bin			\
59
         test-setns.bin				\
60 61 62 63
         test-libopencsd.bin			\
         test-clang.bin				\
         test-llvm.bin				\
         test-llvm-version.bin
64

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

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

72 73
all: $(FILES)

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

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

80 81
###############################

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

278 279
$(OUTPUT)test-llvm-version.bin:
	$(BUILDXX) -std=gnu++11 				\
280 281
		-I$(shell $(LLVM_CONFIG) --includedir)		\
		> $(@:.bin=.make.output) 2>&1
282

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

294
-include $(OUTPUT)*.d
295

296 297 298
###############################

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