Makefile 7.5 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
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                           \
51 52
         test-jvmti.bin				\
         test-sched_getcpu.bin
53

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

56 57 58
CC ?= $(CROSS_COMPILE)gcc
CXX ?= $(CROSS_COMPILE)g++
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
59
LLVM_CONFIG ?= llvm-config
60

61 62
all: $(FILES)

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

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

69 70
###############################

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

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

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

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

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

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

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

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

95 96 97
$(OUTPUT)test-sched_getcpu.bin:
	$(BUILD)

98 99 100 101 102
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

103
$(OUTPUT)test-dwarf.bin:
104
	$(BUILD) $(DWARFLIBS)
105

106 107 108
$(OUTPUT)test-dwarf_getlocations.bin:
	$(BUILD) $(DWARFLIBS)

109
$(OUTPUT)test-libelf-mmap.bin:
110 111
	$(BUILD) -lelf

112
$(OUTPUT)test-libelf-getphdrnum.bin:
113 114
	$(BUILD) -lelf

115 116 117
$(OUTPUT)test-libelf-gelf_getnote.bin:
	$(BUILD) -lelf

118 119 120
$(OUTPUT)test-libelf-getshdrstrndx.bin:
	$(BUILD) -lelf

121
$(OUTPUT)test-libnuma.bin:
122 123
	$(BUILD) -lnuma

124
$(OUTPUT)test-numa_num_possible_cpus.bin:
125 126
	$(BUILD) -lnuma

127
$(OUTPUT)test-libunwind.bin:
128
	$(BUILD) -lelf
129

130
$(OUTPUT)test-libunwind-debug-frame.bin:
131
	$(BUILD) -lelf
132 133 134 135 136 137 138 139 140 141 142 143
$(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

144 145 146 147 148
$(OUTPUT)test-libunwind-debug-frame-arm.bin:
	$(BUILD) -lelf -lunwind-arm

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

150
$(OUTPUT)test-libaudit.bin:
151 152
	$(BUILD) -laudit

153
$(OUTPUT)test-libslang.bin:
154 155
	$(BUILD) -I/usr/include/slang -lslang

156 157 158
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

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

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

165 166 167 168 169 170 171 172 173
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)

174
$(OUTPUT)test-libperl.bin:
175 176
	$(BUILD) $(FLAGS_PERL_EMBED)

177
$(OUTPUT)test-libpython.bin:
178
	$(BUILD) $(FLAGS_PYTHON_EMBED)
179

180
$(OUTPUT)test-libpython-version.bin:
181
	$(BUILD)
182

183
$(OUTPUT)test-libbfd.bin:
184
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
185

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

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

192
$(OUTPUT)test-cplus-demangle.bin:
193 194
	$(BUILD) -liberty

195
$(OUTPUT)test-backtrace.bin:
196 197
	$(BUILD)

198
$(OUTPUT)test-timerfd.bin:
199 200
	$(BUILD)

201
$(OUTPUT)test-libdw-dwarf-unwind.bin:
202 203
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

204
$(OUTPUT)test-libbabeltrace.bin:
205
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
206

207
$(OUTPUT)test-sync-compare-and-swap.bin:
208
	$(BUILD)
209

210 211
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
212

213 214
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
215

216
$(OUTPUT)test-zlib.bin:
217 218
	$(BUILD) -lz

219
$(OUTPUT)test-lzma.bin:
220 221
	$(BUILD) -llzma

222
$(OUTPUT)test-get_cpuid.bin:
223 224
	$(BUILD)

225
$(OUTPUT)test-bpf.bin:
226 227
	$(BUILD)

228 229 230
$(OUTPUT)test-sdt.bin:
	$(BUILD)

231 232 233
$(OUTPUT)test-cxx.bin:
	$(BUILDXX) -std=gnu++11

234 235 236
$(OUTPUT)test-jvmti.bin:
	$(BUILD)

237
$(OUTPUT)test-llvm.bin:
238
	$(BUILDXX) -std=gnu++11 				\
239 240 241 242 243
		-I$(shell $(LLVM_CONFIG) --includedir) 		\
		-L$(shell $(LLVM_CONFIG) --libdir)		\
		$(shell $(LLVM_CONFIG) --libs Core BPF)		\
		$(shell $(LLVM_CONFIG) --system-libs)

244 245 246 247
$(OUTPUT)test-llvm-version.bin:
	$(BUILDXX) -std=gnu++11 				\
		-I$(shell $(LLVM_CONFIG) --includedir)

248
$(OUTPUT)test-clang.bin:
249
	$(BUILDXX) -std=gnu++11 				\
250 251 252 253 254 255 256 257
		-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)

258
-include $(OUTPUT)*.d
259

260 261 262
###############################

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