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