Makefile 3.7 KB
Newer Older
1

2
FILES=					\
3 4 5 6 7
	test-all.bin			\
	test-backtrace.bin		\
	test-bionic.bin			\
	test-dwarf.bin			\
	test-fortify-source.bin		\
8
	test-sync-compare-and-swap.bin	\
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
	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		\
	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 37
	test-lzma.bin			\
	test-bpf.bin
38

M
Mark Rutland 已提交
39 40
CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
41

42 43
all: $(FILES)

44 45
__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
  BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1
46 47 48

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

49
test-all.bin:
50
	$(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
51

52
test-hello.bin:
53 54
	$(BUILD)

55
test-pthread-attr-setaffinity-np.bin:
56
	$(BUILD) -D_GNU_SOURCE -lpthread
57

58
test-stackprotector-all.bin:
59
	$(BUILD) -fstack-protector-all
60

61
test-fortify-source.bin:
62
	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
63

64
test-bionic.bin:
65 66
	$(BUILD)

67
test-libelf.bin:
68 69
	$(BUILD) -lelf

70
test-glibc.bin:
71 72
	$(BUILD)

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

78
test-dwarf.bin:
79
	$(BUILD) $(DWARFLIBS)
80

81
test-libelf-mmap.bin:
82 83
	$(BUILD) -lelf

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

87
test-libnuma.bin:
88 89
	$(BUILD) -lnuma

90
test-libunwind.bin:
91
	$(BUILD) -lelf
92

93
test-libunwind-debug-frame.bin:
94
	$(BUILD) -lelf
95

96
test-libaudit.bin:
97 98
	$(BUILD) -laudit

99
test-libslang.bin:
100 101
	$(BUILD) -I/usr/include/slang -lslang

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

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

108 109 110 111 112 113 114 115 116
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)

117
test-libperl.bin:
118 119
	$(BUILD) $(FLAGS_PERL_EMBED)

120
test-libpython.bin:
121
	$(BUILD)
122

123
test-libpython-version.bin:
124
	$(BUILD)
125

126
test-libbfd.bin:
127
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
128

129
test-liberty.bin:
130
	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
131

132
test-liberty-z.bin:
133
	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
134

135
test-cplus-demangle.bin:
136 137
	$(BUILD) -liberty

138
test-backtrace.bin:
139 140
	$(BUILD)

141
test-timerfd.bin:
142 143
	$(BUILD)

144
test-libdw-dwarf-unwind.bin:
145 146 147 148
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

test-libbabeltrace.bin:
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
149

150
test-sync-compare-and-swap.bin:
151
	$(BUILD)
152

153 154 155 156 157 158
test-compile-32.bin:
	$(CC) -m32 -o $(OUTPUT)$@ test-compile.c

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

159 160 161
test-zlib.bin:
	$(BUILD) -lz

162 163 164
test-lzma.bin:
	$(BUILD) -llzma

165 166 167
test-bpf.bin:
	$(BUILD)

168
-include *.d
169

170 171 172
###############################

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