Makefile 4.3 KB
Newer Older
1
FILES=					\
2 3 4 5 6
	test-all.bin			\
	test-backtrace.bin		\
	test-bionic.bin			\
	test-dwarf.bin			\
	test-fortify-source.bin		\
7
	test-sync-compare-and-swap.bin	\
8 9 10 11 12 13 14 15 16 17 18 19 20
	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		\
21
	test-numa_num_possible_cpus.bin	\
22 23 24 25
	test-libperl.bin		\
	test-libpython.bin		\
	test-libpython-version.bin	\
	test-libslang.bin		\
26
	test-libcrypto.bin		\
27 28
	test-libunwind.bin		\
	test-libunwind-debug-frame.bin	\
29
	test-pthread-attr-setaffinity-np.bin	\
30
	test-stackprotector-all.bin	\
31
	test-timerfd.bin		\
32
	test-libdw-dwarf-unwind.bin	\
33
	test-libbabeltrace.bin		\
34
	test-compile-32.bin		\
35
	test-compile-x32.bin		\
36
	test-zlib.bin			\
37
	test-lzma.bin			\
38 39
	test-bpf.bin			\
	test-get_cpuid.bin
40

41 42
FILES := $(addprefix $(OUTPUT),$(FILES))

M
Mark Rutland 已提交
43 44
CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
45

46 47
all: $(FILES)

48 49
__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
  BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
50 51 52

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

53
$(OUTPUT)test-all.bin:
54
	$(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
55

56
$(OUTPUT)test-hello.bin:
57 58
	$(BUILD)

59
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
60
	$(BUILD) -D_GNU_SOURCE -lpthread
61

62
$(OUTPUT)test-stackprotector-all.bin:
63
	$(BUILD) -fstack-protector-all
64

65
$(OUTPUT)test-fortify-source.bin:
66
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
67

68
$(OUTPUT)test-bionic.bin:
69 70
	$(BUILD)

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

74
$(OUTPUT)test-glibc.bin:
75 76
	$(BUILD)

77 78 79 80 81
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

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

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

88
$(OUTPUT)test-libelf-getphdrnum.bin:
89 90
	$(BUILD) -lelf

91
$(OUTPUT)test-libnuma.bin:
92 93
	$(BUILD) -lnuma

94
$(OUTPUT)test-numa_num_possible_cpus.bin:
95 96
	$(BUILD) -lnuma

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

100
$(OUTPUT)test-libunwind-debug-frame.bin:
101
	$(BUILD) -lelf
102

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

106
$(OUTPUT)test-libslang.bin:
107 108
	$(BUILD) -I/usr/include/slang -lslang

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

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

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

118 119 120 121 122 123 124 125 126
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)

127
$(OUTPUT)test-libperl.bin:
128 129
	$(BUILD) $(FLAGS_PERL_EMBED)

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

133
$(OUTPUT)test-libpython-version.bin:
134
	$(BUILD)
135

136
$(OUTPUT)test-libbfd.bin:
137
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
138

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

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

145
$(OUTPUT)test-cplus-demangle.bin:
146 147
	$(BUILD) -liberty

148
$(OUTPUT)test-backtrace.bin:
149 150
	$(BUILD)

151
$(OUTPUT)test-timerfd.bin:
152 153
	$(BUILD)

154
$(OUTPUT)test-libdw-dwarf-unwind.bin:
155 156
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

157
$(OUTPUT)test-libbabeltrace.bin:
158
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
159

160
$(OUTPUT)test-sync-compare-and-swap.bin:
161
	$(BUILD)
162

163 164
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
165

166 167
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
168

169
$(OUTPUT)test-zlib.bin:
170 171
	$(BUILD) -lz

172
$(OUTPUT)test-lzma.bin:
173 174
	$(BUILD) -llzma

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

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

181
-include $(OUTPUT)*.d
182

183 184 185
###############################

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