Makefile 5.0 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 20 21
	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	\
	test-libelf-mmap.bin		\
	test-libnuma.bin		\
22
	test-numa_num_possible_cpus.bin	\
23 24 25 26
	test-libperl.bin		\
	test-libpython.bin		\
	test-libpython-version.bin	\
	test-libslang.bin		\
27
	test-libcrypto.bin		\
28 29
	test-libunwind.bin		\
	test-libunwind-debug-frame.bin	\
30 31 32 33
	test-libunwind-x86.bin		\
	test-libunwind-x86_64.bin	\
	test-libunwind-arm.bin		\
	test-libunwind-aarch64.bin	\
34 35
	test-libunwind-debug-frame-arm.bin	\
	test-libunwind-debug-frame-aarch64.bin	\
36
	test-pthread-attr-setaffinity-np.bin	\
37
	test-stackprotector-all.bin	\
38
	test-timerfd.bin		\
39
	test-libdw-dwarf-unwind.bin	\
40
	test-libbabeltrace.bin		\
41
	test-compile-32.bin		\
42
	test-compile-x32.bin		\
43
	test-zlib.bin			\
44
	test-lzma.bin			\
45 46
	test-bpf.bin			\
	test-get_cpuid.bin
47

48 49
FILES := $(addprefix $(OUTPUT),$(FILES))

M
Mark Rutland 已提交
50 51
CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
52

53 54
all: $(FILES)

55 56
__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
  BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
57 58 59

###############################

60
$(OUTPUT)test-all.bin:
61
	$(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
62

63
$(OUTPUT)test-hello.bin:
64 65
	$(BUILD)

66
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
67
	$(BUILD) -D_GNU_SOURCE -lpthread
68

69
$(OUTPUT)test-stackprotector-all.bin:
70
	$(BUILD) -fstack-protector-all
71

72
$(OUTPUT)test-fortify-source.bin:
73
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
74

75
$(OUTPUT)test-bionic.bin:
76 77
	$(BUILD)

78
$(OUTPUT)test-libelf.bin:
79 80
	$(BUILD) -lelf

81
$(OUTPUT)test-glibc.bin:
82 83
	$(BUILD)

84 85 86 87 88
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

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

92 93 94
$(OUTPUT)test-dwarf_getlocations.bin:
	$(BUILD) $(DWARFLIBS)

95
$(OUTPUT)test-libelf-mmap.bin:
96 97
	$(BUILD) -lelf

98
$(OUTPUT)test-libelf-getphdrnum.bin:
99 100
	$(BUILD) -lelf

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

104
$(OUTPUT)test-numa_num_possible_cpus.bin:
105 106
	$(BUILD) -lnuma

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

110
$(OUTPUT)test-libunwind-debug-frame.bin:
111
	$(BUILD) -lelf
112 113 114 115 116 117 118 119 120 121 122 123
$(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

124 125 126 127 128
$(OUTPUT)test-libunwind-debug-frame-arm.bin:
	$(BUILD) -lelf -lunwind-arm

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

130
$(OUTPUT)test-libaudit.bin:
131 132
	$(BUILD) -laudit

133
$(OUTPUT)test-libslang.bin:
134 135
	$(BUILD) -I/usr/include/slang -lslang

136 137 138
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

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

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

145 146 147 148 149 150 151 152 153
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)

154
$(OUTPUT)test-libperl.bin:
155 156
	$(BUILD) $(FLAGS_PERL_EMBED)

157
$(OUTPUT)test-libpython.bin:
158
	$(BUILD)
159

160
$(OUTPUT)test-libpython-version.bin:
161
	$(BUILD)
162

163
$(OUTPUT)test-libbfd.bin:
164
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
165

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

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

172
$(OUTPUT)test-cplus-demangle.bin:
173 174
	$(BUILD) -liberty

175
$(OUTPUT)test-backtrace.bin:
176 177
	$(BUILD)

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

181
$(OUTPUT)test-libdw-dwarf-unwind.bin:
182 183
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

184
$(OUTPUT)test-libbabeltrace.bin:
185
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
186

187
$(OUTPUT)test-sync-compare-and-swap.bin:
188
	$(BUILD)
189

190 191
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
192

193 194
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
195

196
$(OUTPUT)test-zlib.bin:
197 198
	$(BUILD) -lz

199
$(OUTPUT)test-lzma.bin:
200 201
	$(BUILD) -llzma

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

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

208
-include $(OUTPUT)*.d
209

210 211 212
###############################

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