Makefile 7.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
FILES=                                          \
         test-all.bin                           \
         test-backtrace.bin                     \
         test-bionic.bin                        \
         test-dwarf.bin                         \
         test-dwarf_getlocations.bin            \
         test-fortify-source.bin                \
         test-sync-compare-and-swap.bin         \
         test-glibc.bin                         \
         test-gtk2.bin                          \
         test-gtk2-infobar.bin                  \
         test-hello.bin                         \
         test-libaudit.bin                      \
         test-libbfd.bin                        \
         test-liberty.bin                       \
         test-liberty-z.bin                     \
         test-cplus-demangle.bin                \
         test-libelf.bin                        \
         test-libelf-getphdrnum.bin             \
         test-libelf-gelf_getnote.bin           \
         test-libelf-getshdrstrndx.bin          \
         test-libelf-mmap.bin                   \
         test-libnuma.bin                       \
         test-numa_num_possible_cpus.bin        \
         test-libperl.bin                       \
         test-libpython.bin                     \
         test-libpython-version.bin             \
         test-libslang.bin                      \
         test-libcrypto.bin                     \
         test-libunwind.bin                     \
         test-libunwind-debug-frame.bin         \
         test-libunwind-x86.bin                 \
         test-libunwind-x86_64.bin              \
         test-libunwind-arm.bin                 \
         test-libunwind-aarch64.bin             \
         test-libunwind-debug-frame-arm.bin     \
         test-libunwind-debug-frame-aarch64.bin \
         test-pthread-attr-setaffinity-np.bin   \
         test-stackprotector-all.bin            \
         test-timerfd.bin                       \
         test-libdw-dwarf-unwind.bin            \
         test-libbabeltrace.bin                 \
         test-compile-32.bin                    \
         test-compile-x32.bin                   \
         test-zlib.bin                          \
         test-lzma.bin                          \
         test-bpf.bin                           \
         test-get_cpuid.bin                     \
         test-sdt.bin                           \
         test-cxx.bin                           \
         test-jvmti.bin
52

53 54
FILES := $(addprefix $(OUTPUT),$(FILES))

M
Mark Rutland 已提交
55
CC := $(CROSS_COMPILE)gcc -MD
56
CXX := $(CROSS_COMPILE)g++ -MD
M
Mark Rutland 已提交
57
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
58
LLVM_CONFIG ?= llvm-config
59

60 61
all: $(FILES)

62 63
__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
  BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
64

