Makefile 3.3 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 29
	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	\
	test-timerfd.bin
30

31 32
CC := $(CC) -MD

33 34
all: $(FILES)

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

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

39
test-all.bin:
40
	$(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
41

42
test-hello.bin:
43 44
	$(BUILD)

45
test-stackprotector-all.bin:
46 47
	$(BUILD) -Werror -fstack-protector-all

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

51
test-bionic.bin:
52 53
	$(BUILD)

54
test-libelf.bin:
55 56
	$(BUILD) -lelf

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

60
test-dwarf.bin:
61 62
	$(BUILD) -ldw

63
test-libelf-mmap.bin:
64 65
	$(BUILD) -lelf

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

69
test-libnuma.bin:
70 71
	$(BUILD) -lnuma

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

75
test-libunwind-debug-frame.bin:
76
	$(BUILD) -lelf
77

78
test-libaudit.bin:
79 80
	$(BUILD) -laudit

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

84
test-gtk2.bin:
85 86
	$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)

87
test-gtk2-infobar.bin:
88 89
	$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)

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

99
test-libperl.bin:
100 101
	$(BUILD) $(FLAGS_PERL_EMBED)

102 103 104 105 106 107 108 109 110 111 112 113 114 115
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)

116
test-libpython.bin:
117 118
	$(BUILD) $(FLAGS_PYTHON_EMBED)

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

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

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

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

131
test-cplus-demangle.bin:
132 133
	$(BUILD) -liberty

134
test-on-exit.bin:
135 136
	$(BUILD)

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

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

143
-include *.d
144

145 146 147
###############################

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