Makefile 8.1 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3 4 5 6 7 8 9 10 11 12 13 14 15
FILES=                                          \
         test-all.bin                           \
         test-backtrace.bin                     \
         test-bionic.bin                        \
         test-dwarf.bin                         \
         test-dwarf_getlocations.bin            \
         test-fortify-source.bin                \
         test-sync-compare-and-swap.bin         \
         test-glibc.bin                         \
         test-gtk2.bin                          \
         test-gtk2-infobar.bin                  \
         test-hello.bin                         \
         test-libaudit.bin                      \
         test-libbfd.bin                        \
16
         test-disassembler-four-args.bin        \
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
         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   \
41
         test-pthread-barrier.bin		\
42 43 44 45 46 47 48 49 50 51 52 53
         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                           \
54
         test-jvmti.bin				\
55
         test-sched_getcpu.bin			\
56
         test-setns.bin				\
57 58 59 60
         test-libopencsd.bin			\
         test-clang.bin				\
         test-llvm.bin				\
         test-llvm-version.bin
61

62 63
FILES := $(addprefix $(OUTPUT),$(FILES))

64 65 66
CC ?= $(CROSS_COMPILE)gcc
CXX ?= $(CROSS_COMPILE)g++
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
67
LLVM_CONFIG ?= llvm-config
68

69 70
all: $(FILES)

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

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

77 78
###############################

79
$(OUTPUT)test-all.bin:
80
	$(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
81

82
$(OUTPUT)test-hello.bin:
83 84
	$(BUILD)

85
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
86
	$(BUILD) -D_GNU_SOURCE -lpthread
87

88 89 90
$(OUTPUT)test-pthread-barrier.bin:
	$(BUILD) -lpthread

91
$(OUTPUT)test-stackprotector-all.bin:
92
	$(BUILD) -fstack-protector-all
93

94
$(OUTPUT)test-fortify-source.bin:
95
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
96

97
$(OUTPUT)test-bionic.bin:
98 99
	$(BUILD)

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

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

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

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

112 113 114 115
$(OUTPUT)test-libopencsd.bin:
	$(BUILD) # -lopencsd_c_api -lopencsd provided by
		 # $(FEATURE_CHECK_LDFLAGS-libopencsd)

116 117 118 119 120
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

121
$(OUTPUT)test-dwarf.bin:
122
	$(BUILD) $(DWARFLIBS)
123

124 125 126
$(OUTPUT)test-dwarf_getlocations.bin:
	$(BUILD) $(DWARFLIBS)

127
$(OUTPUT)test-libelf-mmap.bin:
128 129
	$(BUILD) -lelf

130
$(OUTPUT)test-libelf-getphdrnum.bin:
131 132
	$(BUILD) -lelf

133 134 135
$(OUTPUT)test-libelf-gelf_getnote.bin:
	$(BUILD) -lelf

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

139
$(OUTPUT)test-libnuma.bin:
140 141
	$(BUILD) -lnuma

142
$(OUTPUT)test-numa_num_possible_cpus.bin:
143 144
	$(BUILD) -lnuma

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

148
$(OUTPUT)test-libunwind-debug-frame.bin:
149
	$(BUILD) -lelf
150 151 152 153 154 155 156 157 158 159 160 161
$(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

162 163 164 165 166
$(OUTPUT)test-libunwind-debug-frame-arm.bin:
	$(BUILD) -lelf -lunwind-arm

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

168
$(OUTPUT)test-libaudit.bin:
169 170
	$(BUILD) -laudit

171
$(OUTPUT)test-libslang.bin:
172 173
	$(BUILD) -I/usr/include/slang -lslang

174 175 176
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

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

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

183 184 185 186 187 188 189 190 191
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)

192
$(OUTPUT)test-libperl.bin:
193 194
	$(BUILD) $(FLAGS_PERL_EMBED)

195
$(OUTPUT)test-libpython.bin:
196
	$(BUILD) $(FLAGS_PYTHON_EMBED)
197

198
$(OUTPUT)test-libpython-version.bin:
199
	$(BUILD)
200

201
$(OUTPUT)test-libbfd.bin:
202
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
203

204
$(OUTPUT)test-disassembler-four-args.bin:
205
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
206

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

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

213
$(OUTPUT)test-cplus-demangle.bin:
214 215
	$(BUILD) -liberty

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

219
$(OUTPUT)test-timerfd.bin:
220 221
	$(BUILD)

222
$(OUTPUT)test-libdw-dwarf-unwind.bin:
223 224
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

225
$(OUTPUT)test-libbabeltrace.bin:
226
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
227

228
$(OUTPUT)test-sync-compare-and-swap.bin:
229
	$(BUILD)
230

231 232
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
233

234 235
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
236

237
$(OUTPUT)test-zlib.bin:
238 239
	$(BUILD) -lz

240
$(OUTPUT)test-lzma.bin:
241 242
	$(BUILD) -llzma

243
$(OUTPUT)test-get_cpuid.bin:
244 245
	$(BUILD)

246
$(OUTPUT)test-bpf.bin:
247 248
	$(BUILD)

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

252 253 254
$(OUTPUT)test-cxx.bin:
	$(BUILDXX) -std=gnu++11

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

258
$(OUTPUT)test-llvm.bin:
259
	$(BUILDXX) -std=gnu++11 				\
260 261 262 263 264
		-I$(shell $(LLVM_CONFIG) --includedir) 		\
		-L$(shell $(LLVM_CONFIG) --libdir)		\
		$(shell $(LLVM_CONFIG) --libs Core BPF)		\
		$(shell $(LLVM_CONFIG) --system-libs)

265 266 267 268
$(OUTPUT)test-llvm-version.bin:
	$(BUILDXX) -std=gnu++11 				\
		-I$(shell $(LLVM_CONFIG) --includedir)

269
$(OUTPUT)test-clang.bin:
270
	$(BUILDXX) -std=gnu++11 				\
271 272 273 274 275 276 277 278
		-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)	\
		$(shell $(LLVM_CONFIG) --system-libs)

279
-include $(OUTPUT)*.d
280

281 282 283
###############################

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