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