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