]> asedeno.scripts.mit.edu Git - linux.git/blob - tools/build/feature/Makefile
Merge tag 'Wimplicit-fallthrough-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kerne...
[linux.git] / tools / build / feature / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 FILES=                                          \
3          test-all.bin                           \
4          test-backtrace.bin                     \
5          test-bionic.bin                        \
6          test-dwarf.bin                         \
7          test-dwarf_getlocations.bin            \
8          test-eventfd.bin                       \
9          test-fortify-source.bin                \
10          test-sync-compare-and-swap.bin         \
11          test-get_current_dir_name.bin          \
12          test-glibc.bin                         \
13          test-gtk2.bin                          \
14          test-gtk2-infobar.bin                  \
15          test-hello.bin                         \
16          test-libaudit.bin                      \
17          test-libbfd.bin                        \
18          test-disassembler-four-args.bin        \
19          test-reallocarray.bin                  \
20          test-libbfd-liberty.bin                \
21          test-libbfd-liberty-z.bin              \
22          test-cplus-demangle.bin                \
23          test-libelf.bin                        \
24          test-libelf-getphdrnum.bin             \
25          test-libelf-gelf_getnote.bin           \
26          test-libelf-getshdrstrndx.bin          \
27          test-libelf-mmap.bin                   \
28          test-libnuma.bin                       \
29          test-numa_num_possible_cpus.bin        \
30          test-libperl.bin                       \
31          test-libpython.bin                     \
32          test-libpython-version.bin             \
33          test-libslang.bin                      \
34          test-libcrypto.bin                     \
35          test-libunwind.bin                     \
36          test-libunwind-debug-frame.bin         \
37          test-libunwind-x86.bin                 \
38          test-libunwind-x86_64.bin              \
39          test-libunwind-arm.bin                 \
40          test-libunwind-aarch64.bin             \
41          test-libunwind-debug-frame-arm.bin     \
42          test-libunwind-debug-frame-aarch64.bin \
43          test-pthread-attr-setaffinity-np.bin   \
44          test-pthread-barrier.bin               \
45          test-stackprotector-all.bin            \
46          test-timerfd.bin                       \
47          test-libdw-dwarf-unwind.bin            \
48          test-libbabeltrace.bin                 \
49          test-compile-32.bin                    \
50          test-compile-x32.bin                   \
51          test-zlib.bin                          \
52          test-lzma.bin                          \
53          test-bpf.bin                           \
54          test-get_cpuid.bin                     \
55          test-sdt.bin                           \
56          test-cxx.bin                           \
57          test-jvmti.bin                         \
58          test-jvmti-cmlr.bin                    \
59          test-sched_getcpu.bin                  \
60          test-setns.bin                         \
61          test-libopencsd.bin                    \
62          test-clang.bin                         \
63          test-llvm.bin                          \
64          test-llvm-version.bin                  \
65          test-libaio.bin                        \
66          test-libzstd.bin
67
68 FILES := $(addprefix $(OUTPUT),$(FILES))
69
70 CC ?= $(CROSS_COMPILE)gcc
71 CXX ?= $(CROSS_COMPILE)g++
72 PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
73 LLVM_CONFIG ?= llvm-config
74
75 all: $(FILES)
76
77 __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
78   BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
79
80 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
81   BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
82
83 ###############################
84
85 $(OUTPUT)test-all.bin:
86         $(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
87
88 $(OUTPUT)test-hello.bin:
89         $(BUILD)
90
91 $(OUTPUT)test-pthread-attr-setaffinity-np.bin:
92         $(BUILD) -D_GNU_SOURCE -lpthread
93
94 $(OUTPUT)test-pthread-barrier.bin:
95         $(BUILD) -lpthread
96
97 $(OUTPUT)test-stackprotector-all.bin:
98         $(BUILD) -fstack-protector-all
99
100 $(OUTPUT)test-fortify-source.bin:
101         $(BUILD) -O2 -D_FORTIFY_SOURCE=2
102
103 $(OUTPUT)test-bionic.bin:
104         $(BUILD)
105
106 $(OUTPUT)test-libelf.bin:
107         $(BUILD) -lelf
108
109 $(OUTPUT)test-eventfd.bin:
110         $(BUILD)
111
112 $(OUTPUT)test-get_current_dir_name.bin:
113         $(BUILD)
114
115 $(OUTPUT)test-glibc.bin:
116         $(BUILD)
117
118 $(OUTPUT)test-sched_getcpu.bin:
119         $(BUILD)
120
121 $(OUTPUT)test-setns.bin:
122         $(BUILD)
123
124 $(OUTPUT)test-libopencsd.bin:
125         $(BUILD) # -lopencsd_c_api -lopencsd provided by
126                  # $(FEATURE_CHECK_LDFLAGS-libopencsd)
127
128 DWARFLIBS := -ldw
129 ifeq ($(findstring -static,${LDFLAGS}),-static)
130 DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
131 endif
132
133 $(OUTPUT)test-dwarf.bin:
134         $(BUILD) $(DWARFLIBS)
135
136 $(OUTPUT)test-dwarf_getlocations.bin:
137         $(BUILD) $(DWARFLIBS)
138
139 $(OUTPUT)test-libelf-mmap.bin:
140         $(BUILD) -lelf
141
142 $(OUTPUT)test-libelf-getphdrnum.bin:
143         $(BUILD) -lelf
144
145 $(OUTPUT)test-libelf-gelf_getnote.bin:
146         $(BUILD) -lelf
147
148 $(OUTPUT)test-libelf-getshdrstrndx.bin:
149         $(BUILD) -lelf
150
151 $(OUTPUT)test-libnuma.bin:
152         $(BUILD) -lnuma
153
154 $(OUTPUT)test-numa_num_possible_cpus.bin:
155         $(BUILD) -lnuma
156
157 $(OUTPUT)test-libunwind.bin:
158         $(BUILD) -lelf
159
160 $(OUTPUT)test-libunwind-debug-frame.bin:
161         $(BUILD) -lelf
162 $(OUTPUT)test-libunwind-x86.bin:
163         $(BUILD) -lelf -lunwind-x86
164
165 $(OUTPUT)test-libunwind-x86_64.bin:
166         $(BUILD) -lelf -lunwind-x86_64
167
168 $(OUTPUT)test-libunwind-arm.bin:
169         $(BUILD) -lelf -lunwind-arm
170
171 $(OUTPUT)test-libunwind-aarch64.bin:
172         $(BUILD) -lelf -lunwind-aarch64
173
174 $(OUTPUT)test-libunwind-debug-frame-arm.bin:
175         $(BUILD) -lelf -lunwind-arm
176
177 $(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
178         $(BUILD) -lelf -lunwind-aarch64
179
180 $(OUTPUT)test-libaudit.bin:
181         $(BUILD) -laudit
182
183 $(OUTPUT)test-libslang.bin:
184         $(BUILD) -I/usr/include/slang -lslang
185
186 $(OUTPUT)test-libcrypto.bin:
187         $(BUILD) -lcrypto
188
189 $(OUTPUT)test-gtk2.bin:
190         $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
191
192 $(OUTPUT)test-gtk2-infobar.bin:
193         $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
194
195 grep-libs  = $(filter -l%,$(1))
196 strip-libs = $(filter-out -l%,$(1))
197
198 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
199 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
200 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
201 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
202 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
203
204 $(OUTPUT)test-libperl.bin:
205         $(BUILD) $(FLAGS_PERL_EMBED)
206
207 $(OUTPUT)test-libpython.bin:
208         $(BUILD) $(FLAGS_PYTHON_EMBED)
209
210 $(OUTPUT)test-libpython-version.bin:
211         $(BUILD)
212
213 $(OUTPUT)test-libbfd.bin:
214         $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
215
216 $(OUTPUT)test-disassembler-four-args.bin:
217         $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
218
219 $(OUTPUT)test-reallocarray.bin:
220         $(BUILD)
221
222 $(OUTPUT)test-libbfd-liberty.bin:
223         $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
224
225 $(OUTPUT)test-libbfd-liberty-z.bin:
226         $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
227
228 $(OUTPUT)test-cplus-demangle.bin:
229         $(BUILD) -liberty
230
231 $(OUTPUT)test-backtrace.bin:
232         $(BUILD)
233
234 $(OUTPUT)test-timerfd.bin:
235         $(BUILD)
236
237 $(OUTPUT)test-libdw-dwarf-unwind.bin:
238         $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
239
240 $(OUTPUT)test-libbabeltrace.bin:
241         $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
242
243 $(OUTPUT)test-sync-compare-and-swap.bin:
244         $(BUILD)
245
246 $(OUTPUT)test-compile-32.bin:
247         $(CC) -m32 -o $@ test-compile.c
248
249 $(OUTPUT)test-compile-x32.bin:
250         $(CC) -mx32 -o $@ test-compile.c
251
252 $(OUTPUT)test-zlib.bin:
253         $(BUILD) -lz
254
255 $(OUTPUT)test-lzma.bin:
256         $(BUILD) -llzma
257
258 $(OUTPUT)test-get_cpuid.bin:
259         $(BUILD)
260
261 $(OUTPUT)test-bpf.bin:
262         $(BUILD)
263
264 $(OUTPUT)test-sdt.bin:
265         $(BUILD)
266
267 $(OUTPUT)test-cxx.bin:
268         $(BUILDXX) -std=gnu++11
269
270 $(OUTPUT)test-jvmti.bin:
271         $(BUILD)
272
273 $(OUTPUT)test-jvmti-cmlr.bin:
274         $(BUILD)
275
276 $(OUTPUT)test-llvm.bin:
277         $(BUILDXX) -std=gnu++11                                 \
278                 -I$(shell $(LLVM_CONFIG) --includedir)          \
279                 -L$(shell $(LLVM_CONFIG) --libdir)              \
280                 $(shell $(LLVM_CONFIG) --libs Core BPF)         \
281                 $(shell $(LLVM_CONFIG) --system-libs)           \
282                 > $(@:.bin=.make.output) 2>&1
283
284 $(OUTPUT)test-llvm-version.bin:
285         $(BUILDXX) -std=gnu++11                                 \
286                 -I$(shell $(LLVM_CONFIG) --includedir)          \
287                 > $(@:.bin=.make.output) 2>&1
288
289 $(OUTPUT)test-clang.bin:
290         $(BUILDXX) -std=gnu++11                                 \
291                 -I$(shell $(LLVM_CONFIG) --includedir)          \
292                 -L$(shell $(LLVM_CONFIG) --libdir)              \
293                 -Wl,--start-group -lclangBasic -lclangDriver    \
294                   -lclangFrontend -lclangEdit -lclangLex        \
295                   -lclangAST -Wl,--end-group                    \
296                 $(shell $(LLVM_CONFIG) --libs Core option)      \
297                 $(shell $(LLVM_CONFIG) --system-libs)           \
298                 > $(@:.bin=.make.output) 2>&1
299
300 -include $(OUTPUT)*.d
301
302 $(OUTPUT)test-libaio.bin:
303         $(BUILD) -lrt
304
305 $(OUTPUT)test-libzstd.bin:
306         $(BUILD) -lzstd
307
308 ###############################
309
310 clean:
311         rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)