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