65 66 67
__BUILDXX = $(CXX) $(CXXFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
  BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1

68 69
###############################

70
$(OUTPUT)test-all.bin:
71
	$(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
72

73
$(OUTPUT)test-hello.bin:
74 75
	$(BUILD)

76
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
77
	$(BUILD) -D_GNU_SOURCE -lpthread
78

79
$(OUTPUT)test-stackprotector-all.bin:
80
	$(BUILD) -fstack-protector-all
81

82
$(OUTPUT)test-fortify-source.bin:
83
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
84

85
$(OUTPUT)test-bionic.bin:
86 87
	$(BUILD)

88
$(OUTPUT)test-libelf.bin:
89 90
	$(BUILD) -lelf

91
$(OUTPUT)test-glibc.bin:
92 93
	$(BUILD)

94 95 96 97 98
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

99
$(OUTPUT)test-dwarf.bin:
100
	$(BUILD) $(DWARFLIBS)
101

102 103 104
$(OUTPUT)test-dwarf_getlocations.bin:
	$(BUILD) $(DWARFLIBS)

105
$(OUTPUT)test-libelf-mmap.bin:
106 107
	$(BUILD) -lelf

108
$(OUTPUT)test-libelf-getphdrnum.bin:
109 110
	$(BUILD) -lelf

111 112 113
$(OUTPUT)test-libelf-gelf_getnote.bin:
	$(BUILD) -lelf

114 115 116
$(OUTPUT)test-libelf-getshdrstrndx.bin:
	$(BUILD) -lelf

117
$(OUTPUT)test-libnuma.bin:
118 119
	$(BUILD) -lnuma

120
$(OUTPUT)test-numa_num_possible_cpus.bin:
121 122
	$(BUILD) -lnuma

123
$(OUTPUT)test-libunwind.bin:
124
	$(BUILD) -lelf
125

126
$(OUTPUT)test-libunwind-debug-frame.bin:
127
	$(BUILD) -lelf
128 129 130 131 132 133 134 135 136 137 138 139
$(OUTPUT)test-libunwind-x86.bin:
	$(BUILD) -lelf -lunwind-x86

$(OUTPUT)test-libunwind-x86_64.bin:
	$(BUILD) -lelf -lunwind-x86_64

$(OUTPUT)test-libunwind-arm.bin:
	$(BUILD) -lelf -lunwind-arm

$(OUTPUT)test-libunwind-aarch64.bin:
	$(BUILD) -lelf -lunwind-aarch64

140 141 142 143 144
$(OUTPUT)test-libunwind-debug-frame-arm.bin:
	$(BUILD) -lelf -lunwind-arm

$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
	$(BUILD) -lelf -lunwind-aarch64
145

146
$(OUTPUT)test-libaudit.bin:
147 148
	$(BUILD) -laudit

149
$(OUTPUT)test-libslang.bin:
150 151
	$(BUILD) -I/usr/include/slang -lslang

152 153 154
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

155
$(OUTPUT)test-gtk2.bin:
M
Mark Rutland 已提交
156
	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
157

158
$(OUTPUT)test-gtk2-infobar.bin:
M
Mark Rutland 已提交
159
	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
160

161 162 163 164 165 166 167 168 169
grep-libs  = $(filter -l%,$(1))
strip-libs = $(filter-out -l%,$(1))

PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)

170
$(OUTPUT)test-libperl.bin:
171 172
	$(BUILD) $(FLAGS_PERL_EMBED)

173
$(OUTPUT)test-libpython.bin:
174
	$(BUILD)
175

176
$(OUTPUT)test-libpython-version.bin:
177
	$(BUILD)
178

179
$(OUTPUT)test-libbfd.bin:
180
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
181

182 183
$(OUTPUT)test-liberty.bin:
	$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
184

185 186
$(OUTPUT)test-liberty-z.bin:
	$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
187

188
$(OUTPUT)test-cplus-demangle.bin:
189 190
	$(BUILD) -liberty

191
$(OUTPUT)test-backtrace.bin:
192 193
	$(BUILD)

194
$(OUTPUT)test-timerfd.bin:
195 196
	$(BUILD)

197
$(OUTPUT)test-libdw-dwarf-unwind.bin:
198 199
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

200
$(OUTPUT)test-libbabeltrace.bin:
201
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
202

203
$(OUTPUT)test-sync-compare-and-swap.bin:
204
	$(BUILD)
205

206 207
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
208

209 210
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
211

212
$(OUTPUT)test-zlib.bin:
213 214
	$(BUILD) -lz

215
$(OUTPUT)test-lzma.bin:
216 217
	$(BUILD) -llzma

218
$(OUTPUT)test-get_cpuid.bin:
219 220
	$(BUILD)

221
$(OUTPUT)test-bpf.bin:
222 223
	$(BUILD)

224 225 226
$(OUTPUT)test-sdt.bin:
	$(BUILD)

227 228 229
$(OUTPUT)test-cxx.bin:
	$(BUILDXX) -std=gnu++11

230 231 232
$(OUTPUT)test-jvmti.bin:
	$(BUILD)

233 234 235 236 237 238 239
$(OUTPUT)test-llvm.bin:
	$(BUILDXX) -std=gnu++11 					\
		-I$(shell $(LLVM_CONFIG) --includedir) 		\
		-L$(shell $(LLVM_CONFIG) --libdir)		\
		$(shell $(LLVM_CONFIG) --libs Core BPF)		\
		$(shell $(LLVM_CONFIG) --system-libs)

240 241 242 243 244 245 246 247 248 249
$(OUTPUT)test-clang.bin:
	$(BUILDXX) -std=gnu++11 					\
		-I$(shell $(LLVM_CONFIG) --includedir) 		\
		-L$(shell $(LLVM_CONFIG) --libdir)		\
		-Wl,--start-group -lclangBasic -lclangDriver	\
		  -lclangFrontend -lclangEdit -lclangLex	\
		  -lclangAST -Wl,--end-group 			\
		$(shell $(LLVM_CONFIG) --libs Core option)	\
		$(shell $(LLVM_CONFIG) --system-libs)

250
-include $(OUTPUT)*.d
251

252 253 254
###############################

clean:
255
	rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)