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-on-exit			\
27
	test-stackprotector-all		\
28
	test-stackprotector
29

30 31
CC := $(CC) -MD

32 33
all: $(FILES)

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

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

38
test-all:
39
	$(BUILD) -Werror -fstack-protector -fstack-protector-all -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"' -lbfd -ldl
40

41
test-hello:
42 43
	$(BUILD)

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

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

50 51 52
test-fortify-source:
	$(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2

53 54 55
test-bionic:
	$(BUILD)

56 57 58
test-libelf:
	$(BUILD) -lelf

59 60 61
test-glibc:
	$(BUILD)

62 63 64
test-dwarf:
	$(BUILD) -ldw

65 66 67
test-libelf-mmap:
	$(BUILD) -lelf

68 69 70
test-libelf-getphdrnum:
	$(BUILD) -lelf

71 72 73
test-libnuma:
	$(BUILD) -lnuma

74 75 76
test-libunwind:
	$(BUILD) -lunwind -lunwind-x86_64 -lelf

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

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

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

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

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

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

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

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

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

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

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

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

136 137 138
test-backtrace:
	$(BUILD)

139 140
-include *.d */*.d

141 142 143
###############################

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