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