blob: 7ceb4441b6277729215ea4ea26193e60d0095f2e [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Jiri Olsa2fedf792016-12-04 21:42:53 +01002FILES= \
3 test-all.bin \
4 test-backtrace.bin \
5 test-bionic.bin \
6 test-dwarf.bin \
7 test-dwarf_getlocations.bin \
Arnaldo Carvalho de Melo11c6cbe2018-11-21 17:42:00 -03008 test-eventfd.bin \
Jiri Olsa2fedf792016-12-04 21:42:53 +01009 test-fortify-source.bin \
10 test-sync-compare-and-swap.bin \
Arnaldo Carvalho de Melo8feb8ef2018-11-19 16:56:22 -030011 test-get_current_dir_name.bin \
Jiri Olsa2fedf792016-12-04 21:42:53 +010012 test-glibc.bin \
13 test-gtk2.bin \
14 test-gtk2-infobar.bin \
15 test-hello.bin \
16 test-libaudit.bin \
17 test-libbfd.bin \
Roman Gushchinfb982662017-12-27 19:16:29 +000018 test-disassembler-four-args.bin \
Jakub Kicinski531b0142018-07-10 14:43:05 -070019 test-reallocarray.bin \
Stanislav Fomichev14541b12018-11-15 16:32:01 -080020 test-libbfd-liberty.bin \
21 test-libbfd-liberty-z.bin \
Jiri Olsa2fedf792016-12-04 21:42:53 +010022 test-cplus-demangle.bin \
23 test-libelf.bin \
24 test-libelf-getphdrnum.bin \
25 test-libelf-gelf_getnote.bin \
26 test-libelf-getshdrstrndx.bin \
27 test-libelf-mmap.bin \
28 test-libnuma.bin \
29 test-numa_num_possible_cpus.bin \
30 test-libperl.bin \
31 test-libpython.bin \
32 test-libpython-version.bin \
33 test-libslang.bin \
34 test-libcrypto.bin \
35 test-libunwind.bin \
36 test-libunwind-debug-frame.bin \
37 test-libunwind-x86.bin \
38 test-libunwind-x86_64.bin \
39 test-libunwind-arm.bin \
40 test-libunwind-aarch64.bin \
41 test-libunwind-debug-frame-arm.bin \
42 test-libunwind-debug-frame-aarch64.bin \
43 test-pthread-attr-setaffinity-np.bin \
Arnaldo Carvalho de Melo25ab5ab2017-12-05 10:14:42 -030044 test-pthread-barrier.bin \
Jiri Olsa2fedf792016-12-04 21:42:53 +010045 test-stackprotector-all.bin \
46 test-timerfd.bin \
47 test-libdw-dwarf-unwind.bin \
48 test-libbabeltrace.bin \
49 test-compile-32.bin \
50 test-compile-x32.bin \
51 test-zlib.bin \
52 test-lzma.bin \
53 test-bpf.bin \
54 test-get_cpuid.bin \
55 test-sdt.bin \
56 test-cxx.bin \
Arnaldo Carvalho de Melo120010c2017-03-02 12:55:49 -030057 test-jvmti.bin \
Jiri Olsadd1d0042018-11-21 16:43:41 +010058 test-jvmti-cmlr.bin \
Arnaldo Carvalho de Melo86bcdb52017-07-18 17:15:29 -030059 test-sched_getcpu.bin \
Mathieu Poirieraa6292f2018-01-17 10:52:10 -070060 test-setns.bin \
Jiri Olsa36f9dc32018-03-07 16:50:19 +010061 test-libopencsd.bin \
62 test-clang.bin \
63 test-llvm.bin \
Alexey Budankov2a07d812018-11-06 12:03:35 +030064 test-llvm-version.bin \
65 test-libaio.bin
Ingo Molnarb6aa9972013-09-30 10:08:24 +020066
Josh Poimboeuf19254592015-12-15 09:39:32 -060067FILES := $(addprefix $(OUTPUT),$(FILES))
68
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070069CC ?= $(CROSS_COMPILE)gcc
70CXX ?= $(CROSS_COMPILE)g++
71PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
Wang Nancb40d552016-11-26 07:03:31 +000072LLVM_CONFIG ?= llvm-config
Ingo Molnar8b6eb562013-09-30 13:51:28 +020073
Ingo Molnarb6aa9972013-09-30 10:08:24 +020074all: $(FILES)
75
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070076__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
Josh Poimboeuf19254592015-12-15 09:39:32 -060077 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
Ingo Molnarb6aa9972013-09-30 10:08:24 +020078
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070079__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
Wang Nan87095f72016-09-26 07:26:56 +000080 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
81
Ingo Molnarb6aa9972013-09-30 10:08:24 +020082###############################
83
Josh Poimboeuf19254592015-12-15 09:39:32 -060084$(OUTPUT)test-all.bin:
Jiri Olsa6c6f0f62015-03-04 11:35:47 +010085 $(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
Ingo Molnarbaa9c302013-10-01 14:14:31 +020086
Josh Poimboeuf19254592015-12-15 09:39:32 -060087$(OUTPUT)test-hello.bin:
Ingo Molnarb6aa9972013-09-30 10:08:24 +020088 $(BUILD)
89
Josh Poimboeuf19254592015-12-15 09:39:32 -060090$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +010091 $(BUILD) -D_GNU_SOURCE -lpthread
Vineet Gupta459a3df2015-01-13 19:13:24 +053092
Arnaldo Carvalho de Melo25ab5ab2017-12-05 10:14:42 -030093$(OUTPUT)test-pthread-barrier.bin:
94 $(BUILD) -lpthread
95
Josh Poimboeuf19254592015-12-15 09:39:32 -060096$(OUTPUT)test-stackprotector-all.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +010097 $(BUILD) -fstack-protector-all
Ingo Molnar90ac5422013-09-30 13:48:44 +020098
Josh Poimboeuf19254592015-12-15 09:39:32 -060099$(OUTPUT)test-fortify-source.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +0100100 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200101
Josh Poimboeuf19254592015-12-15 09:39:32 -0600102$(OUTPUT)test-bionic.bin:
Ingo Molnar78e9d652013-09-30 14:11:46 +0200103 $(BUILD)
104
Josh Poimboeuf19254592015-12-15 09:39:32 -0600105$(OUTPUT)test-libelf.bin:
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200106 $(BUILD) -lelf
107
Arnaldo Carvalho de Melo11c6cbe2018-11-21 17:42:00 -0300108$(OUTPUT)test-eventfd.bin:
109 $(BUILD)
110
Arnaldo Carvalho de Melo8feb8ef2018-11-19 16:56:22 -0300111$(OUTPUT)test-get_current_dir_name.bin:
112 $(BUILD)
113
Josh Poimboeuf19254592015-12-15 09:39:32 -0600114$(OUTPUT)test-glibc.bin:
Ingo Molnare12762c2013-10-07 10:34:20 +0200115 $(BUILD)
116
Arnaldo Carvalho de Melo120010c2017-03-02 12:55:49 -0300117$(OUTPUT)test-sched_getcpu.bin:
118 $(BUILD)
119
Arnaldo Carvalho de Melo86bcdb52017-07-18 17:15:29 -0300120$(OUTPUT)test-setns.bin:
121 $(BUILD)
122
Mathieu Poirieraa6292f2018-01-17 10:52:10 -0700123$(OUTPUT)test-libopencsd.bin:
124 $(BUILD) # -lopencsd_c_api -lopencsd provided by
125 # $(FEATURE_CHECK_LDFLAGS-libopencsd)
126
Andi Kleen7aec51c2015-08-12 15:48:37 -0700127DWARFLIBS := -ldw
128ifeq ($(findstring -static,${LDFLAGS}),-static)
129DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
130endif
131
Josh Poimboeuf19254592015-12-15 09:39:32 -0600132$(OUTPUT)test-dwarf.bin:
Andi Kleen7aec51c2015-08-12 15:48:37 -0700133 $(BUILD) $(DWARFLIBS)
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200134
Arnaldo Carvalho de Melobd0419e2016-04-05 11:33:41 -0300135$(OUTPUT)test-dwarf_getlocations.bin:
136 $(BUILD) $(DWARFLIBS)
137
Josh Poimboeuf19254592015-12-15 09:39:32 -0600138$(OUTPUT)test-libelf-mmap.bin:
Ingo Molnar8869b172013-09-30 15:02:28 +0200139 $(BUILD) -lelf
140
Josh Poimboeuf19254592015-12-15 09:39:32 -0600141$(OUTPUT)test-libelf-getphdrnum.bin:
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200142 $(BUILD) -lelf
143
Arnaldo Carvalho de Melo1c1a3a42016-07-12 12:19:09 -0300144$(OUTPUT)test-libelf-gelf_getnote.bin:
145 $(BUILD) -lelf
146
Arnaldo Carvalho de Melo2492c462016-07-04 19:35:47 -0300147$(OUTPUT)test-libelf-getshdrstrndx.bin:
148 $(BUILD) -lelf
149
Josh Poimboeuf19254592015-12-15 09:39:32 -0600150$(OUTPUT)test-libnuma.bin:
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200151 $(BUILD) -lnuma
152
Josh Poimboeuf19254592015-12-15 09:39:32 -0600153$(OUTPUT)test-numa_num_possible_cpus.bin:
Arnaldo Carvalho de Melof8ac8602015-09-17 12:20:28 -0300154 $(BUILD) -lnuma
155
Josh Poimboeuf19254592015-12-15 09:39:32 -0600156$(OUTPUT)test-libunwind.bin:
Jean Pihet1448fef2013-12-10 13:24:04 +0100157 $(BUILD) -lelf
Ingo Molnar058f9522013-09-30 14:45:44 +0200158
Josh Poimboeuf19254592015-12-15 09:39:32 -0600159$(OUTPUT)test-libunwind-debug-frame.bin:
Jean Pihet1448fef2013-12-10 13:24:04 +0100160 $(BUILD) -lelf
He Kuangb1d96002016-05-10 07:40:31 +0000161$(OUTPUT)test-libunwind-x86.bin:
162 $(BUILD) -lelf -lunwind-x86
163
164$(OUTPUT)test-libunwind-x86_64.bin:
165 $(BUILD) -lelf -lunwind-x86_64
166
167$(OUTPUT)test-libunwind-arm.bin:
168 $(BUILD) -lelf -lunwind-arm
169
170$(OUTPUT)test-libunwind-aarch64.bin:
171 $(BUILD) -lelf -lunwind-aarch64
172
He Kuangf9be7ee2016-05-10 07:40:32 +0000173$(OUTPUT)test-libunwind-debug-frame-arm.bin:
174 $(BUILD) -lelf -lunwind-arm
175
176$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
177 $(BUILD) -lelf -lunwind-aarch64
Ingo Molnare3107182013-11-14 08:25:24 +0100178
Josh Poimboeuf19254592015-12-15 09:39:32 -0600179$(OUTPUT)test-libaudit.bin:
Ingo Molnard795a652013-09-30 14:55:31 +0200180 $(BUILD) -laudit
181
Josh Poimboeuf19254592015-12-15 09:39:32 -0600182$(OUTPUT)test-libslang.bin:
Ingo Molnarb9498b52013-09-30 14:57:54 +0200183 $(BUILD) -I/usr/include/slang -lslang
184
Stephane Eranian8ee46462015-11-30 10:02:21 +0100185$(OUTPUT)test-libcrypto.bin:
186 $(BUILD) -lcrypto
187
Josh Poimboeuf19254592015-12-15 09:39:32 -0600188$(OUTPUT)test-gtk2.bin:
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000189 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200190
Josh Poimboeuf19254592015-12-15 09:39:32 -0600191$(OUTPUT)test-gtk2-infobar.bin:
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000192 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200193
Ingo Molnar7181a672013-09-30 15:15:36 +0200194grep-libs = $(filter -l%,$(1))
195strip-libs = $(filter-out -l%,$(1))
196
197PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
198PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
199PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
200PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
201FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
202
Josh Poimboeuf19254592015-12-15 09:39:32 -0600203$(OUTPUT)test-libperl.bin:
Ingo Molnar7181a672013-09-30 15:15:36 +0200204 $(BUILD) $(FLAGS_PERL_EMBED)
205
Josh Poimboeuf19254592015-12-15 09:39:32 -0600206$(OUTPUT)test-libpython.bin:
David Carrillo-Cisneros7be6b312017-04-11 23:49:13 -0700207 $(BUILD) $(FLAGS_PYTHON_EMBED)
Ingo Molnar97341632013-09-30 15:18:37 +0200208
Josh Poimboeuf19254592015-12-15 09:39:32 -0600209$(OUTPUT)test-libpython-version.bin:
Namhyung Kim56c7d792014-07-29 15:57:19 +0900210 $(BUILD)
Ingo Molnar95d061c2013-09-30 15:40:04 +0200211
Josh Poimboeuf19254592015-12-15 09:39:32 -0600212$(OUTPUT)test-libbfd.bin:
Stanislav Fomichev14541b12018-11-15 16:32:01 -0800213 $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
Ingo Molnar3b7646e2013-09-30 15:53:31 +0200214
Roman Gushchinfb982662017-12-27 19:16:29 +0000215$(OUTPUT)test-disassembler-four-args.bin:
Jiong Wang39b72cc2018-01-16 15:51:47 -0800216 $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
Roman Gushchinfb982662017-12-27 19:16:29 +0000217
Jakub Kicinski531b0142018-07-10 14:43:05 -0700218$(OUTPUT)test-reallocarray.bin:
219 $(BUILD)
220
Stanislav Fomichev14541b12018-11-15 16:32:01 -0800221$(OUTPUT)test-libbfd-liberty.bin:
Josh Poimboeuf19254592015-12-15 09:39:32 -0600222 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
Ingo Molnar1c476612013-10-02 15:15:09 +0200223
Stanislav Fomichev14541b12018-11-15 16:32:01 -0800224$(OUTPUT)test-libbfd-liberty-z.bin:
Josh Poimboeuf19254592015-12-15 09:39:32 -0600225 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
Ingo Molnar1c476612013-10-02 15:15:09 +0200226
Josh Poimboeuf19254592015-12-15 09:39:32 -0600227$(OUTPUT)test-cplus-demangle.bin:
Ingo Molnar1c476612013-10-02 15:15:09 +0200228 $(BUILD) -liberty
229
Josh Poimboeuf19254592015-12-15 09:39:32 -0600230$(OUTPUT)test-backtrace.bin:
Ingo Molnar4cc91172013-09-30 16:49:38 +0200231 $(BUILD)
232
Josh Poimboeuf19254592015-12-15 09:39:32 -0600233$(OUTPUT)test-timerfd.bin:
David Ahern87419c92013-10-29 10:43:16 -0600234 $(BUILD)
235
Josh Poimboeuf19254592015-12-15 09:39:32 -0600236$(OUTPUT)test-libdw-dwarf-unwind.bin:
Jiri Olsa53d0a572015-02-20 23:16:58 +0100237 $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
238
Josh Poimboeuf19254592015-12-15 09:39:32 -0600239$(OUTPUT)test-libbabeltrace.bin:
Jiri Olsa53d0a572015-02-20 23:16:58 +0100240 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
Jiri Olsa45757892014-02-19 16:52:56 +0100241
Josh Poimboeuf19254592015-12-15 09:39:32 -0600242$(OUTPUT)test-sync-compare-and-swap.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +0100243 $(BUILD)
Adrian Hunterf6d31362014-07-14 13:02:53 +0300244
Josh Poimboeuf19254592015-12-15 09:39:32 -0600245$(OUTPUT)test-compile-32.bin:
246 $(CC) -m32 -o $@ test-compile.c
Adrian Huntere477f3f2014-10-23 18:16:03 -0300247
Josh Poimboeuf19254592015-12-15 09:39:32 -0600248$(OUTPUT)test-compile-x32.bin:
249 $(CC) -mx32 -o $@ test-compile.c
Adrian Huntere477f3f2014-10-23 18:16:03 -0300250
Josh Poimboeuf19254592015-12-15 09:39:32 -0600251$(OUTPUT)test-zlib.bin:
Namhyung Kime92ce122014-10-31 16:51:38 +0900252 $(BUILD) -lz
253
Josh Poimboeuf19254592015-12-15 09:39:32 -0600254$(OUTPUT)test-lzma.bin:
Jiri Olsa6c6f0f62015-03-04 11:35:47 +0100255 $(BUILD) -llzma
256
Josh Poimboeuf19254592015-12-15 09:39:32 -0600257$(OUTPUT)test-get_cpuid.bin:
Arnaldo Carvalho de Melob0063db2015-09-17 12:54:30 -0300258 $(BUILD)
259
Josh Poimboeuf19254592015-12-15 09:39:32 -0600260$(OUTPUT)test-bpf.bin:
Wang Nan1b76c132015-07-01 02:13:51 +0000261 $(BUILD)
262
Masami Hiramatsue26e63b2016-07-12 19:05:56 +0900263$(OUTPUT)test-sdt.bin:
264 $(BUILD)
265
Wang Nan87095f72016-09-26 07:26:56 +0000266$(OUTPUT)test-cxx.bin:
267 $(BUILDXX) -std=gnu++11
268
Jiri Olsa285932a2016-11-02 14:35:48 +0100269$(OUTPUT)test-jvmti.bin:
270 $(BUILD)
271
Jiri Olsadd1d0042018-11-21 16:43:41 +0100272$(OUTPUT)test-jvmti-cmlr.bin:
273 $(BUILD)
274
Wang Nancb40d552016-11-26 07:03:31 +0000275$(OUTPUT)test-llvm.bin:
Wang Nana940cad2016-12-06 07:22:30 +0000276 $(BUILDXX) -std=gnu++11 \
Wang Nancb40d552016-11-26 07:03:31 +0000277 -I$(shell $(LLVM_CONFIG) --includedir) \
278 -L$(shell $(LLVM_CONFIG) --libdir) \
279 $(shell $(LLVM_CONFIG) --libs Core BPF) \
Jiri Olsa5fb3d8b2018-03-07 16:50:20 +0100280 $(shell $(LLVM_CONFIG) --system-libs) \
281 > $(@:.bin=.make.output) 2>&1
Wang Nancb40d552016-11-26 07:03:31 +0000282
Wang Nana940cad2016-12-06 07:22:30 +0000283$(OUTPUT)test-llvm-version.bin:
284 $(BUILDXX) -std=gnu++11 \
Jiri Olsa5fb3d8b2018-03-07 16:50:20 +0100285 -I$(shell $(LLVM_CONFIG) --includedir) \
286 > $(@:.bin=.make.output) 2>&1
Wang Nana940cad2016-12-06 07:22:30 +0000287
Wang Nanc7fb4f62016-11-26 07:03:32 +0000288$(OUTPUT)test-clang.bin:
Wang Nana940cad2016-12-06 07:22:30 +0000289 $(BUILDXX) -std=gnu++11 \
Wang Nanc7fb4f62016-11-26 07:03:32 +0000290 -I$(shell $(LLVM_CONFIG) --includedir) \
291 -L$(shell $(LLVM_CONFIG) --libdir) \
292 -Wl,--start-group -lclangBasic -lclangDriver \
293 -lclangFrontend -lclangEdit -lclangLex \
294 -lclangAST -Wl,--end-group \
295 $(shell $(LLVM_CONFIG) --libs Core option) \
Jiri Olsa5fb3d8b2018-03-07 16:50:20 +0100296 $(shell $(LLVM_CONFIG) --system-libs) \
297 > $(@:.bin=.make.output) 2>&1
Wang Nanc7fb4f62016-11-26 07:03:32 +0000298
Josh Poimboeuf19254592015-12-15 09:39:32 -0600299-include $(OUTPUT)*.d
Ingo Molnar8b6eb562013-09-30 13:51:28 +0200300
Alexey Budankov2a07d812018-11-06 12:03:35 +0300301$(OUTPUT)test-libaio.bin:
302 $(BUILD) -lrt
303
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200304###############################
305
306clean:
Josh Poimboeuf19254592015-12-15 09:39:32 -0600307 rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)