Makefile 3.2 KB
Newer Older
1

2
FILES=					\
3 4
	test-all			\
	test-backtrace			\
5
	test-bionic			\
6
	test-dwarf			\
7 8
	test-fortify-source		\
	test-glibc			\
9
	test-gtk2			\
10
	test-gtk2-infobar		\
11 12 13
	test-hello			\
	test-libaudit			\
	test-libbfd			\
14 15 16
	test-liberty			\
	test-liberty-z			\
	test-cplus-demangle		\
17 18 19 20
	test-libelf			\
	test-libelf-getphdrnum		\
	test-libelf-mmap		\
	test-libnuma			\
21
	test-libperl			\
22
	test-libpython			\
23
	test-libpython-version		\
24 25
	test-libslang			\
	test-libunwind			\
26
	test-libunwind-debug-frame	\
27
	test-on-exit			\
28
	test-stackprotector-all		\
29 30
	test-stackprotector		\
	test-timerfd
31

32 33
CC := $(CC) -MD

34 35
all: $(FILES)

A
Adrian Hunter 已提交
36
BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
37 38 39

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

40
test-all:
41
	$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -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
42

43
test-hello:
44 45
	$(BUILD)

46 47 48
test-stackprotector-all:
	$(BUILD) -Werror -fstack-protector-all

49
test-stackprotector:
50
	$(BUILD) -Werror -fstack-protector -Wstack-protector
51

52 53 54
test-fortify-source:
	$(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2

55 56 57
test-bionic:
	$(BUILD)

58 59 60
test-libelf:
	$(BUILD) -lelf

61 62 63
test-glibc:
	$(BUILD)

64 65 66
test-dwarf:
	$(BUILD) -ldw

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

70 71 72
test-libelf-getphdrnum:
	$(BUILD) -lelf

73 74 75
test-libnuma:
	$(BUILD) -lnuma

76
test-libunwind:
77
	$(BUILD) $(LIBUNWIND_LIBS) -lelf
78

79 80 81
test-libaudit:
	$(BUILD) -laudit

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

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

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

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

test-libperl:
	$(BUILD) $(FLAGS_PERL_EMBED)

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

test-libpython:
	$(BUILD) $(FLAGS_PYTHON_EMBED)

120 121 122
test-libpython-version:
	$(BUILD) $(FLAGS_PYTHON_EMBED)

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

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

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

test-cplus-demangle:
	$(BUILD) -liberty

135 136 137
test-on-exit:
	$(BUILD)

138 139 140
test-backtrace:
	$(BUILD)

141 142 143
test-timerfd:
	$(BUILD)

144
-include *.d
145

146 147 148
###############################

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