Makefile 2.6 KB
Newer Older
1

2 3
FILES=					\
	test-hello			\
4
	test-stackprotector-all		\
5
	test-stackprotector		\
6
	test-volatile-register-var	\
7
	test-fortify-source		\
8
	test-bionic			\
9
	test-libelf			\
10
	test-glibc			\
11
	test-dwarf			\
12
	test-libelf-mmap		\
13
	test-libelf-getphdrnum		\
14
	test-libunwind			\
15
	test-libaudit			\
16
	test-libslang			\
17
	test-gtk2			\
18
	test-gtk2-infobar		\
19
	test-libperl			\
20
	test-libpython			\
21
	test-libpython-version		\
22
	test-strlcpy			\
23
	test-libbfd			\
24
	test-libnuma
25

26 27
CC := $(CC) -MD

28 29 30 31 32 33
all: $(FILES)

BUILD = $(CC) -o $(OUTPUT)$@ $@.c

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

34
test-hello:
35 36
	$(BUILD)

37 38 39
test-stackprotector-all:
	$(BUILD) -Werror -fstack-protector-all

40 41 42
test-stackprotector:
	$(BUILD) -Werror -fstack-protector

43 44 45
test-volatile-register-var:
	$(BUILD) -Werror -Wvolatile-register-var

46 47 48
test-fortify-source:
	$(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2

49 50 51
test-bionic:
	$(BUILD)

52 53 54
test-libelf:
	$(BUILD) -lelf

55 56 57
test-glibc:
	$(BUILD)

58 59 60
test-dwarf:
	$(BUILD) -ldw

61 62 63
test-libelf-mmap:
	$(BUILD) -lelf

64 65 66
test-libelf-getphdrnum:
	$(BUILD) -lelf

67 68 69
test-libnuma:
	$(BUILD) -lnuma

70 71 72
test-libunwind:
	$(BUILD) -lunwind -lunwind-x86_64 -lelf

73 74 75
test-libaudit:
	$(BUILD) -laudit

76 77 78
test-libslang:
	$(BUILD) -I/usr/include/slang -lslang

79 80 81
test-gtk2:
	$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)

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

85 86 87 88 89 90 91 92 93 94 95 96
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)

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
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)

114 115 116
test-libpython-version:
	$(BUILD) $(FLAGS_PYTHON_EMBED)

117 118 119
test-strlcpy:
	$(BUILD)

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

123 124
-include *.d */*.d

125 126 127
###############################

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