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