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