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

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

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

54 55
all: $(FILES)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

105
$(OUTPUT)test-libnuma.bin:
106 107
	$(BUILD) -lnuma

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

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

114
$(OUTPUT)test-libunwind-debug-frame.bin:
115
	$(BUILD) -lelf
116 117 118 119 120 121 122 123 124 125 126 127
$(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

128 129 130 131 132
$(OUTPUT)test-libunwind-debug-frame-arm.bin:
	$(BUILD) -lelf -lunwind-arm

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

134
$(OUTPUT)test-libaudit.bin:
135 136
	$(BUILD) -laudit

137
$(OUTPUT)test-libslang.bin:
138 139
	$(BUILD) -I/usr/include/slang -lslang

140 141 142
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

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

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

149 150 151 152 153 154 155 156 157
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)

158
$(OUTPUT)test-libperl.bin:
159 160
	$(BUILD) $(FLAGS_PERL_EMBED)

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

164
$(OUTPUT)test-libpython-version.bin:
165
	$(BUILD)
166

167
$(OUTPUT)test-libbfd.bin:
168
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
169

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

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

176
$(OUTPUT)test-cplus-demangle.bin:
177 178
	$(BUILD) -liberty

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

182
$(OUTPUT)test-timerfd.bin:
183 184
	$(BUILD)

185
$(OUTPUT)test-libdw-dwarf-unwind.bin:
186 187
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

188
$(OUTPUT)test-libbabeltrace.bin:
189
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
190

191
$(OUTPUT)test-sync-compare-and-swap.bin:
192
	$(BUILD)
193

194 195
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
196

197 198
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
199

200
$(OUTPUT)test-zlib.bin:
201 202
	$(BUILD) -lz

203
$(OUTPUT)test-lzma.bin:
204 205
	$(BUILD) -llzma

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

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

212
-include $(OUTPUT)*.d
213

214 215 216
###############################

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