Makefile 3.4 KB
Newer Older
1

2
FILES=					\
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
	test-all.bin			\
	test-backtrace.bin		\
	test-bionic.bin			\
	test-dwarf.bin			\
	test-fortify-source.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-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	\
	test-on-exit.bin		\
	test-stackprotector-all.bin	\
29 30
	test-timerfd.bin		\
	test-libdw-dwarf-unwind.bin
31

M
Mark Rutland 已提交
32 33
CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
34

35 36
all: $(FILES)

37
BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
38 39 40

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

41
test-all.bin:
M
Mark Rutland 已提交
42
	$(BUILD) -Werror -fstack-protector-all -O2 -Werror -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
43

44
test-hello.bin:
45 46
	$(BUILD)

47
test-stackprotector-all.bin:
48 49
	$(BUILD) -Werror -fstack-protector-all

50
test-fortify-source.bin:
51 52
	$(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2

53
test-bionic.bin:
54 55
	$(BUILD)

56
test-libelf.bin:
57 58
	$(BUILD) -lelf

59
test-glibc.bin:
60 61
	$(BUILD)

62
test-dwarf.bin:
63 64
	$(BUILD) -ldw

65
test-libelf-mmap.bin:
66 67
	$(BUILD) -lelf

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

71
test-libnuma.bin:
72 73
	$(BUILD) -lnuma

74
test-libunwind.bin:
75
	$(BUILD) -lelf
76

77
test-libunwind-debug-frame.bin:
78
	$(BUILD) -lelf
79

80
test-libaudit.bin:
81 82
	$(BUILD) -laudit

83
test-libslang.bin:
84 85
	$(BUILD) -I/usr/include/slang -lslang

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

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

92 93 94 95 96 97 98 99 100
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)

101
test-libperl.bin:
102 103
	$(BUILD) $(FLAGS_PERL_EMBED)

104 105 106 107 108 109 110 111 112 113 114 115 116 117
override PYTHON := python
override PYTHON_CONFIG := python-config

escape-for-shell-sq =  $(subst ','\'',$(1))
shell-sq = '$(escape-for-shell-sq)'

PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG))

PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)

118
test-libpython.bin:
119 120
	$(BUILD) $(FLAGS_PYTHON_EMBED)

121
test-libpython-version.bin:
122 123
	$(BUILD) $(FLAGS_PYTHON_EMBED)

124
test-libbfd.bin:
125
	$(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
126

127
test-liberty.bin:
128
	$(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
129

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

133
test-cplus-demangle.bin:
134 135
	$(BUILD) -liberty

136
test-on-exit.bin:
137 138
	$(BUILD)

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

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

145 146 147
test-libdw-dwarf-unwind.bin:
	$(BUILD)

148
-include *.d
149

150 151 152
###############################

clean:
153
	rm -f $(FILES) *.d