Makefile 3.6 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 22 23 24 25 26 27
	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		\
	test-libperl.bin		\
	test-libpython.bin		\
	test-libpython-version.bin	\
	test-libslang.bin		\
	test-libunwind.bin		\
	test-libunwind-debug-frame.bin	\
28
	test-pthread-attr-setaffinity-np.bin	\
29
	test-stackprotector-all.bin	\
30
	test-timerfd.bin		\
31
	test-libdw-dwarf-unwind.bin	\
32
	test-libbabeltrace.bin		\
33
	test-compile-32.bin		\
34
	test-compile-x32.bin		\
35
	test-zlib.bin			\
36 37
	test-lzma.bin			\
	test-bpf.bin
38

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

42 43
all: $(FILES)

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

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

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

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

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

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

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

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

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

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

73
test-dwarf.bin:
74 75
	$(BUILD) -ldw

76
test-libelf-mmap.bin:
77 78
	$(BUILD) -lelf

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

82
test-libnuma.bin:
83 84
	$(BUILD) -lnuma

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

88
test-libunwind-debug-frame.bin:
89
	$(BUILD) -lelf
90

91
test-libaudit.bin:
92 93
	$(BUILD) -laudit

94
test-libslang.bin:
95 96
	$(BUILD) -I/usr/include/slang -lslang

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

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

103 104 105 106 107 108 109 110 111
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)

112
test-libperl.bin:
113 114
	$(BUILD) $(FLAGS_PERL_EMBED)

115
test-libpython.bin:
116
	$(BUILD)
117

118
test-libpython-version.bin:
119
	$(BUILD)
120

121
test-libbfd.bin:
122
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
123

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

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

130
test-cplus-demangle.bin:
131 132
	$(BUILD) -liberty

133
test-backtrace.bin:
134 135
	$(BUILD)

136
test-timerfd.bin:
137 138
	$(BUILD)

139
test-libdw-dwarf-unwind.bin:
140 141 142 143
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

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

145
test-sync-compare-and-swap.bin:
146
	$(BUILD)
147

148 149 150 151 152 153
test-compile-32.bin:
	$(CC) -m32 -o $(OUTPUT)$@ test-compile.c

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

154 155 156
test-zlib.bin:
	$(BUILD) -lz

157 158 159
test-lzma.bin:
	$(BUILD) -llzma

160 161 162
test-bpf.bin:
	$(BUILD)

163
-include *.d
164

165 166 167
###############################

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