Makefile 5.5 KB
Newer Older
1
FILES=					\
2 3 4 5
	test-all.bin			\
	test-backtrace.bin		\
	test-bionic.bin			\
	test-dwarf.bin			\
6
	test-dwarf_getlocations.bin	\
7
	test-fortify-source.bin		\
8
	test-sync-compare-and-swap.bin	\
9 10 11 12 13 14 15 16 17 18 19
	test-glibc.bin			\
	test-gtk2.bin			\
	test-gtk2-infobar.bin		\
	test-hello.bin			\
	test-libaudit.bin		\
	test-libbfd.bin			\
	test-liberty.bin		\
	test-liberty-z.bin		\
	test-cplus-demangle.bin		\
	test-libelf.bin			\
	test-libelf-getphdrnum.bin	\
20
	test-libelf-gelf_getnote.bin	\
21
	test-libelf-getshdrstrndx.bin	\
22 23
	test-libelf-mmap.bin		\
	test-libnuma.bin		\
24
	test-numa_num_possible_cpus.bin	\
25 26 27 28
	test-libperl.bin		\
	test-libpython.bin		\
	test-libpython-version.bin	\
	test-libslang.bin		\
29
	test-libcrypto.bin		\
30 31
	test-libunwind.bin		\
	test-libunwind-debug-frame.bin	\
32 33 34 35
	test-libunwind-x86.bin		\
	test-libunwind-x86_64.bin	\
	test-libunwind-arm.bin		\
	test-libunwind-aarch64.bin	\
36 37
	test-libunwind-debug-frame-arm.bin	\
	test-libunwind-debug-frame-aarch64.bin	\
38
	test-pthread-attr-setaffinity-np.bin	\
39
	test-stackprotector-all.bin	\
40
	test-timerfd.bin		\
41
	test-libdw-dwarf-unwind.bin	\
42
	test-libbabeltrace.bin		\
43
	test-compile-32.bin		\
44
	test-compile-x32.bin		\
45
	test-zlib.bin			\
46
	test-lzma.bin			\
47
	test-bpf.bin			\
48
	test-get_cpuid.bin		\
49 50
	test-sdt.bin			\
	test-cxx.bin
51

52 53
FILES := $(addprefix $(OUTPUT),$(FILES))

M
Mark Rutland 已提交
54
CC := $(CROSS_COMPILE)gcc -MD
55
CXX := $(CROSS_COMPILE)g++ -MD
M
Mark Rutland 已提交
56
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
57

58 59
all: $(FILES)

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

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

66 67
###############################

68
$(OUTPUT)test-all.bin:
69
	$(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
70

71
$(OUTPUT)test-hello.bin:
72 73
	$(BUILD)

74
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
75
	$(BUILD) -D_GNU_SOURCE -lpthread
76

77
$(OUTPUT)test-stackprotector-all.bin:
78
	$(BUILD) -fstack-protector-all
79

80
$(OUTPUT)test-fortify-source.bin:
81
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
82

83
$(OUTPUT)test-bionic.bin:
84 85
	$(BUILD)

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

89
$(OUTPUT)test-glibc.bin:
90 91
	$(BUILD)

92 93 94 95 96
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

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

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

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

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

109 110 111
$(OUTPUT)test-libelf-gelf_getnote.bin:
	$(BUILD) -lelf

112 113 114
$(OUTPUT)test-libelf-getshdrstrndx.bin:
	$(BUILD) -lelf

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

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

121
$(OUTPUT)test-libunwind.bin:
122
	$(BUILD) -lelf
123

124
$(OUTPUT)test-libunwind-debug-frame.bin:
125
	$(BUILD) -lelf
126 127 128 129 130 131 132 133 134 135 136 137
$(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

138 139 140 141 142
$(OUTPUT)test-libunwind-debug-frame-arm.bin:
	$(BUILD) -lelf -lunwind-arm

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

144
$(OUTPUT)test-libaudit.bin:
145 146
	$(BUILD) -laudit

147
$(OUTPUT)test-libslang.bin:
148 149
	$(BUILD) -I/usr/include/slang -lslang

150 151 152
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

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

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

159 160 161 162 163 164 165 166 167
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)

168
$(OUTPUT)test-libperl.bin:
169 170
	$(BUILD) $(FLAGS_PERL_EMBED)

171
$(OUTPUT)test-libpython.bin:
172
	$(BUILD)
173

174
$(OUTPUT)test-libpython-version.bin:
175
	$(BUILD)
176

177
$(OUTPUT)test-libbfd.bin:
178
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
179

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

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

186
$(OUTPUT)test-cplus-demangle.bin:
187 188
	$(BUILD) -liberty

189
$(OUTPUT)test-backtrace.bin:
190 191
	$(BUILD)

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

195
$(OUTPUT)test-libdw-dwarf-unwind.bin:
196 197
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

198
$(OUTPUT)test-libbabeltrace.bin:
199
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
200

201
$(OUTPUT)test-sync-compare-and-swap.bin:
202
	$(BUILD)
203

204 205
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
206

207 208
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
209

210
$(OUTPUT)test-zlib.bin:
211 212
	$(BUILD) -lz

213
$(OUTPUT)test-lzma.bin:
214 215
	$(BUILD) -llzma

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

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

222 223 224
$(OUTPUT)test-sdt.bin:
	$(BUILD)

225 226 227
$(OUTPUT)test-cxx.bin:
	$(BUILDXX) -std=gnu++11

228
-include $(OUTPUT)*.d
229

230 231 232
###############################

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