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