1include ../scripts/Makefile.include 2 3# The default target of this Makefile is... 4all: 5 6include config/utilities.mak 7 8# Define V to have a more verbose compile. 9# 10# Define O to save output files in a separate directory. 11# 12# Define ARCH as name of target architecture if you want cross-builds. 13# 14# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds. 15# 16# Define NO_LIBPERL to disable perl script extension. 17# 18# Define NO_LIBPYTHON to disable python script extension. 19# 20# Define PYTHON to point to the python binary if the default 21# `python' is not correct; for example: PYTHON=python2 22# 23# Define PYTHON_CONFIG to point to the python-config binary if 24# the default `$(PYTHON)-config' is not correct. 25# 26# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8 27# 28# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72. 29# 30# Define LDFLAGS=-static to build a static binary. 31# 32# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds. 33# 34# Define NO_DWARF if you do not want debug-info analysis feature at all. 35# 36# Define WERROR=0 to disable treating any warnings as errors. 37# 38# Define NO_NEWT if you do not want TUI support. 39# 40# Define NO_GTK2 if you do not want GTK+ GUI support. 41# 42# Define NO_DEMANGLE if you do not want C++ symbol demangling. 43# 44# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) 45# 46# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf 47# backtrace post unwind. 48# 49# Define NO_BACKTRACE if you do not want stack backtrace debug feature 50 51$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE 52 @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) 53 54uname_M := $(shell uname -m 2>/dev/null || echo not) 55 56ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ 57 -e s/arm.*/arm/ -e s/sa110/arm/ \ 58 -e s/s390x/s390/ -e s/parisc64/parisc/ \ 59 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ 60 -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) 61NO_PERF_REGS := 1 62 63CC = $(CROSS_COMPILE)gcc 64AR = $(CROSS_COMPILE)ar 65 66# Additional ARCH settings for x86 67ifeq ($(ARCH),i386) 68 override ARCH := x86 69 NO_PERF_REGS := 0 70 LIBUNWIND_LIBS = -lunwind -lunwind-x86 71endif 72ifeq ($(ARCH),x86_64) 73 override ARCH := x86 74 IS_X86_64 := 0 75 ifeq (, $(findstring m32,$(EXTRA_CFLAGS))) 76 IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1) 77 endif 78 ifeq (${IS_X86_64}, 1) 79 RAW_ARCH := x86_64 80 ARCH_CFLAGS := -DARCH_X86_64 81 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 82 endif 83 NO_PERF_REGS := 0 84 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 85endif 86 87# Treat warnings as errors unless directed not to 88ifneq ($(WERROR),0) 89 CFLAGS_WERROR := -Werror 90endif 91 92ifeq ("$(origin DEBUG)", "command line") 93 PERF_DEBUG = $(DEBUG) 94endif 95ifndef PERF_DEBUG 96 CFLAGS_OPTIMIZE = -O6 -D_FORTIFY_SOURCE=2 97endif 98 99ifdef PARSER_DEBUG 100 PARSER_DEBUG_BISON := -t 101 PARSER_DEBUG_FLEX := -d 102 PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG 103endif 104 105CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) 106EXTLIBS = -lpthread -lrt -lelf -lm 107ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 108ALL_LDFLAGS = $(LDFLAGS) 109STRIP ?= strip 110 111# Among the variables below, these: 112# perfexecdir 113# template_dir 114# mandir 115# infodir 116# htmldir 117# ETC_PERFCONFIG (but not sysconfdir) 118# can be specified as a relative path some/where/else; 119# this is interpreted as relative to $(prefix) and "perf" at 120# runtime figures out where they are based on the path to the executable. 121# This can help installing the suite in a relocatable way. 122 123# Make the path relative to DESTDIR, not to prefix 124ifndef DESTDIR 125prefix = $(HOME) 126endif 127bindir_relative = bin 128bindir = $(prefix)/$(bindir_relative) 129mandir = share/man 130infodir = share/info 131perfexecdir = libexec/perf-core 132sharedir = $(prefix)/share 133template_dir = share/perf-core/templates 134htmldir = share/doc/perf-doc 135ifeq ($(prefix),/usr) 136sysconfdir = /etc 137ETC_PERFCONFIG = $(sysconfdir)/perfconfig 138else 139sysconfdir = $(prefix)/etc 140ETC_PERFCONFIG = etc/perfconfig 141endif 142lib = lib 143 144export prefix bindir sharedir sysconfdir 145 146RM = rm -f 147MKDIR = mkdir 148FIND = find 149INSTALL = install 150 151# sparse is architecture-neutral, which means that we need to tell it 152# explicitly what architecture to check for. Fix this up for yours.. 153SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ 154 155ifneq ($(MAKECMDGOALS),clean) 156ifneq ($(MAKECMDGOALS),tags) 157-include config/feature-tests.mak 158 159ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) 160 CFLAGS := $(CFLAGS) -fstack-protector-all 161endif 162 163ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) 164 CFLAGS := $(CFLAGS) -Wstack-protector 165endif 166 167ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) 168 CFLAGS := $(CFLAGS) -Wvolatile-register-var 169endif 170 171### --- END CONFIGURATION SECTION --- 172 173ifeq ($(srctree),) 174srctree := $(patsubst %/,%,$(dir $(shell pwd))) 175srctree := $(patsubst %/,%,$(dir $(srctree))) 176#$(info Determined 'srctree' to be $(srctree)) 177endif 178 179ifneq ($(objtree),) 180#$(info Determined 'objtree' to be $(objtree)) 181endif 182 183ifneq ($(OUTPUT),) 184#$(info Determined 'OUTPUT' to be $(OUTPUT)) 185endif 186 187BASIC_CFLAGS = \ 188 -Iutil/include \ 189 -Iarch/$(ARCH)/include \ 190 $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \ 191 -I$(srctree)/arch/$(ARCH)/include/uapi \ 192 -I$(srctree)/arch/$(ARCH)/include \ 193 $(if $(objtree),-I$(objtree)/include/generated/uapi) \ 194 -I$(srctree)/include/uapi \ 195 -I$(srctree)/include \ 196 -I$(OUTPUT)util \ 197 -Iutil \ 198 -I. \ 199 -I$(TRACE_EVENT_DIR) \ 200 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 201 202BASIC_LDFLAGS = 203 204ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) 205 BIONIC := 1 206 EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) 207 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) 208 BASIC_CFLAGS += -I. 209endif 210endif # MAKECMDGOALS != tags 211endif # MAKECMDGOALS != clean 212 213# Guard against environment variables 214BUILTIN_OBJS = 215LIB_H = 216LIB_OBJS = 217PYRF_OBJS = 218SCRIPT_SH = 219 220SCRIPT_SH += perf-archive.sh 221 222grep-libs = $(filter -l%,$(1)) 223strip-libs = $(filter-out -l%,$(1)) 224 225TRACE_EVENT_DIR = ../lib/traceevent/ 226 227ifneq ($(OUTPUT),) 228 TE_PATH=$(OUTPUT) 229else 230 TE_PATH=$(TRACE_EVENT_DIR) 231endif 232 233LIBTRACEEVENT = $(TE_PATH)libtraceevent.a 234TE_LIB := -L$(TE_PATH) -ltraceevent 235 236export LIBTRACEEVENT 237 238# python extension build directories 239PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/ 240PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/ 241PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/ 242export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP 243 244python-clean := rm -rf $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so 245 246PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) 247PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py 248 249$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) 250 $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \ 251 --quiet build_ext; \ 252 mkdir -p $(OUTPUT)python && \ 253 cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/ 254# 255# No Perl scripts right now: 256# 257 258SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) 259 260# 261# Single 'perf' binary right now: 262# 263PROGRAMS += $(OUTPUT)perf 264 265LANG_BINDINGS = 266 267# what 'all' will build and 'install' will install, in perfexecdir 268ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) 269 270# what 'all' will build but not install in perfexecdir 271OTHER_PROGRAMS = $(OUTPUT)perf 272 273# Set paths to tools early so that they can be used for version tests. 274ifndef SHELL_PATH 275 SHELL_PATH = /bin/sh 276endif 277ifndef PERL_PATH 278 PERL_PATH = /usr/bin/perl 279endif 280 281export PERL_PATH 282 283FLEX = flex 284BISON= bison 285 286$(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c 287 $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c 288 289$(OUTPUT)util/parse-events-bison.c: util/parse-events.y 290 $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c 291 292$(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c 293 $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c 294 295$(OUTPUT)util/pmu-bison.c: util/pmu.y 296 $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c 297 298$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c 299$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c 300 301LIB_FILE=$(OUTPUT)libperf.a 302 303LIB_H += ../../include/uapi/linux/perf_event.h 304LIB_H += ../../include/linux/rbtree.h 305LIB_H += ../../include/linux/list.h 306LIB_H += ../../include/uapi/linux/const.h 307LIB_H += ../../include/linux/hash.h 308LIB_H += ../../include/linux/stringify.h 309LIB_H += util/include/linux/bitmap.h 310LIB_H += util/include/linux/bitops.h 311LIB_H += util/include/linux/compiler.h 312LIB_H += util/include/linux/const.h 313LIB_H += util/include/linux/ctype.h 314LIB_H += util/include/linux/kernel.h 315LIB_H += util/include/linux/list.h 316LIB_H += util/include/linux/export.h 317LIB_H += util/include/linux/magic.h 318LIB_H += util/include/linux/poison.h 319LIB_H += util/include/linux/prefetch.h 320LIB_H += util/include/linux/rbtree.h 321LIB_H += util/include/linux/rbtree_augmented.h 322LIB_H += util/include/linux/string.h 323LIB_H += util/include/linux/types.h 324LIB_H += util/include/linux/linkage.h 325LIB_H += util/include/asm/asm-offsets.h 326LIB_H += util/include/asm/bug.h 327LIB_H += util/include/asm/byteorder.h 328LIB_H += util/include/asm/hweight.h 329LIB_H += util/include/asm/swab.h 330LIB_H += util/include/asm/system.h 331LIB_H += util/include/asm/uaccess.h 332LIB_H += util/include/dwarf-regs.h 333LIB_H += util/include/asm/dwarf2.h 334LIB_H += util/include/asm/cpufeature.h 335LIB_H += util/include/asm/unistd_32.h 336LIB_H += util/include/asm/unistd_64.h 337LIB_H += perf.h 338LIB_H += util/annotate.h 339LIB_H += util/cache.h 340LIB_H += util/callchain.h 341LIB_H += util/build-id.h 342LIB_H += util/debug.h 343LIB_H += util/debugfs.h 344LIB_H += util/sysfs.h 345LIB_H += util/pmu.h 346LIB_H += util/event.h 347LIB_H += util/evsel.h 348LIB_H += util/evlist.h 349LIB_H += util/exec_cmd.h 350LIB_H += util/types.h 351LIB_H += util/levenshtein.h 352LIB_H += util/machine.h 353LIB_H += util/map.h 354LIB_H += util/parse-options.h 355LIB_H += util/parse-events.h 356LIB_H += util/quote.h 357LIB_H += util/util.h 358LIB_H += util/xyarray.h 359LIB_H += util/header.h 360LIB_H += util/help.h 361LIB_H += util/session.h 362LIB_H += util/strbuf.h 363LIB_H += util/strlist.h 364LIB_H += util/strfilter.h 365LIB_H += util/svghelper.h 366LIB_H += util/tool.h 367LIB_H += util/run-command.h 368LIB_H += util/sigchain.h 369LIB_H += util/dso.h 370LIB_H += util/symbol.h 371LIB_H += util/color.h 372LIB_H += util/values.h 373LIB_H += util/sort.h 374LIB_H += util/hist.h 375LIB_H += util/thread.h 376LIB_H += util/thread_map.h 377LIB_H += util/trace-event.h 378LIB_H += util/probe-finder.h 379LIB_H += util/dwarf-aux.h 380LIB_H += util/probe-event.h 381LIB_H += util/pstack.h 382LIB_H += util/cpumap.h 383LIB_H += util/top.h 384LIB_H += $(ARCH_INCLUDE) 385LIB_H += util/cgroup.h 386LIB_H += $(TRACE_EVENT_DIR)event-parse.h 387LIB_H += util/target.h 388LIB_H += util/rblist.h 389LIB_H += util/intlist.h 390LIB_H += util/perf_regs.h 391LIB_H += util/unwind.h 392LIB_H += util/vdso.h 393LIB_H += ui/helpline.h 394LIB_H += ui/progress.h 395LIB_H += ui/util.h 396LIB_H += ui/ui.h 397 398LIB_OBJS += $(OUTPUT)util/abspath.o 399LIB_OBJS += $(OUTPUT)util/alias.o 400LIB_OBJS += $(OUTPUT)util/annotate.o 401LIB_OBJS += $(OUTPUT)util/build-id.o 402LIB_OBJS += $(OUTPUT)util/config.o 403LIB_OBJS += $(OUTPUT)util/ctype.o 404LIB_OBJS += $(OUTPUT)util/debugfs.o 405LIB_OBJS += $(OUTPUT)util/sysfs.o 406LIB_OBJS += $(OUTPUT)util/pmu.o 407LIB_OBJS += $(OUTPUT)util/environment.o 408LIB_OBJS += $(OUTPUT)util/event.o 409LIB_OBJS += $(OUTPUT)util/evlist.o 410LIB_OBJS += $(OUTPUT)util/evsel.o 411LIB_OBJS += $(OUTPUT)util/exec_cmd.o 412LIB_OBJS += $(OUTPUT)util/help.o 413LIB_OBJS += $(OUTPUT)util/levenshtein.o 414LIB_OBJS += $(OUTPUT)util/parse-options.o 415LIB_OBJS += $(OUTPUT)util/parse-events.o 416LIB_OBJS += $(OUTPUT)util/path.o 417LIB_OBJS += $(OUTPUT)util/rbtree.o 418LIB_OBJS += $(OUTPUT)util/bitmap.o 419LIB_OBJS += $(OUTPUT)util/hweight.o 420LIB_OBJS += $(OUTPUT)util/run-command.o 421LIB_OBJS += $(OUTPUT)util/quote.o 422LIB_OBJS += $(OUTPUT)util/strbuf.o 423LIB_OBJS += $(OUTPUT)util/string.o 424LIB_OBJS += $(OUTPUT)util/strlist.o 425LIB_OBJS += $(OUTPUT)util/strfilter.o 426LIB_OBJS += $(OUTPUT)util/top.o 427LIB_OBJS += $(OUTPUT)util/usage.o 428LIB_OBJS += $(OUTPUT)util/wrapper.o 429LIB_OBJS += $(OUTPUT)util/sigchain.o 430LIB_OBJS += $(OUTPUT)util/dso.o 431LIB_OBJS += $(OUTPUT)util/symbol.o 432LIB_OBJS += $(OUTPUT)util/symbol-elf.o 433LIB_OBJS += $(OUTPUT)util/color.o 434LIB_OBJS += $(OUTPUT)util/pager.o 435LIB_OBJS += $(OUTPUT)util/header.o 436LIB_OBJS += $(OUTPUT)util/callchain.o 437LIB_OBJS += $(OUTPUT)util/values.o 438LIB_OBJS += $(OUTPUT)util/debug.o 439LIB_OBJS += $(OUTPUT)util/machine.o 440LIB_OBJS += $(OUTPUT)util/map.o 441LIB_OBJS += $(OUTPUT)util/pstack.o 442LIB_OBJS += $(OUTPUT)util/session.o 443LIB_OBJS += $(OUTPUT)util/thread.o 444LIB_OBJS += $(OUTPUT)util/thread_map.o 445LIB_OBJS += $(OUTPUT)util/trace-event-parse.o 446LIB_OBJS += $(OUTPUT)util/parse-events-flex.o 447LIB_OBJS += $(OUTPUT)util/parse-events-bison.o 448LIB_OBJS += $(OUTPUT)util/pmu-flex.o 449LIB_OBJS += $(OUTPUT)util/pmu-bison.o 450LIB_OBJS += $(OUTPUT)util/trace-event-read.o 451LIB_OBJS += $(OUTPUT)util/trace-event-info.o 452LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o 453LIB_OBJS += $(OUTPUT)util/svghelper.o 454LIB_OBJS += $(OUTPUT)util/sort.o 455LIB_OBJS += $(OUTPUT)util/hist.o 456LIB_OBJS += $(OUTPUT)util/probe-event.o 457LIB_OBJS += $(OUTPUT)util/util.o 458LIB_OBJS += $(OUTPUT)util/xyarray.o 459LIB_OBJS += $(OUTPUT)util/cpumap.o 460LIB_OBJS += $(OUTPUT)util/cgroup.o 461LIB_OBJS += $(OUTPUT)util/target.o 462LIB_OBJS += $(OUTPUT)util/rblist.o 463LIB_OBJS += $(OUTPUT)util/intlist.o 464LIB_OBJS += $(OUTPUT)util/vdso.o 465LIB_OBJS += $(OUTPUT)util/stat.o 466 467LIB_OBJS += $(OUTPUT)ui/setup.o 468LIB_OBJS += $(OUTPUT)ui/helpline.o 469LIB_OBJS += $(OUTPUT)ui/progress.o 470LIB_OBJS += $(OUTPUT)ui/util.o 471LIB_OBJS += $(OUTPUT)ui/hist.o 472LIB_OBJS += $(OUTPUT)ui/stdio/hist.o 473 474LIB_OBJS += $(OUTPUT)arch/common.o 475 476LIB_OBJS += $(OUTPUT)tests/parse-events.o 477LIB_OBJS += $(OUTPUT)tests/dso-data.o 478LIB_OBJS += $(OUTPUT)tests/attr.o 479LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o 480LIB_OBJS += $(OUTPUT)tests/open-syscall.o 481LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o 482LIB_OBJS += $(OUTPUT)tests/open-syscall-tp-fields.o 483LIB_OBJS += $(OUTPUT)tests/mmap-basic.o 484LIB_OBJS += $(OUTPUT)tests/perf-record.o 485LIB_OBJS += $(OUTPUT)tests/rdpmc.o 486LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o 487LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o 488LIB_OBJS += $(OUTPUT)tests/pmu.o 489LIB_OBJS += $(OUTPUT)tests/hists_link.o 490LIB_OBJS += $(OUTPUT)tests/python-use.o 491 492BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o 493BUILTIN_OBJS += $(OUTPUT)builtin-bench.o 494# Benchmark modules 495BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o 496BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o 497ifeq ($(RAW_ARCH),x86_64) 498BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o 499BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o 500endif 501BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o 502BUILTIN_OBJS += $(OUTPUT)bench/mem-memset.o 503 504BUILTIN_OBJS += $(OUTPUT)builtin-diff.o 505BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o 506BUILTIN_OBJS += $(OUTPUT)builtin-help.o 507BUILTIN_OBJS += $(OUTPUT)builtin-sched.o 508BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o 509BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o 510BUILTIN_OBJS += $(OUTPUT)builtin-list.o 511BUILTIN_OBJS += $(OUTPUT)builtin-record.o 512BUILTIN_OBJS += $(OUTPUT)builtin-report.o 513BUILTIN_OBJS += $(OUTPUT)builtin-stat.o 514BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o 515BUILTIN_OBJS += $(OUTPUT)builtin-top.o 516BUILTIN_OBJS += $(OUTPUT)builtin-script.o 517BUILTIN_OBJS += $(OUTPUT)builtin-probe.o 518BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o 519BUILTIN_OBJS += $(OUTPUT)builtin-lock.o 520BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o 521BUILTIN_OBJS += $(OUTPUT)builtin-inject.o 522BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o 523 524PERFLIBS = $(LIB_FILE) $(LIBTRACEEVENT) 525 526# 527# Platform specific tweaks 528# 529ifneq ($(MAKECMDGOALS),clean) 530ifneq ($(MAKECMDGOALS),tags) 531 532# We choose to avoid "if .. else if .. else .. endif endif" 533# because maintaining the nesting to match is a pain. If 534# we had "elif" things would have been much nicer... 535 536ifdef NO_LIBELF 537 NO_DWARF := 1 538 NO_DEMANGLE := 1 539 NO_LIBUNWIND := 1 540else 541FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) 542ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) 543 FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS) 544 ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) 545 LIBC_SUPPORT := 1 546 endif 547 ifeq ($(BIONIC),1) 548 LIBC_SUPPORT := 1 549 endif 550 ifeq ($(LIBC_SUPPORT),1) 551 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); 552 553 NO_LIBELF := 1 554 NO_DWARF := 1 555 NO_DEMANGLE := 1 556 else 557 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); 558 endif 559else 560 # for linking with debug library, run like: 561 # make DEBUG=1 LIBDW_DIR=/opt/libdw/ 562 ifdef LIBDW_DIR 563 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include 564 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib 565 endif 566 567 FLAGS_DWARF=$(ALL_CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) 568 ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) 569 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); 570 NO_DWARF := 1 571 endif # Dwarf support 572endif # SOURCE_LIBELF 573endif # NO_LIBELF 574 575ifndef NO_LIBUNWIND 576# for linking with debug library, run like: 577# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ 578ifdef LIBUNWIND_DIR 579 LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include 580 LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib 581endif 582 583FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(ALL_CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) 584ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) 585 msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); 586 NO_LIBUNWIND := 1 587endif # Libunwind support 588endif # NO_LIBUNWIND 589 590-include arch/$(ARCH)/Makefile 591 592ifneq ($(OUTPUT),) 593 BASIC_CFLAGS += -I$(OUTPUT) 594endif 595 596ifdef NO_LIBELF 597EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) 598 599# Remove ELF/DWARF dependent codes 600LIB_OBJS := $(filter-out $(OUTPUT)util/symbol-elf.o,$(LIB_OBJS)) 601LIB_OBJS := $(filter-out $(OUTPUT)util/dwarf-aux.o,$(LIB_OBJS)) 602LIB_OBJS := $(filter-out $(OUTPUT)util/probe-event.o,$(LIB_OBJS)) 603LIB_OBJS := $(filter-out $(OUTPUT)util/probe-finder.o,$(LIB_OBJS)) 604 605BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS)) 606 607# Use minimal symbol handling 608LIB_OBJS += $(OUTPUT)util/symbol-minimal.o 609 610else # NO_LIBELF 611BASIC_CFLAGS += -DLIBELF_SUPPORT 612 613FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) 614ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) 615 BASIC_CFLAGS += -DLIBELF_MMAP 616endif 617 618ifndef NO_DWARF 619ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) 620 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); 621else 622 BASIC_CFLAGS := -DDWARF_SUPPORT $(LIBDW_CFLAGS) $(BASIC_CFLAGS) 623 BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS) 624 EXTLIBS += -lelf -ldw 625 LIB_OBJS += $(OUTPUT)util/probe-finder.o 626 LIB_OBJS += $(OUTPUT)util/dwarf-aux.o 627endif # PERF_HAVE_DWARF_REGS 628endif # NO_DWARF 629endif # NO_LIBELF 630 631ifndef NO_LIBUNWIND 632 BASIC_CFLAGS += -DLIBUNWIND_SUPPORT 633 EXTLIBS += $(LIBUNWIND_LIBS) 634 BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS) 635 BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS) 636 LIB_OBJS += $(OUTPUT)util/unwind.o 637endif 638 639ifndef NO_LIBAUDIT 640 FLAGS_LIBAUDIT = $(ALL_CFLAGS) $(ALL_LDFLAGS) -laudit 641 ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y) 642 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); 643 else 644 BASIC_CFLAGS += -DLIBAUDIT_SUPPORT 645 BUILTIN_OBJS += $(OUTPUT)builtin-trace.o 646 EXTLIBS += -laudit 647 endif 648endif 649 650ifndef NO_NEWT 651 FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt 652 ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT),libnewt),y) 653 msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev); 654 else 655 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h 656 BASIC_CFLAGS += -I/usr/include/slang 657 BASIC_CFLAGS += -DNEWT_SUPPORT 658 EXTLIBS += -lnewt -lslang 659 LIB_OBJS += $(OUTPUT)ui/browser.o 660 LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o 661 LIB_OBJS += $(OUTPUT)ui/browsers/hists.o 662 LIB_OBJS += $(OUTPUT)ui/browsers/map.o 663 LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o 664 LIB_OBJS += $(OUTPUT)ui/tui/setup.o 665 LIB_OBJS += $(OUTPUT)ui/tui/util.o 666 LIB_OBJS += $(OUTPUT)ui/tui/helpline.o 667 LIB_OBJS += $(OUTPUT)ui/tui/progress.o 668 LIB_H += ui/browser.h 669 LIB_H += ui/browsers/map.h 670 LIB_H += ui/keysyms.h 671 LIB_H += ui/libslang.h 672 endif 673endif 674 675ifndef NO_GTK2 676 FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) 677 ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y) 678 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); 679 else 680 ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y) 681 BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR 682 endif 683 BASIC_CFLAGS += -DGTK2_SUPPORT 684 BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) 685 EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null) 686 LIB_OBJS += $(OUTPUT)ui/gtk/browser.o 687 LIB_OBJS += $(OUTPUT)ui/gtk/hists.o 688 LIB_OBJS += $(OUTPUT)ui/gtk/setup.o 689 LIB_OBJS += $(OUTPUT)ui/gtk/util.o 690 LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o 691 LIB_OBJS += $(OUTPUT)ui/gtk/progress.o 692 endif 693endif 694 695ifdef NO_LIBPERL 696 BASIC_CFLAGS += -DNO_LIBPERL 697else 698 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) 699 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) 700 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) 701 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` 702 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) 703 704 ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y) 705 BASIC_CFLAGS += -DNO_LIBPERL 706 else 707 ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS) 708 EXTLIBS += $(PERL_EMBED_LIBADD) 709 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o 710 LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o 711 endif 712endif 713 714disable-python = $(eval $(disable-python_code)) 715define disable-python_code 716 BASIC_CFLAGS += -DNO_LIBPYTHON 717 $(if $(1),$(warning No $(1) was found)) 718 $(warning Python support will not be built) 719endef 720 721override PYTHON := \ 722 $(call get-executable-or-default,PYTHON,python) 723 724ifndef PYTHON 725 $(call disable-python,python interpreter) 726else 727 728 PYTHON_WORD := $(call shell-wordify,$(PYTHON)) 729 730 ifdef NO_LIBPYTHON 731 $(call disable-python) 732 else 733 734 override PYTHON_CONFIG := \ 735 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config) 736 737 ifndef PYTHON_CONFIG 738 $(call disable-python,python-config tool) 739 else 740 741 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) 742 743 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) 744 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) 745 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) 746 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) 747 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) 748 749 ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y) 750 $(call disable-python,Python.h (for Python 2.x)) 751 else 752 753 ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y) 754 $(warning Python 3 is not yet supported; please set) 755 $(warning PYTHON and/or PYTHON_CONFIG appropriately.) 756 $(warning If you also have Python 2 installed, then) 757 $(warning try something like:) 758 $(warning $(and ,)) 759 $(warning $(and ,) make PYTHON=python2) 760 $(warning $(and ,)) 761 $(warning Otherwise, disable Python support entirely:) 762 $(warning $(and ,)) 763 $(warning $(and ,) make NO_LIBPYTHON=1) 764 $(warning $(and ,)) 765 $(error $(and ,)) 766 else 767 ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS) 768 EXTLIBS += $(PYTHON_EMBED_LIBADD) 769 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o 770 LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o 771 LANG_BINDINGS += $(OUTPUT)python/perf.so 772 endif 773 774 endif 775 endif 776 endif 777endif 778 779ifdef NO_DEMANGLE 780 BASIC_CFLAGS += -DNO_DEMANGLE 781else 782 ifdef HAVE_CPLUS_DEMANGLE 783 EXTLIBS += -liberty 784 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE 785 else 786 FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd 787 has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd) 788 ifeq ($(has_bfd),y) 789 EXTLIBS += -lbfd 790 else 791 FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty 792 has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty) 793 ifeq ($(has_bfd_iberty),y) 794 EXTLIBS += -lbfd -liberty 795 else 796 FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz 797 has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz) 798 ifeq ($(has_bfd_iberty_z),y) 799 EXTLIBS += -lbfd -liberty -lz 800 else 801 FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty 802 has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle) 803 ifeq ($(has_cplus_demangle),y) 804 EXTLIBS += -liberty 805 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE 806 else 807 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) 808 BASIC_CFLAGS += -DNO_DEMANGLE 809 endif 810 endif 811 endif 812 endif 813 endif 814endif 815 816ifeq ($(NO_PERF_REGS),0) 817 ifeq ($(ARCH),x86) 818 LIB_H += arch/x86/include/perf_regs.h 819 endif 820 BASIC_CFLAGS += -DHAVE_PERF_REGS 821endif 822 823ifndef NO_STRLCPY 824 ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y) 825 BASIC_CFLAGS += -DHAVE_STRLCPY 826 endif 827endif 828 829ifndef NO_ON_EXIT 830 ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y) 831 BASIC_CFLAGS += -DHAVE_ON_EXIT 832 endif 833endif 834 835ifndef NO_BACKTRACE 836 ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y) 837 BASIC_CFLAGS += -DBACKTRACE_SUPPORT 838 endif 839endif 840 841ifdef ASCIIDOC8 842 export ASCIIDOC8 843endif 844 845endif # MAKECMDGOALS != tags 846endif # MAKECMDGOALS != clean 847 848# Shell quote (do not use $(call) to accommodate ancient setups); 849 850ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) 851 852DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) 853bindir_SQ = $(subst ','\'',$(bindir)) 854bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) 855mandir_SQ = $(subst ','\'',$(mandir)) 856infodir_SQ = $(subst ','\'',$(infodir)) 857perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) 858template_dir_SQ = $(subst ','\'',$(template_dir)) 859htmldir_SQ = $(subst ','\'',$(htmldir)) 860prefix_SQ = $(subst ','\'',$(prefix)) 861sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) 862 863SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) 864 865LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group 866 867ALL_CFLAGS += $(BASIC_CFLAGS) 868ALL_CFLAGS += $(ARCH_CFLAGS) 869ALL_LDFLAGS += $(BASIC_LDFLAGS) 870 871export INSTALL SHELL_PATH 872 873 874### Build rules 875 876SHELL = $(SHELL_PATH) 877 878all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) 879 880please_set_SHELL_PATH_to_a_more_modern_shell: 881 @$$(:) 882 883shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell 884 885strip: $(PROGRAMS) $(OUTPUT)perf 886 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf 887 888$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS 889 $(QUIET_CC)$(CC) -include $(OUTPUT)PERF-VERSION-FILE \ 890 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ 891 $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@ 892 893$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS) 894 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \ 895 $(BUILTIN_OBJS) $(LIBS) -o $@ 896 897$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS 898 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ 899 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ 900 '-DPERF_MAN_PATH="$(mandir_SQ)"' \ 901 '-DPERF_INFO_PATH="$(infodir_SQ)"' $< 902 903$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS 904 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ 905 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ 906 '-DPERF_MAN_PATH="$(mandir_SQ)"' \ 907 '-DPERF_INFO_PATH="$(infodir_SQ)"' $< 908 909$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt 910 911$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt) 912 $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@ 913 914$(SCRIPTS) : % : %.sh 915 $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@' 916 917# These can record PERF_VERSION 918$(OUTPUT)perf.o perf.spec \ 919 $(SCRIPTS) \ 920 : $(OUTPUT)PERF-VERSION-FILE 921 922.SUFFIXES: 923.SUFFIXES: .o .c .S .s 924 925# These two need to be here so that when O= is not used they take precedence 926# over the general rule for .o 927 928$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS 929 $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(ALL_CFLAGS) -w $< 930 931$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS 932 $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(ALL_CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $< 933 934$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS 935 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< 936$(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS 937 $(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $< 938$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS 939 $(QUIET_CC)$(CC) -o $@ -S $(ALL_CFLAGS) $< 940$(OUTPUT)%.o: %.S 941 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< 942$(OUTPUT)%.s: %.S 943 $(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $< 944 945$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS 946 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ 947 '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \ 948 '-DPREFIX="$(prefix_SQ)"' \ 949 $< 950 951$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS 952 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ 953 '-DBINDIR="$(bindir_SQ)"' -DPYTHON='"$(PYTHON_WORD)"' \ 954 $< 955 956$(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS 957 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ 958 -DPYTHONPATH='"$(OUTPUT)python"' \ 959 -DPYTHON='"$(PYTHON_WORD)"' \ 960 $< 961 962$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS 963 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 964 965$(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS 966 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< 967 968$(OUTPUT)ui/browsers/annotate.o: ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS 969 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< 970 971$(OUTPUT)ui/browsers/hists.o: ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS 972 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< 973 974$(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS 975 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< 976 977$(OUTPUT)ui/browsers/scripts.o: ui/browsers/scripts.c $(OUTPUT)PERF-CFLAGS 978 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< 979 980$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS 981 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 982 983$(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS 984 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls $< 985 986$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS 987 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< 988 989$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS 990 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $< 991 992$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS 993 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< 994 995$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS 996 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $< 997 998$(OUTPUT)perf-%: %.o $(PERFLIBS) 999 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) 1000 1001$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H) 1002$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h) 1003 1004# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So 1005# we depend the various files onto their directories. 1006DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h 1007$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS))) 1008# In the second step, we make a rule to actually create these directories 1009$(sort $(dir $(DIRECTORY_DEPS))): 1010 $(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null 1011 1012$(LIB_FILE): $(LIB_OBJS) 1013 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS) 1014 1015# libtraceevent.a 1016$(LIBTRACEEVENT): 1017 $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a 1018 1019$(LIBTRACEEVENT)-clean: 1020 $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean 1021 1022help: 1023 @echo 'Perf make targets:' 1024 @echo ' doc - make *all* documentation (see below)' 1025 @echo ' man - make manpage documentation (access with man <foo>)' 1026 @echo ' html - make html documentation' 1027 @echo ' info - make GNU info documentation (access with info <foo>)' 1028 @echo ' pdf - make pdf documentation' 1029 @echo ' TAGS - use etags to make tag information for source browsing' 1030 @echo ' tags - use ctags to make tag information for source browsing' 1031 @echo ' cscope - use cscope to make interactive browsing database' 1032 @echo '' 1033 @echo 'Perf install targets:' 1034 @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed' 1035 @echo ' HINT: use "make prefix=<path> <install target>" to install to a particular' 1036 @echo ' path like make prefix=/usr/local install install-doc' 1037 @echo ' install - install compiled binaries' 1038 @echo ' install-doc - install *all* documentation' 1039 @echo ' install-man - install manpage documentation' 1040 @echo ' install-html - install html documentation' 1041 @echo ' install-info - install GNU info documentation' 1042 @echo ' install-pdf - install pdf documentation' 1043 @echo '' 1044 @echo ' quick-install-doc - alias for quick-install-man' 1045 @echo ' quick-install-man - install the documentation quickly' 1046 @echo ' quick-install-html - install the html documentation quickly' 1047 @echo '' 1048 @echo 'Perf maintainer targets:' 1049 @echo ' clean - clean all binary objects and build output' 1050 1051 1052DOC_TARGETS := doc man html info pdf 1053 1054INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man 1055INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html 1056 1057# 'make doc' should call 'make -C Documentation all' 1058$(DOC_TARGETS): 1059 $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all) 1060 1061TAGS: 1062 $(RM) TAGS 1063 $(FIND) . -name '*.[hcS]' -print | xargs etags -a 1064 1065tags: 1066 $(RM) tags 1067 $(FIND) . -name '*.[hcS]' -print | xargs ctags -a 1068 1069cscope: 1070 $(RM) cscope* 1071 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b 1072 1073### Detect prefix changes 1074TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\ 1075 $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ) 1076 1077$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS 1078 @FLAGS='$(TRACK_CFLAGS)'; \ 1079 if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \ 1080 echo 1>&2 " * new build flags or prefix"; \ 1081 echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \ 1082 fi 1083 1084### Testing rules 1085 1086# GNU make supports exporting all variables by "export" without parameters. 1087# However, the environment gets quite big, and some programs have problems 1088# with that. 1089 1090check: $(OUTPUT)common-cmds.h 1091 if sparse; \ 1092 then \ 1093 for i in *.c */*.c; \ 1094 do \ 1095 sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \ 1096 done; \ 1097 else \ 1098 exit 1; \ 1099 fi 1100 1101### Installation rules 1102 1103ifneq ($(filter /%,$(firstword $(perfexecdir))),) 1104perfexec_instdir = $(perfexecdir) 1105else 1106perfexec_instdir = $(prefix)/$(perfexecdir) 1107endif 1108perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) 1109 1110install-bin: all 1111 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' 1112 $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)' 1113 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace' 1114 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin' 1115 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' 1116 $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace' 1117 $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl' 1118 $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin' 1119 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace' 1120 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin' 1121 $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace' 1122 $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python' 1123 $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin' 1124 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d' 1125 $(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf' 1126 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests' 1127 $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests' 1128 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' 1129 $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' 1130 1131install: install-bin try-install-man 1132 1133install-python_ext: 1134 $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' 1135 1136# 'make install-doc' should call 'make -C Documentation install' 1137$(INSTALL_DOC_TARGETS): 1138 $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=) 1139 1140### Cleaning rules 1141 1142clean: $(LIBTRACEEVENT)-clean 1143 $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS) 1144 $(RM) $(ALL_PROGRAMS) perf 1145 $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* 1146 $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean 1147 $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS 1148 $(RM) $(OUTPUT)util/*-bison* 1149 $(RM) $(OUTPUT)util/*-flex* 1150 $(python-clean) 1151 1152.PHONY: all install clean strip $(LIBTRACEEVENT) 1153.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell 1154.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS 1155