blob: e35e4e5ad192e6126404b4f5ee52e397e2bb22db [file] [log] [blame]
Jiri Olsa2fedf792016-12-04 21:42:53 +01001FILES= \
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 \
Arnaldo Carvalho de Melo120010c2017-03-02 12:55:49 -030051 test-jvmti.bin \
52 test-sched_getcpu.bin
Ingo Molnarb6aa9972013-09-30 10:08:24 +020053
Josh Poimboeuf19254592015-12-15 09:39:32 -060054FILES := $(addprefix $(OUTPUT),$(FILES))
55
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070056CC ?= $(CROSS_COMPILE)gcc
57CXX ?= $(CROSS_COMPILE)g++
58PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
Wang Nancb40d552016-11-26 07:03:31 +000059LLVM_CONFIG ?= llvm-config
Ingo Molnar8b6eb562013-09-30 13:51:28 +020060
Ingo Molnarb6aa9972013-09-30 10:08:24 +020061all: $(FILES)
62
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070063__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
Josh Poimboeuf19254592015-12-15 09:39:32 -060064 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
Ingo Molnarb6aa9972013-09-30 10:08:24 +020065
David Carrillo-Cisneros9961aa62017-04-11 23:49:14 -070066__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
Wang Nan87095f72016-09-26 07:26:56 +000067 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
68
Ingo Molnarb6aa9972013-09-30 10:08:24 +020069###############################
70
Josh Poimboeuf19254592015-12-15 09:39:32 -060071$(OUTPUT)test-all.bin:
Jiri Olsa6c6f0f62015-03-04 11:35:47 +010072 $(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 +020073
Josh Poimboeuf19254592015-12-15 09:39:32 -060074$(OUTPUT)test-hello.bin:
Ingo Molnarb6aa9972013-09-30 10:08:24 +020075 $(BUILD)
76
Josh Poimboeuf19254592015-12-15 09:39:32 -060077$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +010078 $(BUILD) -D_GNU_SOURCE -lpthread
Vineet Gupta459a3df2015-01-13 19:13:24 +053079
Josh Poimboeuf19254592015-12-15 09:39:32 -060080$(OUTPUT)test-stackprotector-all.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +010081 $(BUILD) -fstack-protector-all
Ingo Molnar90ac5422013-09-30 13:48:44 +020082
Josh Poimboeuf19254592015-12-15 09:39:32 -060083$(OUTPUT)test-fortify-source.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +010084 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
Ingo Molnar1ea6f992013-10-07 09:38:28 +020085
Josh Poimboeuf19254592015-12-15 09:39:32 -060086$(OUTPUT)test-bionic.bin:
Ingo Molnar78e9d652013-09-30 14:11:46 +020087 $(BUILD)
88
Josh Poimboeuf19254592015-12-15 09:39:32 -060089$(OUTPUT)test-libelf.bin:
Ingo Molnar8f7f8002013-09-30 14:20:25 +020090 $(BUILD) -lelf
91
Josh Poimboeuf19254592015-12-15 09:39:32 -060092$(OUTPUT)test-glibc.bin:
Ingo Molnare12762c2013-10-07 10:34:20 +020093 $(BUILD)
94
Arnaldo Carvalho de Melo120010c2017-03-02 12:55:49 -030095$(OUTPUT)test-sched_getcpu.bin:
96 $(BUILD)
97
Andi Kleen7aec51c2015-08-12 15:48:37 -070098DWARFLIBS := -ldw
99ifeq ($(findstring -static,${LDFLAGS}),-static)
100DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
101endif
102
Josh Poimboeuf19254592015-12-15 09:39:32 -0600103$(OUTPUT)test-dwarf.bin:
Andi Kleen7aec51c2015-08-12 15:48:37 -0700104 $(BUILD) $(DWARFLIBS)
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200105
Arnaldo Carvalho de Melobd0419e2016-04-05 11:33:41 -0300106$(OUTPUT)test-dwarf_getlocations.bin:
107 $(BUILD) $(DWARFLIBS)
108
Josh Poimboeuf19254592015-12-15 09:39:32 -0600109$(OUTPUT)test-libelf-mmap.bin:
Ingo Molnar8869b172013-09-30 15:02:28 +0200110 $(BUILD) -lelf
111
Josh Poimboeuf19254592015-12-15 09:39:32 -0600112$(OUTPUT)test-libelf-getphdrnum.bin:
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200113 $(BUILD) -lelf
114
Arnaldo Carvalho de Melo1c1a3a42016-07-12 12:19:09 -0300115$(OUTPUT)test-libelf-gelf_getnote.bin:
116 $(BUILD) -lelf
117
Arnaldo Carvalho de Melo2492c462016-07-04 19:35:47 -0300118$(OUTPUT)test-libelf-getshdrstrndx.bin:
119 $(BUILD) -lelf
120
Josh Poimboeuf19254592015-12-15 09:39:32 -0600121$(OUTPUT)test-libnuma.bin:
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200122 $(BUILD) -lnuma
123
Josh Poimboeuf19254592015-12-15 09:39:32 -0600124$(OUTPUT)test-numa_num_possible_cpus.bin:
Arnaldo Carvalho de Melof8ac8602015-09-17 12:20:28 -0300125 $(BUILD) -lnuma
126
Josh Poimboeuf19254592015-12-15 09:39:32 -0600127$(OUTPUT)test-libunwind.bin:
Jean Pihet1448fef2013-12-10 13:24:04 +0100128 $(BUILD) -lelf
Ingo Molnar058f9522013-09-30 14:45:44 +0200129
Josh Poimboeuf19254592015-12-15 09:39:32 -0600130$(OUTPUT)test-libunwind-debug-frame.bin:
Jean Pihet1448fef2013-12-10 13:24:04 +0100131 $(BUILD) -lelf
He Kuangb1d96002016-05-10 07:40:31 +0000132$(OUTPUT)test-libunwind-x86.bin:
133 $(BUILD) -lelf -lunwind-x86
134
135$(OUTPUT)test-libunwind-x86_64.bin:
136 $(BUILD) -lelf -lunwind-x86_64
137
138$(OUTPUT)test-libunwind-arm.bin:
139 $(BUILD) -lelf -lunwind-arm
140
141$(OUTPUT)test-libunwind-aarch64.bin:
142 $(BUILD) -lelf -lunwind-aarch64
143
He Kuangf9be7ee2016-05-10 07:40:32 +0000144$(OUTPUT)test-libunwind-debug-frame-arm.bin:
145 $(BUILD) -lelf -lunwind-arm
146
147$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
148 $(BUILD) -lelf -lunwind-aarch64
Ingo Molnare3107182013-11-14 08:25:24 +0100149
Josh Poimboeuf19254592015-12-15 09:39:32 -0600150$(OUTPUT)test-libaudit.bin:
Ingo Molnard795a652013-09-30 14:55:31 +0200151 $(BUILD) -laudit
152
Josh Poimboeuf19254592015-12-15 09:39:32 -0600153$(OUTPUT)test-libslang.bin:
Ingo Molnarb9498b52013-09-30 14:57:54 +0200154 $(BUILD) -I/usr/include/slang -lslang
155
Stephane Eranian8ee46462015-11-30 10:02:21 +0100156$(OUTPUT)test-libcrypto.bin:
157 $(BUILD) -lcrypto
158
Josh Poimboeuf19254592015-12-15 09:39:32 -0600159$(OUTPUT)test-gtk2.bin:
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000160 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200161
Josh Poimboeuf19254592015-12-15 09:39:32 -0600162$(OUTPUT)test-gtk2-infobar.bin:
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000163 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200164
Ingo Molnar7181a672013-09-30 15:15:36 +0200165grep-libs = $(filter -l%,$(1))
166strip-libs = $(filter-out -l%,$(1))
167
168PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
169PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
170PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
171PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
172FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
173
Josh Poimboeuf19254592015-12-15 09:39:32 -0600174$(OUTPUT)test-libperl.bin:
Ingo Molnar7181a672013-09-30 15:15:36 +0200175 $(BUILD) $(FLAGS_PERL_EMBED)
176
Josh Poimboeuf19254592015-12-15 09:39:32 -0600177$(OUTPUT)test-libpython.bin:
David Carrillo-Cisneros7be6b312017-04-11 23:49:13 -0700178 $(BUILD) $(FLAGS_PYTHON_EMBED)
Ingo Molnar97341632013-09-30 15:18:37 +0200179
Josh Poimboeuf19254592015-12-15 09:39:32 -0600180$(OUTPUT)test-libpython-version.bin:
Namhyung Kim56c7d792014-07-29 15:57:19 +0900181 $(BUILD)
Ingo Molnar95d061c2013-09-30 15:40:04 +0200182
Josh Poimboeuf19254592015-12-15 09:39:32 -0600183$(OUTPUT)test-libbfd.bin:
Andi Kleen280e7c42014-01-11 11:42:51 -0800184 $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
Ingo Molnar3b7646e2013-09-30 15:53:31 +0200185
Josh Poimboeuf19254592015-12-15 09:39:32 -0600186$(OUTPUT)test-liberty.bin:
187 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
Ingo Molnar1c476612013-10-02 15:15:09 +0200188
Josh Poimboeuf19254592015-12-15 09:39:32 -0600189$(OUTPUT)test-liberty-z.bin:
190 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
Ingo Molnar1c476612013-10-02 15:15:09 +0200191
Josh Poimboeuf19254592015-12-15 09:39:32 -0600192$(OUTPUT)test-cplus-demangle.bin:
Ingo Molnar1c476612013-10-02 15:15:09 +0200193 $(BUILD) -liberty
194
Josh Poimboeuf19254592015-12-15 09:39:32 -0600195$(OUTPUT)test-backtrace.bin:
Ingo Molnar4cc91172013-09-30 16:49:38 +0200196 $(BUILD)
197
Josh Poimboeuf19254592015-12-15 09:39:32 -0600198$(OUTPUT)test-timerfd.bin:
David Ahern87419c92013-10-29 10:43:16 -0600199 $(BUILD)
200
Josh Poimboeuf19254592015-12-15 09:39:32 -0600201$(OUTPUT)test-libdw-dwarf-unwind.bin:
Jiri Olsa53d0a572015-02-20 23:16:58 +0100202 $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
203
Josh Poimboeuf19254592015-12-15 09:39:32 -0600204$(OUTPUT)test-libbabeltrace.bin:
Jiri Olsa53d0a572015-02-20 23:16:58 +0100205 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
Jiri Olsa45757892014-02-19 16:52:56 +0100206
Josh Poimboeuf19254592015-12-15 09:39:32 -0600207$(OUTPUT)test-sync-compare-and-swap.bin:
Ingo Molnarb49f1a42015-02-28 10:16:27 +0100208 $(BUILD)
Adrian Hunterf6d31362014-07-14 13:02:53 +0300209
Josh Poimboeuf19254592015-12-15 09:39:32 -0600210$(OUTPUT)test-compile-32.bin:
211 $(CC) -m32 -o $@ test-compile.c
Adrian Huntere477f3f2014-10-23 18:16:03 -0300212
Josh Poimboeuf19254592015-12-15 09:39:32 -0600213$(OUTPUT)test-compile-x32.bin:
214 $(CC) -mx32 -o $@ test-compile.c
Adrian Huntere477f3f2014-10-23 18:16:03 -0300215
Josh Poimboeuf19254592015-12-15 09:39:32 -0600216$(OUTPUT)test-zlib.bin:
Namhyung Kime92ce122014-10-31 16:51:38 +0900217 $(BUILD) -lz
218
Josh Poimboeuf19254592015-12-15 09:39:32 -0600219$(OUTPUT)test-lzma.bin:
Jiri Olsa6c6f0f62015-03-04 11:35:47 +0100220 $(BUILD) -llzma
221
Josh Poimboeuf19254592015-12-15 09:39:32 -0600222$(OUTPUT)test-get_cpuid.bin:
Arnaldo Carvalho de Melob0063db2015-09-17 12:54:30 -0300223 $(BUILD)
224
Josh Poimboeuf19254592015-12-15 09:39:32 -0600225$(OUTPUT)test-bpf.bin:
Wang Nan1b76c132015-07-01 02:13:51 +0000226 $(BUILD)
227
Masami Hiramatsue26e63b2016-07-12 19:05:56 +0900228$(OUTPUT)test-sdt.bin:
229 $(BUILD)
230
Wang Nan87095f72016-09-26 07:26:56 +0000231$(OUTPUT)test-cxx.bin:
232 $(BUILDXX) -std=gnu++11
233
Jiri Olsa285932a2016-11-02 14:35:48 +0100234$(OUTPUT)test-jvmti.bin:
235 $(BUILD)
236
Wang Nancb40d552016-11-26 07:03:31 +0000237$(OUTPUT)test-llvm.bin:
Wang Nana940cad2016-12-06 07:22:30 +0000238 $(BUILDXX) -std=gnu++11 \
Wang Nancb40d552016-11-26 07:03:31 +0000239 -I$(shell $(LLVM_CONFIG) --includedir) \
240 -L$(shell $(LLVM_CONFIG) --libdir) \
241 $(shell $(LLVM_CONFIG) --libs Core BPF) \
242 $(shell $(LLVM_CONFIG) --system-libs)
243
Wang Nana940cad2016-12-06 07:22:30 +0000244$(OUTPUT)test-llvm-version.bin:
245 $(BUILDXX) -std=gnu++11 \
246 -I$(shell $(LLVM_CONFIG) --includedir)
247
Wang Nanc7fb4f62016-11-26 07:03:32 +0000248$(OUTPUT)test-clang.bin:
Wang Nana940cad2016-12-06 07:22:30 +0000249 $(BUILDXX) -std=gnu++11 \
Wang Nanc7fb4f62016-11-26 07:03:32 +0000250 -I$(shell $(LLVM_CONFIG) --includedir) \
251 -L$(shell $(LLVM_CONFIG) --libdir) \
252 -Wl,--start-group -lclangBasic -lclangDriver \
253 -lclangFrontend -lclangEdit -lclangLex \
254 -lclangAST -Wl,--end-group \
255 $(shell $(LLVM_CONFIG) --libs Core option) \
256 $(shell $(LLVM_CONFIG) --system-libs)
257
Josh Poimboeuf19254592015-12-15 09:39:32 -0600258-include $(OUTPUT)*.d
Ingo Molnar8b6eb562013-09-30 13:51:28 +0200259
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200260###############################
261
262clean:
Josh Poimboeuf19254592015-12-15 09:39:32 -0600263 rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)