Makefile 3.3 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-on-exit			\
27 28 29
	test-stackprotector-all		\
	test-stackprotector		\
	test-volatile-register-var
30

31 32
CC := $(CC) -MD

33 34
all: $(FILES)

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

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

39 40 41
test-all:
	$(BUILD) -Werror -fstack-protector -fstack-protector-all -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -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' -DPACKAGE=perf -lbfd -ldl

42
test-hello:
43 44
	$(BUILD)

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

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

51 52 53
test-volatile-register-var:
	$(BUILD) -Werror -Wvolatile-register-var

54 55 56
test-fortify-source:
	$(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2

57 58 59
test-bionic:
	$(BUILD)

60 61 62
test-libelf:
	$(BUILD) -lelf

63 64 65
test-glibc:
	$(BUILD)

66 67 68
test-dwarf:
	$(BUILD) -ldw

69 70 71
test-libelf-mmap:
	$(BUILD) -lelf

72 73 74
test-libelf-getphdrnum:
	$(BUILD) -lelf

75 76 77
test-libnuma:
	$(BUILD) -lnuma

78 79 80
test-libunwind:
	$(BUILD) -lunwind -lunwind-x86_64 -lelf

81 82 83
test-libaudit:
	$(BUILD) -laudit

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

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

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

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

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

122 123 124
test-libpython-version:
	$(BUILD) $(FLAGS_PYTHON_EMBED)

125 126 127
test-libbfd:
	$(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl

128 129 130 131 132 133 134 135 136
test-liberty:
	$(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl -liberty

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

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

137 138 139
test-on-exit:
	$(BUILD)

140 141 142
test-backtrace:
	$(BUILD)

143 144
-include *.d */*.d

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

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