blob: f8ad640ffe5d1e4f8b23705562a0c0d1933655b4 [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 \
8 test-fortify-source.bin \
9 test-sync-compare-and-swap.bin \
10 test-glibc.bin \
11 test-gtk2.bin \
12 test-gtk2-infobar.bin \
13 test-hello.bin \
14 test-libaudit.bin \
15 test-libbfd.bin \
Roman Gushchinfb982662017-12-27 19:16:29 +000016 test-disassembler-four-args.bin \
Jiri Olsa2fedf792016-12-04 21:42:53 +010017 test-liberty.bin \
18 test-liberty-z.bin \
19 test-cplus-demangle.bin \
20 test-libelf.bin \
21 test-libelf-getphdrnum.bin \
22 test-libelf-gelf_getnote.bin \
23 test-libelf-getshdrstrndx.bin \
24 test-libelf-mmap.bin \
25 test-libnuma.bin \
26 test-numa_num_possible_cpus.bin \
27 test-libperl.bin \
28 test-libpython.bin \
29 test-libpython-version.bin \
30 test-libslang.bin \
31 test-libcrypto.bin \
32 test-libunwind.bin \
33 test-libunwind-debug-frame.bin \
34 test-libunwind-x86.bin \
35 test-libunwind-x86_64.bin \
36 test-libunwind-arm.bin \
37 test-libunwind-aarch64.bin \
38 test-libunwind-debug-frame-arm.bin \
39 test-libunwind-debug-frame-aarch64.bin \
40 test-pthread-attr-setaffinity-np.bin \
Arnaldo Carvalho de Melo25ab5ab2017-12-05 10:14:42 -030041 test-pthread-barrier.bin \
Jiri Olsa2fedf792016-12-04 21:42:53 +010042 test-stackprotector-all.bin \
43 test-timerfd.bin \
44 test-libdw-dwarf-unwind.bin \
45 test-libbabeltrace.bin \
46 test-compile-32.bin \
47 test-compile-x32.bin \
48 test-zlib.bin \
49 test-lzma.bin \
50 test-bpf.bin \
51 test-get_cpuid.bin \
52 test-sdt.bin \
53 test-cxx.bin \
Arnaldo Carvalho de Melo120010c2017-03-02 12:55:49 -030054 test-jvmti.bin \
Arnaldo Carvalho de Melo86bcdb52017-07-18 17:15:29 -030055 test-sched_getcpu.bin \
Mathieu Poirieraa6292f2018-01-17 10:52:10 -070056 test-setns.bin \
Jiri Olsa36f9dc32018-03-07 16:50:19 +010057 test-libopencsd.bin \
58 test-clang.bin \
59 test-llvm.bin \
60 test-llvm-version.bin
Ingo Molnarb6aa9972013-09-30 10:08:24 +020061
Josh Poimboeuf19254592015-12-15 09:39:32 -060062FILES := $(addprefix $(OUTPUT),$(FILES))
63
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070064CC ?= $(CROSS_COMPILE)gcc
65CXX ?= $(CROSS_COMPILE)g++
66PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
Wang Nancb40d552016-11-26 07:03:31 +000067LLVM_CONFIG ?= llvm-config
Ingo Molnar8b6eb562013-09-30 13:51:28 +020068
Ingo Molnarb6aa9972013-09-30 10:08:24 +020069all: $(FILES)
70
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070071__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
Josh Poimboeuf19254592015-12-15 09:39:32 -060072 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
Ingo Molnarb6aa9972013-09-30 10:08:24 +020073
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070074__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
Wang Nan87095f72016-09-26 07:26:56 +000075 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
76
Ingo Molnarb6aa9972013-09-30 10:08:24 +020077###############################
78
Josh Poimboeuf19254592015-12-15 09:39:32 -060079$(OUTPUT)test-all.bin:
Jiri Olsa6c6f0f62015-03-04 11:35:47 +010080 $(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 +020081
Josh Poimboeuf19254592015-12-15 09:39:32 -060082$(OUTPUT)test-hello.bin:
Ingo Molnarb6aa9972013-09-30 10:08:24 +020083 $(BUILD)
84
Josh Poimboeuf19254592015-12-15 09:39:32 -060085$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +010086 $(BUILD) -D_GNU_SOURCE -lpthread
Vineet Gupta459a3df2015-01-13 19:13:24 +053087
Arnaldo Carvalho de Melo25ab5ab2017-12-05 10:14:42 -030088$(OUTPUT)test-pthread-barrier.bin:
89 $(BUILD) -lpthread
90
Josh Poimboeuf19254592015-12-15 09:39:32 -060091$(OUTPUT)test-stackprotector-all.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +010092 $(BUILD) -fstack-protector-all
Ingo Molnar90ac5422013-09-30 13:48:44 +020093
Josh Poimboeuf19254592015-12-15 09:39:32 -060094$(OUTPUT)test-fortify-source.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +010095 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
Ingo Molnar1ea6f992013-10-07 09:38:28 +020096
Josh Poimboeuf19254592015-12-15 09:39:32 -060097$(OUTPUT)test-bionic.bin:
Ingo Molnar78e9d652013-09-30 14:11:46 +020098 $(BUILD)
99
Josh Poimboeuf19254592015-12-15 09:39:32 -0600100$(OUTPUT)test-libelf.bin:
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200101 $(BUILD) -lelf
102
Josh Poimboeuf19254592015-12-15 09:39:32 -0600103$(OUTPUT)test-glibc.bin:
Ingo Molnare12762c2013-10-07 10:34:20 +0200104 $(BUILD)
105
Arnaldo Carvalho de Melo120010c2017-03-02 12:55:49 -0300106$(OUTPUT)test-sched_getcpu.bin:
107 $(BUILD)
108
Arnaldo Carvalho de Melo86bcdb52017-07-18 17:15:29 -0300109$(OUTPUT)test-setns.bin:
110 $(BUILD)
111
Mathieu Poirieraa6292f2018-01-17 10:52:10 -0700112$(OUTPUT)test-libopencsd.bin:
113 $(BUILD) # -lopencsd_c_api -lopencsd provided by
114 # $(FEATURE_CHECK_LDFLAGS-libopencsd)
115
Andi Kleen7aec51c2015-08-12 15:48:37 -0700116DWARFLIBS := -ldw
117ifeq ($(findstring -static,${LDFLAGS}),-static)
118DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
119endif
120
Josh Poimboeuf19254592015-12-15 09:39:32 -0600121$(OUTPUT)test-dwarf.bin:
Andi Kleen7aec51c2015-08-12 15:48:37 -0700122 $(BUILD) $(DWARFLIBS)
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200123
Arnaldo Carvalho de Melobd0419e2016-04-05 11:33:41 -0300124$(OUTPUT)test-dwarf_getlocations.bin:
125 $(BUILD) $(DWARFLIBS)
126
Josh Poimboeuf19254592015-12-15 09:39:32 -0600127$(OUTPUT)test-libelf-mmap.bin:
Ingo Molnar8869b172013-09-30 15:02:28 +0200128 $(BUILD) -lelf
129
Josh Poimboeuf19254592015-12-15 09:39:32 -0600130$(OUTPUT)test-libelf-getphdrnum.bin:
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200131 $(BUILD) -lelf
132
Arnaldo Carvalho de Melo1c1a3a42016-07-12 12:19:09 -0300133$(OUTPUT)test-libelf-gelf_getnote.bin:
134 $(BUILD) -lelf
135
Arnaldo Carvalho de Melo2492c462016-07-04 19:35:47 -0300136$(OUTPUT)test-libelf-getshdrstrndx.bin:
137 $(BUILD) -lelf
138
Josh Poimboeuf19254592015-12-15 09:39:32 -0600139$(OUTPUT)test-libnuma.bin:
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200140 $(BUILD) -lnuma
141
Josh Poimboeuf19254592015-12-15 09:39:32 -0600142$(OUTPUT)test-numa_num_possible_cpus.bin:
Arnaldo Carvalho de Melof8ac8602015-09-17 12:20:28 -0300143 $(BUILD) -lnuma
144
Josh Poimboeuf19254592015-12-15 09:39:32 -0600145$(OUTPUT)test-libunwind.bin:
Jean Pihet1448fef2013-12-10 13:24:04 +0100146 $(BUILD) -lelf
Ingo Molnar058f9522013-09-30 14:45:44 +0200147
Josh Poimboeuf19254592015-12-15 09:39:32 -0600148$(OUTPUT)test-libunwind-debug-frame.bin:
Jean Pihet1448fef2013-12-10 13:24:04 +0100149 $(BUILD) -lelf
He Kuangb1d96002016-05-10 07:40:31 +0000150$(OUTPUT)test-libunwind-x86.bin:
151 $(BUILD) -lelf -lunwind-x86
152
153$(OUTPUT)test-libunwind-x86_64.bin:
154 $(BUILD) -lelf -lunwind-x86_64
155
156$(OUTPUT)test-libunwind-arm.bin:
157 $(BUILD) -lelf -lunwind-arm
158
159$(OUTPUT)test-libunwind-aarch64.bin:
160 $(BUILD) -lelf -lunwind-aarch64
161
He Kuangf9be7ee2016-05-10 07:40:32 +0000162$(OUTPUT)test-libunwind-debug-frame-arm.bin:
163 $(BUILD) -lelf -lunwind-arm
164
165$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
166 $(BUILD) -lelf -lunwind-aarch64
Ingo Molnare3107182013-11-14 08:25:24 +0100167
Josh Poimboeuf19254592015-12-15 09:39:32 -0600168$(OUTPUT)test-libaudit.bin:
Ingo Molnard795a652013-09-30 14:55:31 +0200169 $(BUILD) -laudit
170
Josh Poimboeuf19254592015-12-15 09:39:32 -0600171$(OUTPUT)test-libslang.bin:
Ingo Molnarb9498b52013-09-30 14:57:54 +0200172 $(BUILD) -I/usr/include/slang -lslang
173
Stephane Eranian8ee46462015-11-30 10:02:21 +0100174$(OUTPUT)test-libcrypto.bin:
175 $(BUILD) -lcrypto
176
Josh Poimboeuf19254592015-12-15 09:39:32 -0600177$(OUTPUT)test-gtk2.bin:
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000178 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200179
Josh Poimboeuf19254592015-12-15 09:39:32 -0600180$(OUTPUT)test-gtk2-infobar.bin:
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000181 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200182
Ingo Molnar7181a672013-09-30 15:15:36 +0200183grep-libs = $(filter -l%,$(1))
184strip-libs = $(filter-out -l%,$(1))
185
186PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
187PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
188PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
189PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
190FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
191
Josh Poimboeuf19254592015-12-15 09:39:32 -0600192$(OUTPUT)test-libperl.bin:
Ingo Molnar7181a672013-09-30 15:15:36 +0200193 $(BUILD) $(FLAGS_PERL_EMBED)
194
Josh Poimboeuf19254592015-12-15 09:39:32 -0600195$(OUTPUT)test-libpython.bin:
David Carrillo-Cisneros7be6b312017-04-11 23:49:13 -0700196 $(BUILD) $(FLAGS_PYTHON_EMBED)
Ingo Molnar97341632013-09-30 15:18:37 +0200197
Josh Poimboeuf19254592015-12-15 09:39:32 -0600198$(OUTPUT)test-libpython-version.bin:
Namhyung Kim56c7d792014-07-29 15:57:19 +0900199 $(BUILD)
Ingo Molnar95d061c2013-09-30 15:40:04 +0200200
Josh Poimboeuf19254592015-12-15 09:39:32 -0600201$(OUTPUT)test-libbfd.bin:
Andi Kleen280e7c42014-01-11 11:42:51 -0800202 $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
Ingo Molnar3b7646e2013-09-30 15:53:31 +0200203
Roman Gushchinfb982662017-12-27 19:16:29 +0000204$(OUTPUT)test-disassembler-four-args.bin:
Jiong Wang39b72cc2018-01-16 15:51:47 -0800205 $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
Roman Gushchinfb982662017-12-27 19:16:29 +0000206
Josh Poimboeuf19254592015-12-15 09:39:32 -0600207$(OUTPUT)test-liberty.bin:
208 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
Ingo Molnar1c476612013-10-02 15:15:09 +0200209
Josh Poimboeuf19254592015-12-15 09:39:32 -0600210$(OUTPUT)test-liberty-z.bin:
211 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
Ingo Molnar1c476612013-10-02 15:15:09 +0200212
Josh Poimboeuf19254592015-12-15 09:39:32 -0600213$(OUTPUT)test-cplus-demangle.bin:
Ingo Molnar1c476612013-10-02 15:15:09 +0200214 $(BUILD) -liberty
215
Josh Poimboeuf19254592015-12-15 09:39:32 -0600216$(OUTPUT)test-backtrace.bin:
Ingo Molnar4cc91172013-09-30 16:49:38 +0200217 $(BUILD)
218
Josh Poimboeuf19254592015-12-15 09:39:32 -0600219$(OUTPUT)test-timerfd.bin:
David Ahern87419c92013-10-29 10:43:16 -0600220 $(BUILD)
221
Josh Poimboeuf19254592015-12-15 09:39:32 -0600222$(OUTPUT)test-libdw-dwarf-unwind.bin:
Jiri Olsa53d0a572015-02-20 23:16:58 +0100223 $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
224
Josh Poimboeuf19254592015-12-15 09:39:32 -0600225$(OUTPUT)test-libbabeltrace.bin:
Jiri Olsa53d0a572015-02-20 23:16:58 +0100226 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
Jiri Olsa45757892014-02-19 16:52:56 +0100227
Josh Poimboeuf19254592015-12-15 09:39:32 -0600228$(OUTPUT)test-sync-compare-and-swap.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +0100229 $(BUILD)
Adrian Hunterf6d31362014-07-14 13:02:53 +0300230
Josh Poimboeuf19254592015-12-15 09:39:32 -0600231$(OUTPUT)test-compile-32.bin:
232 $(CC) -m32 -o $@ test-compile.c
Adrian Huntere477f3f2014-10-23 18:16:03 -0300233
Josh Poimboeuf19254592015-12-15 09:39:32 -0600234$(OUTPUT)test-compile-x32.bin:
235 $(CC) -mx32 -o $@ test-compile.c
Adrian Huntere477f3f2014-10-23 18:16:03 -0300236
Josh Poimboeuf19254592015-12-15 09:39:32 -0600237$(OUTPUT)test-zlib.bin:
Namhyung Kime92ce122014-10-31 16:51:38 +0900238 $(BUILD) -lz
239
Josh Poimboeuf19254592015-12-15 09:39:32 -0600240$(OUTPUT)test-lzma.bin:
Jiri Olsa6c6f0f62015-03-04 11:35:47 +0100241 $(BUILD) -llzma
242
Josh Poimboeuf19254592015-12-15 09:39:32 -0600243$(OUTPUT)test-get_cpuid.bin:
Arnaldo Carvalho de Melob0063db2015-09-17 12:54:30 -0300244 $(BUILD)
245
Josh Poimboeuf19254592015-12-15 09:39:32 -0600246$(OUTPUT)test-bpf.bin:
Wang Nan1b76c132015-07-01 02:13:51 +0000247 $(BUILD)
248
Masami Hiramatsue26e63b2016-07-12 19:05:56 +0900249$(OUTPUT)test-sdt.bin:
250 $(BUILD)
251
Wang Nan87095f72016-09-26 07:26:56 +0000252$(OUTPUT)test-cxx.bin:
253 $(BUILDXX) -std=gnu++11
254
Jiri Olsa285932a2016-11-02 14:35:48 +0100255$(OUTPUT)test-jvmti.bin:
256 $(BUILD)
257
Wang Nancb40d552016-11-26 07:03:31 +0000258$(OUTPUT)test-llvm.bin:
Wang Nana940cad2016-12-06 07:22:30 +0000259 $(BUILDXX) -std=gnu++11 \
Wang Nancb40d552016-11-26 07:03:31 +0000260 -I$(shell $(LLVM_CONFIG) --includedir) \
261 -L$(shell $(LLVM_CONFIG) --libdir) \
262 $(shell $(LLVM_CONFIG) --libs Core BPF) \
263 $(shell $(LLVM_CONFIG) --system-libs)
264
Wang Nana940cad2016-12-06 07:22:30 +0000265$(OUTPUT)test-llvm-version.bin:
266 $(BUILDXX) -std=gnu++11 \
267 -I$(shell $(LLVM_CONFIG) --includedir)
268
Wang Nanc7fb4f62016-11-26 07:03:32 +0000269$(OUTPUT)test-clang.bin:
Wang Nana940cad2016-12-06 07:22:30 +0000270 $(BUILDXX) -std=gnu++11 \
Wang Nanc7fb4f62016-11-26 07:03:32 +0000271 -I$(shell $(LLVM_CONFIG) --includedir) \
272 -L$(shell $(LLVM_CONFIG) --libdir) \
273 -Wl,--start-group -lclangBasic -lclangDriver \
274 -lclangFrontend -lclangEdit -lclangLex \
275 -lclangAST -Wl,--end-group \
276 $(shell $(LLVM_CONFIG) --libs Core option) \
277 $(shell $(LLVM_CONFIG) --system-libs)
278
Josh Poimboeuf19254592015-12-15 09:39:32 -0600279-include $(OUTPUT)*.d
Ingo Molnar8b6eb562013-09-30 13:51:28 +0200280
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200281###############################
282
283clean:
Josh Poimboeuf19254592015-12-15 09:39:32 -0600284 rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)