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