Makefile 4.3 KB
Newer Older
1
FILES=					\
2 3 4 5 6
	test-all.bin			\
	test-backtrace.bin		\
	test-bionic.bin			\
	test-dwarf.bin			\
	test-fortify-source.bin		\
7
	test-sync-compare-and-swap.bin	\
8 9 10 11 12 13 14 15 16 17 18 19 20
	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-mmap.bin		\
	test-libnuma.bin		\
21
	test-numa_num_possible_cpus.bin	\
22 23 24 25 26 27
	test-libperl.bin		\
	test-libpython.bin		\
	test-libpython-version.bin	\
	test-libslang.bin		\
	test-libunwind.bin		\
	test-libunwind-debug-frame.bin	\
28
	test-pthread-attr-setaffinity-np.bin	\
29
	test-stackprotector-all.bin	\
30
	test-timerfd.bin		\
31
	test-libdw-dwarf-unwind.bin	\
32
	test-libbabeltrace.bin		\
33
	test-compile-32.bin		\
34
	test-compile-x32.bin		\
35
	test-zlib.bin			\
36
	test-lzma.bin			\
37 38
	test-bpf.bin			\
	test-get_cpuid.bin
39

40 41
FILES := $(addprefix $(OUTPUT),$(FILES))

M
Mark Rutland 已提交
42 43
CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
44

45 46
all: $(FILES)

47 48
__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
  BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
49 50 51

###############################

52
$(OUTPUT)test-all.bin:
53
	$(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
54

55
$(OUTPUT)test-hello.bin:
56 57
	$(BUILD)

58
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
59
	$(BUILD) -D_GNU_SOURCE -lpthread
60

61
$(OUTPUT)test-stackprotector-all.bin:
62
	$(BUILD) -fstack-protector-all
63

64
$(OUTPUT)test-fortify-source.bin:
65
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
66

67
$(OUTPUT)test-bionic.bin:
68 69
	$(BUILD)

70
$(OUTPUT)test-libelf.bin:
71 72
	$(BUILD) -lelf

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

76 77 78 79 80
DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

81
$(OUTPUT)test-dwarf.bin:
82
	$(BUILD) $(DWARFLIBS)
83

84
$(OUTPUT)test-libelf-mmap.bin:
85 86
	$(BUILD) -lelf

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

90
$(OUTPUT)test-libnuma.bin:
91 92
	$(BUILD) -lnuma

93
$(OUTPUT)test-numa_num_possible_cpus.bin:
94 95
	$(BUILD) -lnuma

96
$(OUTPUT)test-libunwind.bin:
97
	$(BUILD) -lelf
98

99
$(OUTPUT)test-libunwind-debug-frame.bin:
100
	$(BUILD) -lelf
101

102
$(OUTPUT)test-libaudit.bin:
103 104
	$(BUILD) -laudit

105
$(OUTPUT)test-libslang.bin:
106 107
	$(BUILD) -I/usr/include/slang -lslang

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

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

114 115 116 117 118 119 120 121 122
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)

123
$(OUTPUT)test-libperl.bin:
124 125
	$(BUILD) $(FLAGS_PERL_EMBED)

126
$(OUTPUT)test-libpython.bin:
127
	$(BUILD)
128

129
$(OUTPUT)test-libpython-version.bin:
130
	$(BUILD)
131

132
$(OUTPUT)test-libbfd.bin:
133
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
134

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

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

141
$(OUTPUT)test-cplus-demangle.bin:
142 143
	$(BUILD) -liberty

144
$(OUTPUT)test-backtrace.bin:
145 146
	$(BUILD)

147
$(OUTPUT)test-timerfd.bin:
148 149
	$(BUILD)

150
$(OUTPUT)test-libdw-dwarf-unwind.bin:
151 152
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

153
$(OUTPUT)test-libbabeltrace.bin:
154
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
155

156
$(OUTPUT)test-sync-compare-and-swap.bin:
157
	$(BUILD)
158

159 160
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
161

162 163
$(OUTPUT)test-compile-x32.bin:
	$(CC) -mx32 -o $@ test-compile.c
164

165
$(OUTPUT)test-zlib.bin:
166 167
	$(BUILD) -lz

168
$(OUTPUT)test-lzma.bin:
169 170
	$(BUILD) -llzma

171
$(OUTPUT)test-get_cpuid.bin:
172 173
	$(BUILD)

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

177
-include $(OUTPUT)*.d
178

179 180 181
###############################

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