Makefile 3.8 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 38
	test-lzma.bin			\
	test-bpf.bin
39

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

43 44
all: $(FILES)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

169 170 171
test-bpf.bin:
	$(BUILD)

172
-include *.d
173

174 175 176
###############################

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