]>
Commit | Line | Data |
---|---|---|
8bd407b9 JO |
1 | uname_M := $(shell uname -m 2>/dev/null || echo not) |
2 | ||
3 | ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ | |
4 | -e s/arm.*/arm/ -e s/sa110/arm/ \ | |
5 | -e s/s390x/s390/ -e s/parisc64/parisc/ \ | |
6 | -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ | |
7 | -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) | |
8 | NO_PERF_REGS := 1 | |
9 | ||
10 | # Additional ARCH settings for x86 | |
11 | ifeq ($(ARCH),i386) | |
12 | override ARCH := x86 | |
13 | NO_PERF_REGS := 0 | |
14 | LIBUNWIND_LIBS = -lunwind -lunwind-x86 | |
15 | endif | |
16 | ||
17 | ifeq ($(ARCH),x86_64) | |
18 | override ARCH := x86 | |
19 | IS_X86_64 := 0 | |
20 | ifeq (, $(findstring m32,$(EXTRA_CFLAGS))) | |
21 | IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1) | |
22 | endif | |
23 | ifeq (${IS_X86_64}, 1) | |
24 | RAW_ARCH := x86_64 | |
25 | ARCH_CFLAGS := -DARCH_X86_64 | |
26 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S | |
27 | endif | |
28 | NO_PERF_REGS := 0 | |
29 | LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 | |
30 | endif | |
31 | ||
32 | ifeq ($(NO_PERF_REGS),0) | |
33 | BASIC_CFLAGS += -DHAVE_PERF_REGS | |
34 | endif | |
a32f4936 JO |
35 | |
36 | -include config/feature-tests.mak | |
37 | ||
38 | ifeq ($(call get-executable,$(FLEX)),) | |
39 | dummy := $(error Error: $(FLEX) is missing on this system, please install it) | |
40 | endif | |
41 | ||
42 | ifeq ($(call get-executable,$(BISON)),) | |
43 | dummy := $(error Error: $(BISON) is missing on this system, please install it) | |
44 | endif | |
362493f0 JO |
45 | |
46 | # Treat warnings as errors unless directed not to | |
47 | ifneq ($(WERROR),0) | |
48 | CFLAGS_WERROR := -Werror | |
49 | endif | |
50 | ||
51 | ifeq ("$(origin DEBUG)", "command line") | |
52 | PERF_DEBUG = $(DEBUG) | |
53 | endif | |
54 | ifndef PERF_DEBUG | |
55 | CFLAGS_OPTIMIZE = -O6 | |
56 | endif | |
57 | ||
58 | ifdef PARSER_DEBUG | |
59 | PARSER_DEBUG_BISON := -t | |
60 | PARSER_DEBUG_FLEX := -d | |
61 | PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG | |
62 | endif | |
63 | ||
64 | CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) | |
65 | EXTLIBS = -lpthread -lrt -lelf -lm | |
66 | ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE | |
67 | ALL_LDFLAGS = $(LDFLAGS) | |
68 | ||
69 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) | |
70 | CFLAGS := $(CFLAGS) -fstack-protector-all | |
71 | endif | |
72 | ||
73 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) | |
74 | CFLAGS := $(CFLAGS) -Wstack-protector | |
75 | endif | |
76 | ||
77 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) | |
78 | CFLAGS := $(CFLAGS) -Wvolatile-register-var | |
79 | endif | |
80 | ||
81 | ifndef PERF_DEBUG | |
82 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) | |
83 | CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2 | |
84 | endif | |
85 | endif | |
86 | ||
87 | BASIC_CFLAGS += \ | |
88 | -Iutil/include \ | |
89 | -Iarch/$(ARCH)/include \ | |
90 | $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \ | |
91 | -I$(srctree)/arch/$(ARCH)/include/uapi \ | |
92 | -I$(srctree)/arch/$(ARCH)/include \ | |
93 | $(if $(objtree),-I$(objtree)/include/generated/uapi) \ | |
94 | -I$(srctree)/include/uapi \ | |
95 | -I$(srctree)/include \ | |
96 | -I$(OUTPUT)util \ | |
97 | -Iutil \ | |
98 | -I. \ | |
99 | -I$(TRACE_EVENT_DIR) \ | |
100 | -I../lib/ \ | |
101 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE | |
102 | ||
103 | BASIC_LDFLAGS = | |
104 | ||
105 | ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) | |
106 | BIONIC := 1 | |
107 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) | |
108 | EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) | |
109 | BASIC_CFLAGS += -I. | |
110 | endif | |
cf4cca10 JO |
111 | |
112 | ifdef NO_LIBELF | |
113 | NO_DWARF := 1 | |
114 | NO_DEMANGLE := 1 | |
115 | NO_LIBUNWIND := 1 | |
116 | else | |
117 | FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) | |
118 | ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) | |
119 | FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS) | |
120 | ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) | |
121 | LIBC_SUPPORT := 1 | |
122 | endif | |
123 | ifeq ($(BIONIC),1) | |
124 | LIBC_SUPPORT := 1 | |
125 | endif | |
126 | ifeq ($(LIBC_SUPPORT),1) | |
127 | msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); | |
128 | ||
129 | NO_LIBELF := 1 | |
130 | NO_DWARF := 1 | |
131 | NO_DEMANGLE := 1 | |
132 | else | |
133 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); | |
134 | endif | |
135 | else | |
136 | # for linking with debug library, run like: | |
137 | # make DEBUG=1 LIBDW_DIR=/opt/libdw/ | |
138 | ifdef LIBDW_DIR | |
139 | LIBDW_CFLAGS := -I$(LIBDW_DIR)/include | |
140 | LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib | |
141 | endif | |
142 | ||
143 | FLAGS_DWARF=$(ALL_CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) | |
144 | ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) | |
145 | msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); | |
146 | NO_DWARF := 1 | |
147 | endif # Dwarf support | |
148 | endif # SOURCE_LIBELF | |
149 | endif # NO_LIBELF | |
150 | ||
151 | ifndef NO_LIBELF | |
152 | BASIC_CFLAGS += -DLIBELF_SUPPORT | |
153 | FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) | |
154 | ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) | |
155 | BASIC_CFLAGS += -DLIBELF_MMAP | |
156 | endif | |
779724fd JO |
157 | |
158 | # include ARCH specific config | |
159 | -include arch/$(ARCH)/Makefile | |
160 | ||
161 | ifndef NO_DWARF | |
162 | ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) | |
163 | msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); | |
164 | NO_DWARF := 1 | |
165 | else | |
166 | BASIC_CFLAGS := -DDWARF_SUPPORT $(LIBDW_CFLAGS) $(BASIC_CFLAGS) | |
167 | BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS) | |
168 | EXTLIBS += -lelf -ldw | |
169 | endif # PERF_HAVE_DWARF_REGS | |
170 | endif # NO_DWARF | |
171 | ||
cf4cca10 | 172 | endif # NO_LIBELF |
0e433feb JO |
173 | |
174 | # There's only x86 (both 32 and 64) support for CFI unwind so far | |
175 | ifneq ($(ARCH),x86) | |
176 | NO_LIBUNWIND := 1 | |
177 | endif | |
178 | ||
179 | ifndef NO_LIBUNWIND | |
180 | # for linking with debug library, run like: | |
181 | # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ | |
182 | ifdef LIBUNWIND_DIR | |
183 | LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include | |
184 | LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib | |
185 | endif | |
186 | ||
187 | FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(ALL_CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) | |
188 | ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) | |
189 | msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); | |
190 | NO_LIBUNWIND := 1 | |
191 | endif # Libunwind support | |
192 | endif # NO_LIBUNWIND | |
193 | ||
194 | ifndef NO_LIBUNWIND | |
195 | BASIC_CFLAGS += -DLIBUNWIND_SUPPORT | |
196 | EXTLIBS += $(LIBUNWIND_LIBS) | |
197 | BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS) | |
198 | BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS) | |
199 | endif # NO_LIBUNWIND |