Makefile 8.6 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
         test-libopencsd.bin			\
         test-clang.bin				\
         test-llvm.bin				\
64 65
         test-llvm-version.bin			\
         test-libaio.bin
66

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

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

74 75
all: $(FILES)

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

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

82 83
###############################

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

299
-include $(OUTPUT)*.d
300

301 302 303
$(OUTPUT)test-libaio.bin:
	$(BUILD) -lrt

304 305 306
###############################

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