xref: /openbmc/linux/tools/build/feature/Makefile (revision f3539c12)
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
51FILES := $(addprefix $(OUTPUT),$(FILES))
52
53CC := $(CROSS_COMPILE)gcc -MD
54PKG_CONFIG := $(CROSS_COMPILE)pkg-config
55
56all: $(FILES)
57
58__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
59  BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
60
61###############################
62
63$(OUTPUT)test-all.bin:
64	$(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
65
66$(OUTPUT)test-hello.bin:
67	$(BUILD)
68
69$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
70	$(BUILD) -D_GNU_SOURCE -lpthread
71
72$(OUTPUT)test-stackprotector-all.bin:
73	$(BUILD) -fstack-protector-all
74
75$(OUTPUT)test-fortify-source.bin:
76	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
77
78$(OUTPUT)test-bionic.bin:
79	$(BUILD)
80
81$(OUTPUT)test-libelf.bin:
82	$(BUILD) -lelf
83
84$(OUTPUT)test-glibc.bin:
85	$(BUILD)
86
87DWARFLIBS := -ldw
88ifeq ($(findstring -static,${LDFLAGS}),-static)
89DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
90endif
91
92$(OUTPUT)test-dwarf.bin:
93	$(BUILD) $(DWARFLIBS)
94
95$(OUTPUT)test-dwarf_getlocations.bin:
96	$(BUILD) $(DWARFLIBS)
97
98$(OUTPUT)test-libelf-mmap.bin:
99	$(BUILD) -lelf
100
101$(OUTPUT)test-libelf-getphdrnum.bin:
102	$(BUILD) -lelf
103
104$(OUTPUT)test-libelf-gelf_getnote.bin:
105	$(BUILD) -lelf
106
107$(OUTPUT)test-libelf-getshdrstrndx.bin:
108	$(BUILD) -lelf
109
110$(OUTPUT)test-libnuma.bin:
111	$(BUILD) -lnuma
112
113$(OUTPUT)test-numa_num_possible_cpus.bin:
114	$(BUILD) -lnuma
115
116$(OUTPUT)test-libunwind.bin:
117	$(BUILD) -lelf
118
119$(OUTPUT)test-libunwind-debug-frame.bin:
120	$(BUILD) -lelf
121$(OUTPUT)test-libunwind-x86.bin:
122	$(BUILD) -lelf -lunwind-x86
123
124$(OUTPUT)test-libunwind-x86_64.bin:
125	$(BUILD) -lelf -lunwind-x86_64
126
127$(OUTPUT)test-libunwind-arm.bin:
128	$(BUILD) -lelf -lunwind-arm
129
130$(OUTPUT)test-libunwind-aarch64.bin:
131	$(BUILD) -lelf -lunwind-aarch64
132
133$(OUTPUT)test-libunwind-debug-frame-arm.bin:
134	$(BUILD) -lelf -lunwind-arm
135
136$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
137	$(BUILD) -lelf -lunwind-aarch64
138
139$(OUTPUT)test-libaudit.bin:
140	$(BUILD) -laudit
141
142$(OUTPUT)test-libslang.bin:
143	$(BUILD) -I/usr/include/slang -lslang
144
145$(OUTPUT)test-libcrypto.bin:
146	$(BUILD) -lcrypto
147
148$(OUTPUT)test-gtk2.bin:
149	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
150
151$(OUTPUT)test-gtk2-infobar.bin:
152	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
153
154grep-libs  = $(filter -l%,$(1))
155strip-libs = $(filter-out -l%,$(1))
156
157PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
158PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
159PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
160PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
161FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
162
163$(OUTPUT)test-libperl.bin:
164	$(BUILD) $(FLAGS_PERL_EMBED)
165
166$(OUTPUT)test-libpython.bin:
167	$(BUILD)
168
169$(OUTPUT)test-libpython-version.bin:
170	$(BUILD)
171
172$(OUTPUT)test-libbfd.bin:
173	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
174
175$(OUTPUT)test-liberty.bin:
176	$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
177
178$(OUTPUT)test-liberty-z.bin:
179	$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
180
181$(OUTPUT)test-cplus-demangle.bin:
182	$(BUILD) -liberty
183
184$(OUTPUT)test-backtrace.bin:
185	$(BUILD)
186
187$(OUTPUT)test-timerfd.bin:
188	$(BUILD)
189
190$(OUTPUT)test-libdw-dwarf-unwind.bin:
191	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
192
193$(OUTPUT)test-libbabeltrace.bin:
194	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
195
196$(OUTPUT)test-sync-compare-and-swap.bin:
197	$(BUILD)
198
199$(OUTPUT)test-compile-32.bin:
200	$(CC) -m32 -o $@ test-compile.c
201
202$(OUTPUT)test-compile-x32.bin:
203	$(CC) -mx32 -o $@ test-compile.c
204
205$(OUTPUT)test-zlib.bin:
206	$(BUILD) -lz
207
208$(OUTPUT)test-lzma.bin:
209	$(BUILD) -llzma
210
211$(OUTPUT)test-get_cpuid.bin:
212	$(BUILD)
213
214$(OUTPUT)test-bpf.bin:
215	$(BUILD)
216
217$(OUTPUT)test-sdt.bin:
218	$(BUILD)
219
220-include $(OUTPUT)*.d
221
222###############################
223
224clean:
225	rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)
226