Jiri Olsa | 8bd407b | 2013-03-15 16:28:49 +0100 | [diff] [blame] | 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 |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 9 | CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) |
Jiri Olsa | 8bd407b | 2013-03-15 16:28:49 +0100 | [diff] [blame] | 10 | |
| 11 | # Additional ARCH settings for x86 |
| 12 | ifeq ($(ARCH),i386) |
| 13 | override ARCH := x86 |
| 14 | NO_PERF_REGS := 0 |
| 15 | LIBUNWIND_LIBS = -lunwind -lunwind-x86 |
| 16 | endif |
| 17 | |
| 18 | ifeq ($(ARCH),x86_64) |
| 19 | override ARCH := x86 |
| 20 | IS_X86_64 := 0 |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 21 | ifeq (, $(findstring m32,$(CFLAGS))) |
Jiri Olsa | 8bd407b | 2013-03-15 16:28:49 +0100 | [diff] [blame] | 22 | IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1) |
| 23 | endif |
| 24 | ifeq (${IS_X86_64}, 1) |
| 25 | RAW_ARCH := x86_64 |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 26 | CFLAGS += -DARCH_X86_64 |
Jiri Olsa | 8bd407b | 2013-03-15 16:28:49 +0100 | [diff] [blame] | 27 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S |
| 28 | endif |
| 29 | NO_PERF_REGS := 0 |
| 30 | LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 |
| 31 | endif |
| 32 | |
| 33 | ifeq ($(NO_PERF_REGS),0) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 34 | CFLAGS += -DHAVE_PERF_REGS |
Jiri Olsa | 8bd407b | 2013-03-15 16:28:49 +0100 | [diff] [blame] | 35 | endif |
Jiri Olsa | a32f493 | 2013-03-25 00:32:01 +0100 | [diff] [blame] | 36 | |
| 37 | -include config/feature-tests.mak |
| 38 | |
| 39 | ifeq ($(call get-executable,$(FLEX)),) |
| 40 | dummy := $(error Error: $(FLEX) is missing on this system, please install it) |
| 41 | endif |
| 42 | |
| 43 | ifeq ($(call get-executable,$(BISON)),) |
| 44 | dummy := $(error Error: $(BISON) is missing on this system, please install it) |
| 45 | endif |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 46 | |
| 47 | # Treat warnings as errors unless directed not to |
| 48 | ifneq ($(WERROR),0) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 49 | CFLAGS += -Werror |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 50 | endif |
| 51 | |
| 52 | ifeq ("$(origin DEBUG)", "command line") |
| 53 | PERF_DEBUG = $(DEBUG) |
| 54 | endif |
| 55 | ifndef PERF_DEBUG |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 56 | CFLAGS += -O6 |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 57 | endif |
| 58 | |
| 59 | ifdef PARSER_DEBUG |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 60 | PARSER_DEBUG_BISON := -t |
| 61 | PARSER_DEBUG_FLEX := -d |
| 62 | CFLAGS += -DPARSER_DEBUG |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 63 | endif |
| 64 | |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 65 | CFLAGS += \ |
| 66 | -fno-omit-frame-pointer \ |
| 67 | -ggdb3 \ |
| 68 | -funwind-tables \ |
| 69 | -Wall \ |
| 70 | -Wextra \ |
| 71 | -std=gnu99 |
| 72 | |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 73 | EXTLIBS = -lpthread -lrt -lelf -lm |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 74 | ALL_LDFLAGS = $(LDFLAGS) |
| 75 | |
| 76 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 77 | CFLAGS += -fstack-protector-all |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 78 | endif |
| 79 | |
| 80 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 81 | CFLAGS += -Wstack-protector |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 82 | endif |
| 83 | |
| 84 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 85 | CFLAGS += -Wvolatile-register-var |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 86 | endif |
| 87 | |
| 88 | ifndef PERF_DEBUG |
| 89 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 90 | CFLAGS += -D_FORTIFY_SOURCE=2 |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 91 | endif |
| 92 | endif |
| 93 | |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 94 | CFLAGS += \ |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 95 | -Iutil/include \ |
| 96 | -Iarch/$(ARCH)/include \ |
| 97 | $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \ |
| 98 | -I$(srctree)/arch/$(ARCH)/include/uapi \ |
| 99 | -I$(srctree)/arch/$(ARCH)/include \ |
| 100 | $(if $(objtree),-I$(objtree)/include/generated/uapi) \ |
| 101 | -I$(srctree)/include/uapi \ |
| 102 | -I$(srctree)/include \ |
| 103 | -I$(OUTPUT)util \ |
| 104 | -Iutil \ |
| 105 | -I. \ |
| 106 | -I$(TRACE_EVENT_DIR) \ |
| 107 | -I../lib/ \ |
| 108 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE |
| 109 | |
| 110 | BASIC_LDFLAGS = |
| 111 | |
| 112 | ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) |
| 113 | BIONIC := 1 |
| 114 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) |
| 115 | EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) |
Jiri Olsa | 362493f | 2013-03-25 00:40:48 +0100 | [diff] [blame] | 116 | endif |
Jiri Olsa | cf4cca1 | 2013-03-25 00:45:08 +0100 | [diff] [blame] | 117 | |
| 118 | ifdef NO_LIBELF |
| 119 | NO_DWARF := 1 |
| 120 | NO_DEMANGLE := 1 |
| 121 | NO_LIBUNWIND := 1 |
| 122 | else |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 123 | FLAGS_LIBELF=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) |
Jiri Olsa | cf4cca1 | 2013-03-25 00:45:08 +0100 | [diff] [blame] | 124 | ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 125 | FLAGS_GLIBC=$(CFLAGS) $(ALL_LDFLAGS) |
Jiri Olsa | cf4cca1 | 2013-03-25 00:45:08 +0100 | [diff] [blame] | 126 | ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) |
| 127 | LIBC_SUPPORT := 1 |
| 128 | endif |
| 129 | ifeq ($(BIONIC),1) |
| 130 | LIBC_SUPPORT := 1 |
| 131 | endif |
| 132 | ifeq ($(LIBC_SUPPORT),1) |
| 133 | msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); |
| 134 | |
| 135 | NO_LIBELF := 1 |
| 136 | NO_DWARF := 1 |
| 137 | NO_DEMANGLE := 1 |
| 138 | else |
| 139 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); |
| 140 | endif |
| 141 | else |
| 142 | # for linking with debug library, run like: |
| 143 | # make DEBUG=1 LIBDW_DIR=/opt/libdw/ |
| 144 | ifdef LIBDW_DIR |
| 145 | LIBDW_CFLAGS := -I$(LIBDW_DIR)/include |
| 146 | LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib |
| 147 | endif |
| 148 | |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 149 | FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) |
Jiri Olsa | cf4cca1 | 2013-03-25 00:45:08 +0100 | [diff] [blame] | 150 | ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) |
| 151 | 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); |
| 152 | NO_DWARF := 1 |
| 153 | endif # Dwarf support |
| 154 | endif # SOURCE_LIBELF |
| 155 | endif # NO_LIBELF |
| 156 | |
| 157 | ifndef NO_LIBELF |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 158 | CFLAGS += -DLIBELF_SUPPORT |
| 159 | FLAGS_LIBELF=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) |
Jiri Olsa | cf4cca1 | 2013-03-25 00:45:08 +0100 | [diff] [blame] | 160 | ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 161 | CFLAGS += -DLIBELF_MMAP |
Jiri Olsa | cf4cca1 | 2013-03-25 00:45:08 +0100 | [diff] [blame] | 162 | endif |
Jiri Olsa | 779724f | 2013-03-25 00:48:14 +0100 | [diff] [blame] | 163 | |
| 164 | # include ARCH specific config |
| 165 | -include arch/$(ARCH)/Makefile |
| 166 | |
| 167 | ifndef NO_DWARF |
| 168 | ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) |
| 169 | msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); |
| 170 | NO_DWARF := 1 |
| 171 | else |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 172 | CFLAGS += -DDWARF_SUPPORT $(LIBDW_CFLAGS) |
Jiri Olsa | 779724f | 2013-03-25 00:48:14 +0100 | [diff] [blame] | 173 | BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS) |
| 174 | EXTLIBS += -lelf -ldw |
| 175 | endif # PERF_HAVE_DWARF_REGS |
| 176 | endif # NO_DWARF |
| 177 | |
Jiri Olsa | cf4cca1 | 2013-03-25 00:45:08 +0100 | [diff] [blame] | 178 | endif # NO_LIBELF |
Jiri Olsa | 0e433fe | 2013-03-25 00:53:03 +0100 | [diff] [blame] | 179 | |
| 180 | # There's only x86 (both 32 and 64) support for CFI unwind so far |
| 181 | ifneq ($(ARCH),x86) |
| 182 | NO_LIBUNWIND := 1 |
| 183 | endif |
| 184 | |
| 185 | ifndef NO_LIBUNWIND |
| 186 | # for linking with debug library, run like: |
| 187 | # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ |
| 188 | ifdef LIBUNWIND_DIR |
| 189 | LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include |
| 190 | LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib |
| 191 | endif |
| 192 | |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 193 | FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) |
Jiri Olsa | 0e433fe | 2013-03-25 00:53:03 +0100 | [diff] [blame] | 194 | ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) |
| 195 | msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); |
| 196 | NO_LIBUNWIND := 1 |
| 197 | endif # Libunwind support |
| 198 | endif # NO_LIBUNWIND |
| 199 | |
| 200 | ifndef NO_LIBUNWIND |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 201 | CFLAGS += -DLIBUNWIND_SUPPORT |
Jiri Olsa | 0e433fe | 2013-03-25 00:53:03 +0100 | [diff] [blame] | 202 | EXTLIBS += $(LIBUNWIND_LIBS) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 203 | CFLAGS += $(LIBUNWIND_CFLAGS) |
Jiri Olsa | 0e433fe | 2013-03-25 00:53:03 +0100 | [diff] [blame] | 204 | BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS) |
| 205 | endif # NO_LIBUNWIND |
Jiri Olsa | a827952 | 2013-03-25 00:54:36 +0100 | [diff] [blame] | 206 | |
| 207 | ifndef NO_LIBAUDIT |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 208 | FLAGS_LIBAUDIT = $(CFLAGS) $(ALL_LDFLAGS) -laudit |
Jiri Olsa | a827952 | 2013-03-25 00:54:36 +0100 | [diff] [blame] | 209 | ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y) |
| 210 | msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); |
| 211 | NO_LIBAUDIT := 1 |
| 212 | else |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 213 | CFLAGS += -DLIBAUDIT_SUPPORT |
Jiri Olsa | a827952 | 2013-03-25 00:54:36 +0100 | [diff] [blame] | 214 | EXTLIBS += -laudit |
| 215 | endif |
| 216 | endif |
Jiri Olsa | 4a8f888 | 2013-03-25 00:56:08 +0100 | [diff] [blame] | 217 | |
| 218 | ifdef NO_NEWT |
| 219 | NO_SLANG=1 |
| 220 | endif |
| 221 | |
| 222 | ifndef NO_SLANG |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 223 | FLAGS_SLANG=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang |
Jiri Olsa | 4a8f888 | 2013-03-25 00:56:08 +0100 | [diff] [blame] | 224 | ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y) |
| 225 | msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); |
| 226 | NO_SLANG := 1 |
| 227 | else |
| 228 | # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 229 | CFLAGS += -I/usr/include/slang |
| 230 | CFLAGS += -DSLANG_SUPPORT |
Jiri Olsa | 4a8f888 | 2013-03-25 00:56:08 +0100 | [diff] [blame] | 231 | EXTLIBS += -lslang |
| 232 | endif |
| 233 | endif |
Jiri Olsa | 58cabf6 | 2013-03-18 00:09:24 +0100 | [diff] [blame] | 234 | |
| 235 | ifndef NO_GTK2 |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 236 | FLAGS_GTK2=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) |
Jiri Olsa | 58cabf6 | 2013-03-18 00:09:24 +0100 | [diff] [blame] | 237 | ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y) |
| 238 | msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); |
| 239 | NO_GTK2 := 1 |
| 240 | else |
| 241 | ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 242 | CFLAGS += -DHAVE_GTK_INFO_BAR |
Jiri Olsa | 58cabf6 | 2013-03-18 00:09:24 +0100 | [diff] [blame] | 243 | endif |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 244 | CFLAGS += -DGTK2_SUPPORT |
| 245 | CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) |
Jiri Olsa | 58cabf6 | 2013-03-18 00:09:24 +0100 | [diff] [blame] | 246 | EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null) |
| 247 | endif |
| 248 | endif |
Jiri Olsa | 3082cb3 | 2013-03-18 00:19:44 +0100 | [diff] [blame] | 249 | |
| 250 | grep-libs = $(filter -l%,$(1)) |
| 251 | strip-libs = $(filter-out -l%,$(1)) |
| 252 | |
| 253 | ifdef NO_LIBPERL |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 254 | CFLAGS += -DNO_LIBPERL |
Jiri Olsa | 3082cb3 | 2013-03-18 00:19:44 +0100 | [diff] [blame] | 255 | else |
| 256 | PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) |
| 257 | PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) |
| 258 | PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) |
| 259 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` |
| 260 | FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) |
| 261 | |
| 262 | ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 263 | CFLAGS += -DNO_LIBPERL |
Jiri Olsa | 3082cb3 | 2013-03-18 00:19:44 +0100 | [diff] [blame] | 264 | NO_LIBPERL := 1 |
| 265 | else |
| 266 | ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS) |
| 267 | EXTLIBS += $(PERL_EMBED_LIBADD) |
| 268 | endif |
| 269 | endif |
Jiri Olsa | 6e533cf | 2013-03-18 00:35:32 +0100 | [diff] [blame] | 270 | |
| 271 | disable-python = $(eval $(disable-python_code)) |
| 272 | define disable-python_code |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 273 | CFLAGS += -DNO_LIBPYTHON |
Jiri Olsa | 6e533cf | 2013-03-18 00:35:32 +0100 | [diff] [blame] | 274 | $(if $(1),$(warning No $(1) was found)) |
| 275 | $(warning Python support will not be built) |
| 276 | NO_LIBPYTHON := 1 |
| 277 | endef |
| 278 | |
| 279 | override PYTHON := \ |
| 280 | $(call get-executable-or-default,PYTHON,python) |
| 281 | |
| 282 | ifndef PYTHON |
| 283 | $(call disable-python,python interpreter) |
| 284 | else |
| 285 | |
| 286 | PYTHON_WORD := $(call shell-wordify,$(PYTHON)) |
| 287 | |
| 288 | ifdef NO_LIBPYTHON |
| 289 | $(call disable-python) |
| 290 | else |
| 291 | |
| 292 | override PYTHON_CONFIG := \ |
| 293 | $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config) |
| 294 | |
| 295 | ifndef PYTHON_CONFIG |
| 296 | $(call disable-python,python-config tool) |
| 297 | else |
| 298 | |
| 299 | PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) |
| 300 | |
| 301 | PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) |
| 302 | PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) |
| 303 | PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) |
| 304 | PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) |
| 305 | FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) |
| 306 | |
| 307 | ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y) |
| 308 | $(call disable-python,Python.h (for Python 2.x)) |
| 309 | else |
| 310 | |
| 311 | ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y) |
| 312 | $(warning Python 3 is not yet supported; please set) |
| 313 | $(warning PYTHON and/or PYTHON_CONFIG appropriately.) |
| 314 | $(warning If you also have Python 2 installed, then) |
| 315 | $(warning try something like:) |
| 316 | $(warning $(and ,)) |
| 317 | $(warning $(and ,) make PYTHON=python2) |
| 318 | $(warning $(and ,)) |
| 319 | $(warning Otherwise, disable Python support entirely:) |
| 320 | $(warning $(and ,)) |
| 321 | $(warning $(and ,) make NO_LIBPYTHON=1) |
| 322 | $(warning $(and ,)) |
| 323 | $(error $(and ,)) |
| 324 | else |
| 325 | ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS) |
| 326 | EXTLIBS += $(PYTHON_EMBED_LIBADD) |
| 327 | LANG_BINDINGS += $(OUTPUT)python/perf.so |
| 328 | endif |
| 329 | endif |
| 330 | endif |
| 331 | endif |
| 332 | endif |
Jiri Olsa | c3cf836 | 2013-03-18 00:38:16 +0100 | [diff] [blame] | 333 | |
| 334 | ifdef NO_DEMANGLE |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 335 | CFLAGS += -DNO_DEMANGLE |
Jiri Olsa | c3cf836 | 2013-03-18 00:38:16 +0100 | [diff] [blame] | 336 | else |
| 337 | ifdef HAVE_CPLUS_DEMANGLE |
| 338 | EXTLIBS += -liberty |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 339 | CFLAGS += -DHAVE_CPLUS_DEMANGLE |
Jiri Olsa | c3cf836 | 2013-03-18 00:38:16 +0100 | [diff] [blame] | 340 | else |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 341 | FLAGS_BFD=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd |
Jiri Olsa | c3cf836 | 2013-03-18 00:38:16 +0100 | [diff] [blame] | 342 | has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd) |
| 343 | ifeq ($(has_bfd),y) |
| 344 | EXTLIBS += -lbfd |
| 345 | else |
| 346 | FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty |
| 347 | has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty) |
| 348 | ifeq ($(has_bfd_iberty),y) |
| 349 | EXTLIBS += -lbfd -liberty |
| 350 | else |
| 351 | FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz |
| 352 | has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz) |
| 353 | ifeq ($(has_bfd_iberty_z),y) |
| 354 | EXTLIBS += -lbfd -liberty -lz |
| 355 | else |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 356 | FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty |
Jiri Olsa | c3cf836 | 2013-03-18 00:38:16 +0100 | [diff] [blame] | 357 | has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle) |
| 358 | ifeq ($(has_cplus_demangle),y) |
| 359 | EXTLIBS += -liberty |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 360 | CFLAGS += -DHAVE_CPLUS_DEMANGLE |
Jiri Olsa | c3cf836 | 2013-03-18 00:38:16 +0100 | [diff] [blame] | 361 | else |
| 362 | msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 363 | CFLAGS += -DNO_DEMANGLE |
Jiri Olsa | c3cf836 | 2013-03-18 00:38:16 +0100 | [diff] [blame] | 364 | endif |
| 365 | endif |
| 366 | endif |
| 367 | endif |
| 368 | endif |
| 369 | endif |
Jiri Olsa | a1c7c9e | 2013-03-18 00:41:04 +0100 | [diff] [blame] | 370 | |
| 371 | ifndef NO_STRLCPY |
| 372 | ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 373 | CFLAGS += -DHAVE_STRLCPY |
Jiri Olsa | a1c7c9e | 2013-03-18 00:41:04 +0100 | [diff] [blame] | 374 | endif |
| 375 | endif |
| 376 | |
| 377 | ifndef NO_ON_EXIT |
| 378 | ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 379 | CFLAGS += -DHAVE_ON_EXIT |
Jiri Olsa | a1c7c9e | 2013-03-18 00:41:04 +0100 | [diff] [blame] | 380 | endif |
| 381 | endif |
| 382 | |
| 383 | ifndef NO_BACKTRACE |
| 384 | ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y) |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 385 | CFLAGS += -DBACKTRACE_SUPPORT |
Jiri Olsa | a1c7c9e | 2013-03-18 00:41:04 +0100 | [diff] [blame] | 386 | endif |
| 387 | endif |
Jiri Olsa | 58a0abd | 2013-03-18 00:45:27 +0100 | [diff] [blame] | 388 | |
| 389 | ifndef NO_LIBNUMA |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 390 | FLAGS_LIBNUMA = $(CFLAGS) $(ALL_LDFLAGS) -lnuma |
Jiri Olsa | 58a0abd | 2013-03-18 00:45:27 +0100 | [diff] [blame] | 391 | ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y) |
| 392 | msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev); |
| 393 | NO_LIBNUMA := 1 |
| 394 | else |
Jiri Olsa | 9c12cf9 | 2013-03-21 11:30:54 +0100 | [diff] [blame^] | 395 | CFLAGS += -DLIBNUMA_SUPPORT |
Jiri Olsa | 58a0abd | 2013-03-18 00:45:27 +0100 | [diff] [blame] | 396 | EXTLIBS += -lnuma |
| 397 | endif |
| 398 | endif |
Jiri Olsa | cd1c39f | 2013-03-18 00:56:01 +0100 | [diff] [blame] | 399 | |
| 400 | # Among the variables below, these: |
| 401 | # perfexecdir |
| 402 | # template_dir |
| 403 | # mandir |
| 404 | # infodir |
| 405 | # htmldir |
| 406 | # ETC_PERFCONFIG (but not sysconfdir) |
| 407 | # can be specified as a relative path some/where/else; |
| 408 | # this is interpreted as relative to $(prefix) and "perf" at |
| 409 | # runtime figures out where they are based on the path to the executable. |
| 410 | # This can help installing the suite in a relocatable way. |
| 411 | |
| 412 | # Make the path relative to DESTDIR, not to prefix |
| 413 | ifndef DESTDIR |
| 414 | prefix = $(HOME) |
| 415 | endif |
| 416 | bindir_relative = bin |
| 417 | bindir = $(prefix)/$(bindir_relative) |
| 418 | mandir = share/man |
| 419 | infodir = share/info |
| 420 | perfexecdir = libexec/perf-core |
| 421 | sharedir = $(prefix)/share |
| 422 | template_dir = share/perf-core/templates |
| 423 | htmldir = share/doc/perf-doc |
| 424 | ifeq ($(prefix),/usr) |
| 425 | sysconfdir = /etc |
| 426 | ETC_PERFCONFIG = $(sysconfdir)/perfconfig |
| 427 | else |
| 428 | sysconfdir = $(prefix)/etc |
| 429 | ETC_PERFCONFIG = etc/perfconfig |
| 430 | endif |
| 431 | lib = lib |
| 432 | |
| 433 | # Shell quote (do not use $(call) to accommodate ancient setups); |
| 434 | ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) |
| 435 | DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) |
| 436 | bindir_SQ = $(subst ','\'',$(bindir)) |
| 437 | mandir_SQ = $(subst ','\'',$(mandir)) |
| 438 | infodir_SQ = $(subst ','\'',$(infodir)) |
| 439 | perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) |
| 440 | template_dir_SQ = $(subst ','\'',$(template_dir)) |
| 441 | htmldir_SQ = $(subst ','\'',$(htmldir)) |
| 442 | prefix_SQ = $(subst ','\'',$(prefix)) |
| 443 | sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) |
| 444 | |
| 445 | ifneq ($(filter /%,$(firstword $(perfexecdir))),) |
| 446 | perfexec_instdir = $(perfexecdir) |
| 447 | else |
| 448 | perfexec_instdir = $(prefix)/$(perfexecdir) |
| 449 | endif |
| 450 | perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) |