Makefile 3.9 KB
Newer Older
1

2
FILES=					\
3 4 5 6 7
	test-all.bin			\
	test-backtrace.bin		\
	test-bionic.bin			\
	test-dwarf.bin			\
	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 27 28
	test-libperl.bin		\
	test-libpython.bin		\
	test-libpython-version.bin	\
	test-libslang.bin		\
	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

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

44 45
all: $(FILES)

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

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

51
test-all.bin:
52
	$(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
53

54
test-hello.bin:
55 56
	$(BUILD)

57
test-pthread-attr-setaffinity-np.bin:
58
	$(BUILD) -D_GNU_SOURCE -lpthread
59

60
test-stackprotector-all.bin:
61
	$(BUILD) -fstack-protector-all
62

63
test-fortify-source.bin:
64
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
65

66
test-bionic.bin:
67 68
	$(BUILD)

69
test-libelf.bin:
70 71
	$(BUILD) -lelf

72
test-glibc.bin:
73 74
	$(BUILD)

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

80
test-dwarf.bin:
81
	$(BUILD) $(DWARFLIBS)
82

83
test-libelf-mmap.bin:
84 85
	$(BUILD) -lelf

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

89
test-libnuma.bin:
90 91
	$(BUILD) -lnuma

92 93 94
test-numa_num_possible_cpus.bin:
	$(BUILD) -lnuma

95
test-libunwind.bin:
96
	$(BUILD) -lelf
97

98
test-libunwind-debug-frame.bin:
99
	$(BUILD) -lelf
100

101
test-libaudit.bin:
102 103
	$(BUILD) -laudit

104
test-libslang.bin:
105 106
	$(BUILD) -I/usr/include/slang -lslang

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

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

113 114 115 116 117 118 119 120 121
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)

122
test-libperl.bin:
123 124
	$(BUILD) $(FLAGS_PERL_EMBED)

125
test-libpython.bin:
126
	$(BUILD)
127

128
test-libpython-version.bin:
129
	$(BUILD)
130

131
test-libbfd.bin:
132
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
133

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

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

140
test-cplus-demangle.bin:
141 142
	$(BUILD) -liberty

143
test-backtrace.bin:
144 145
	$(BUILD)

146
test-timerfd.bin:
147 148
	$(BUILD)

149
test-libdw-dwarf-unwind.bin:
150 151 152 153
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

test-libbabeltrace.bin:
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
154

155
test-sync-compare-and-swap.bin:
156
	$(BUILD)
157

158 159 160 161 162 163
test-compile-32.bin:
	$(CC) -m32 -o $(OUTPUT)$@ test-compile.c

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

164 165 166
test-zlib.bin:
	$(BUILD) -lz

167 168 169
test-lzma.bin:
	$(BUILD) -llzma

170 171 172
test-get_cpuid.bin:
	$(BUILD)

173 174 175
test-bpf.bin:
	$(BUILD)

176
-include *.d
177

178 179 180
###############################

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