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

42 43
FILES := $(addprefix $(OUTPUT),$(FILES))

44 45
CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
46

47 48
all: $(FILES)

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

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

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

57
$(OUTPUT)test-hello.bin:
58 59
	$(BUILD)

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

63
$(OUTPUT)test-stackprotector-all.bin:
64
	$(BUILD) -fstack-protector-all
65

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

69
$(OUTPUT)test-bionic.bin:
70 71
	$(BUILD)

72
$(OUTPUT)test-libelf.bin:
73 74
	$(BUILD) -lelf

75
$(OUTPUT)test-glibc.bin:
76 77
	$(BUILD)

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

83
$(OUTPUT)test-dwarf.bin:
84
	$(BUILD) $(DWARFLIBS)
85

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

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

92
$(OUTPUT)test-libelf-getphdrnum.bin:
93 94
	$(BUILD) -lelf

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

98
$(OUTPUT)test-numa_num_possible_cpus.bin:
99 100
	$(BUILD) -lnuma

101
$(OUTPUT)test-libunwind.bin:
102
	$(BUILD) -lelf
103

104
$(OUTPUT)test-libunwind-debug-frame.bin:
105
	$(BUILD) -lelf
106

107
$(OUTPUT)test-libaudit.bin:
108 109
	$(BUILD) -laudit

110
$(OUTPUT)test-libslang.bin:
111 112
	$(BUILD) -I/usr/include/slang -lslang

113 114 115
$(OUTPUT)test-libcrypto.bin:
	$(BUILD) -lcrypto

116
$(OUTPUT)test-gtk2.bin:
117
	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
118

119
$(OUTPUT)test-gtk2-infobar.bin:
120
	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
121

122 123 124 125 126 127 128 129 130
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)

131
$(OUTPUT)test-libperl.bin:
132 133
	$(BUILD) $(FLAGS_PERL_EMBED)

134
$(OUTPUT)test-libpython.bin:
135
	$(BUILD)
136

137
$(OUTPUT)test-libpython-version.bin:
138
	$(BUILD)
139

140
$(OUTPUT)test-libbfd.bin:
141
	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
142

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

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

149
$(OUTPUT)test-cplus-demangle.bin:
150 151
	$(BUILD) -liberty

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

155
$(OUTPUT)test-timerfd.bin:
156 157
	$(BUILD)

158
$(OUTPUT)test-libdw-dwarf-unwind.bin:
159 160
	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

161
$(OUTPUT)test-libbabeltrace.bin:
162
	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
163

164
$(OUTPUT)test-sync-compare-and-swap.bin:
165
	$(BUILD)
166

167 168
$(OUTPUT)test-compile-32.bin:
	$(CC) -m32 -o $@ test-compile.c
169

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

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

176
$(OUTPUT)test-lzma.bin:
177 178
	$(BUILD) -llzma

179
$(OUTPUT)test-get_cpuid.bin:
180 181
	$(BUILD)

182
$(OUTPUT)test-bpf.bin:
183 184
	$(BUILD)

185
-include $(OUTPUT)*.d
186

187 188 189
###############################

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