Merge branch 'perf/urgent' into perf/core, to pick up fixes before applying new changes
[firefly-linux-kernel-4.4.55.git] / tools / build / feature / Makefile
1
2 FILES=                                  \
3         test-all.bin                    \
4         test-backtrace.bin              \
5         test-bionic.bin                 \
6         test-dwarf.bin                  \
7         test-fortify-source.bin         \
8         test-sync-compare-and-swap.bin  \
9         test-glibc.bin                  \
10         test-gtk2.bin                   \
11         test-gtk2-infobar.bin           \
12         test-hello.bin                  \
13         test-libaudit.bin               \
14         test-libbfd.bin                 \
15         test-liberty.bin                \
16         test-liberty-z.bin              \
17         test-cplus-demangle.bin         \
18         test-libelf.bin                 \
19         test-libelf-getphdrnum.bin      \
20         test-libelf-mmap.bin            \
21         test-libnuma.bin                \
22         test-libperl.bin                \
23         test-libpython.bin              \
24         test-libpython-version.bin      \
25         test-libslang.bin               \
26         test-libunwind.bin              \
27         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         test-lzma.bin                   \
37         test-bpf.bin
38
39 CC := $(CROSS_COMPILE)gcc -MD
40 PKG_CONFIG := $(CROSS_COMPILE)pkg-config
41
42 all: $(FILES)
43
44 __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
45   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         $(BUILD)
54
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         $(BUILD)
66
67 test-libelf.bin:
68         $(BUILD) -lelf
69
70 test-glibc.bin:
71         $(BUILD)
72
73 test-dwarf.bin:
74         $(BUILD) -ldw
75
76 test-libelf-mmap.bin:
77         $(BUILD) -lelf
78
79 test-libelf-getphdrnum.bin:
80         $(BUILD) -lelf
81
82 test-libnuma.bin:
83         $(BUILD) -lnuma
84
85 test-libunwind.bin:
86         $(BUILD) -lelf
87
88 test-libunwind-debug-frame.bin:
89         $(BUILD) -lelf
90
91 test-libaudit.bin:
92         $(BUILD) -laudit
93
94 test-libslang.bin:
95         $(BUILD) -I/usr/include/slang -lslang
96
97 test-gtk2.bin:
98         $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
99
100 test-gtk2-infobar.bin:
101         $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
102
103 grep-libs  = $(filter -l%,$(1))
104 strip-libs = $(filter-out -l%,$(1))
105
106 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
107 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
108 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
109 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
110 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
111
112 test-libperl.bin:
113         $(BUILD) $(FLAGS_PERL_EMBED)
114
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         $(BUILD) -liberty
132
133 test-backtrace.bin:
134         $(BUILD)
135
136 test-timerfd.bin:
137         $(BUILD)
138
139 test-libdw-dwarf-unwind.bin:
140         $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
141
142 test-libbabeltrace.bin:
143         $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
144
145 test-sync-compare-and-swap.bin:
146         $(BUILD)
147
148 test-compile-32.bin:
149         $(CC) -m32 -o $(OUTPUT)$@ test-compile.c
150
151 test-compile-x32.bin:
152         $(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
153
154 test-zlib.bin:
155         $(BUILD) -lz
156
157 test-lzma.bin:
158         $(BUILD) -llzma
159
160 test-bpf.bin:
161         $(BUILD)
162
163 -include *.d
164
165 ###############################
166
167 clean:
168         rm -f $(FILES) *.d $(FILES:.bin=.make.output)