Makefile 3.1 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
	test-timerfd
30

31 32
CC := $(CC) -MD

33 34
all: $(FILES)

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

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

39
test-all:
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:
43 44
	$(BUILD)

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

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

51 52 53
test-bionic:
	$(BUILD)

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

57 58 59
test-glibc:
	$(BUILD)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

137 138 139
test-backtrace:
	$(BUILD)

140 141 142
test-timerfd:
	$(BUILD)

143
-include *.d
144

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

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