xref: /linux/tools/perf/Makefile (revision ca721e45b39209415d2288dbac3667b26d9d1def)
186470930SIngo Molnar# The default target of this Makefile is...
286470930SIngo Molnarall::
386470930SIngo Molnar
486470930SIngo Molnar# Define V=1 to have a more verbose compile.
57baed9afSMichael S. Tsirkin# Define V=2 to have an even more verbose compile.
686470930SIngo Molnar#
786470930SIngo Molnar# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
886470930SIngo Molnar# or vsnprintf() return -1 instead of number of characters which would
986470930SIngo Molnar# have been written to the final string if enough space had been available.
1086470930SIngo Molnar#
1186470930SIngo Molnar# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
1286470930SIngo Molnar# when attempting to read from an fopen'ed directory.
1386470930SIngo Molnar#
1486470930SIngo Molnar# Define NO_OPENSSL environment variable if you do not have OpenSSL.
1586470930SIngo Molnar# This also implies MOZILLA_SHA1.
1686470930SIngo Molnar#
1786470930SIngo Molnar# Define CURLDIR=/foo/bar if your curl header and library files are in
1886470930SIngo Molnar# /foo/bar/include and /foo/bar/lib directories.
1986470930SIngo Molnar#
2086470930SIngo Molnar# Define EXPATDIR=/foo/bar if your expat header and library files are in
2186470930SIngo Molnar# /foo/bar/include and /foo/bar/lib directories.
2286470930SIngo Molnar#
2386470930SIngo Molnar# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
2486470930SIngo Molnar#
2586470930SIngo Molnar# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
2686470930SIngo Molnar# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
2786470930SIngo Molnar#
2886470930SIngo Molnar# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
2986470930SIngo Molnar# do not support the 'size specifiers' introduced by C99, namely ll, hh,
3086470930SIngo Molnar# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
3186470930SIngo Molnar# some C compilers supported these specifiers prior to C99 as an extension.
3286470930SIngo Molnar#
3386470930SIngo Molnar# Define NO_STRCASESTR if you don't have strcasestr.
3486470930SIngo Molnar#
3586470930SIngo Molnar# Define NO_MEMMEM if you don't have memmem.
3686470930SIngo Molnar#
3786470930SIngo Molnar# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
3886470930SIngo Molnar# If your compiler also does not support long long or does not have
3986470930SIngo Molnar# strtoull, define NO_STRTOULL.
4086470930SIngo Molnar#
4186470930SIngo Molnar# Define NO_SETENV if you don't have setenv in the C library.
4286470930SIngo Molnar#
4386470930SIngo Molnar# Define NO_UNSETENV if you don't have unsetenv in the C library.
4486470930SIngo Molnar#
4586470930SIngo Molnar# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
4686470930SIngo Molnar#
4786470930SIngo Molnar# Define NO_SYS_SELECT_H if you don't have sys/select.h.
4886470930SIngo Molnar#
4986470930SIngo Molnar# Define NO_SYMLINK_HEAD if you never want .perf/HEAD to be a symbolic link.
5086470930SIngo Molnar# Enable it on Windows.  By default, symrefs are still used.
5186470930SIngo Molnar#
5286470930SIngo Molnar# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
5386470930SIngo Molnar# tests.  These tests take up a significant amount of the total test time
5486470930SIngo Molnar# but are not needed unless you plan to talk to SVN repos.
5586470930SIngo Molnar#
5686470930SIngo Molnar# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
5786470930SIngo Molnar# installed in /sw, but don't want PERF to link against any libraries
5886470930SIngo Molnar# installed there.  If defined you may specify your own (or Fink's)
5986470930SIngo Molnar# include directories and library directories by defining CFLAGS
6086470930SIngo Molnar# and LDFLAGS appropriately.
6186470930SIngo Molnar#
6286470930SIngo Molnar# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
6386470930SIngo Molnar# have DarwinPorts installed in /opt/local, but don't want PERF to
6486470930SIngo Molnar# link against any libraries installed there.  If defined you may
6586470930SIngo Molnar# specify your own (or DarwinPort's) include directories and
6686470930SIngo Molnar# library directories by defining CFLAGS and LDFLAGS appropriately.
6786470930SIngo Molnar#
6886470930SIngo Molnar# Define PPC_SHA1 environment variable when running make to make use of
6986470930SIngo Molnar# a bundled SHA1 routine optimized for PowerPC.
7086470930SIngo Molnar#
7186470930SIngo Molnar# Define ARM_SHA1 environment variable when running make to make use of
7286470930SIngo Molnar# a bundled SHA1 routine optimized for ARM.
7386470930SIngo Molnar#
7486470930SIngo Molnar# Define MOZILLA_SHA1 environment variable when running make to make use of
7586470930SIngo Molnar# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
7686470930SIngo Molnar# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
7786470930SIngo Molnar# choice) has very fast version optimized for i586.
7886470930SIngo Molnar#
7986470930SIngo Molnar# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
8086470930SIngo Molnar#
8186470930SIngo Molnar# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
8286470930SIngo Molnar#
8386470930SIngo Molnar# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
8486470930SIngo Molnar# Patrick Mauritz).
8586470930SIngo Molnar#
8686470930SIngo Molnar# Define NO_MMAP if you want to avoid mmap.
8786470930SIngo Molnar#
8886470930SIngo Molnar# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
8986470930SIngo Molnar#
9086470930SIngo Molnar# Define NO_PREAD if you have a problem with pread() system call (e.g.
9186470930SIngo Molnar# cygwin.dll before v1.5.22).
9286470930SIngo Molnar#
9386470930SIngo Molnar# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
9486470930SIngo Molnar# generally faster on your platform than accessing the working directory.
9586470930SIngo Molnar#
9686470930SIngo Molnar# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
9786470930SIngo Molnar# the executable mode bit, but doesn't really do so.
9886470930SIngo Molnar#
9986470930SIngo Molnar# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
10086470930SIngo Molnar#
10186470930SIngo Molnar# Define NO_SOCKADDR_STORAGE if your platform does not have struct
10286470930SIngo Molnar# sockaddr_storage.
10386470930SIngo Molnar#
10486470930SIngo Molnar# Define NO_ICONV if your libc does not properly support iconv.
10586470930SIngo Molnar#
10686470930SIngo Molnar# Define OLD_ICONV if your library has an old iconv(), where the second
10786470930SIngo Molnar# (input buffer pointer) parameter is declared with type (const char **).
10886470930SIngo Molnar#
10986470930SIngo Molnar# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
11086470930SIngo Molnar#
11186470930SIngo Molnar# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
11286470930SIngo Molnar# that tells runtime paths to dynamic libraries;
11386470930SIngo Molnar# "-Wl,-rpath=/path/lib" is used instead.
11486470930SIngo Molnar#
11586470930SIngo Molnar# Define USE_NSEC below if you want perf to care about sub-second file mtimes
11686470930SIngo Molnar# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
11786470930SIngo Molnar# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
11886470930SIngo Molnar# randomly break unless your underlying filesystem supports those sub-second
11986470930SIngo Molnar# times (my ext3 doesn't).
12086470930SIngo Molnar#
12186470930SIngo Molnar# Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
12286470930SIngo Molnar# "st_ctim"
12386470930SIngo Molnar#
12486470930SIngo Molnar# Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
12586470930SIngo Molnar# available.  This automatically turns USE_NSEC off.
12686470930SIngo Molnar#
12786470930SIngo Molnar# Define USE_STDEV below if you want perf to care about the underlying device
12886470930SIngo Molnar# change being considered an inode change from the update-index perspective.
12986470930SIngo Molnar#
13086470930SIngo Molnar# Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
13186470930SIngo Molnar# field that counts the on-disk footprint in 512-byte blocks.
13286470930SIngo Molnar#
13386470930SIngo Molnar# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
13486470930SIngo Molnar#
13586470930SIngo Molnar# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
13686470930SIngo Molnar#
13786470930SIngo Molnar# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
13886470930SIngo Molnar# MakeMaker (e.g. using ActiveState under Cygwin).
13986470930SIngo Molnar#
14086470930SIngo Molnar# Define NO_PERL if you do not want Perl scripts or libraries at all.
14186470930SIngo Molnar#
14286470930SIngo Molnar# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
14386470930SIngo Molnar# is a simplified version of the merge sort used in glibc. This is
14486470930SIngo Molnar# recommended if Git triggers O(n^2) behavior in your platform's qsort().
14586470930SIngo Molnar#
14686470930SIngo Molnar# Define NO_EXTERNAL_GREP if you don't want "perf grep" to ever call
14786470930SIngo Molnar# your external grep (e.g., if your system lacks grep, if its grep is
14886470930SIngo Molnar# broken, or spawning external process is slower than built-in grep perf has).
14975138650SMichael S. Tsirkin#
15075138650SMichael S. Tsirkin# Define LDFLAGS=-static to build a static binary.
15181516c5fSMichael S. Tsirkin#
15281516c5fSMichael S. Tsirkin# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
153*ca721e45SMasami Hiramatsu#
154*ca721e45SMasami Hiramatsu# Define NO_DWARF if you do not want debug-info analysis feature at all.
15586470930SIngo Molnar
15686470930SIngo MolnarPERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
15786470930SIngo Molnar	@$(SHELL_PATH) util/PERF-VERSION-GEN
15886470930SIngo Molnar-include PERF-VERSION-FILE
15986470930SIngo Molnar
16086470930SIngo Molnaruname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
16186470930SIngo Molnaruname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
16286470930SIngo Molnaruname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
16386470930SIngo Molnaruname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
16486470930SIngo Molnaruname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
16586470930SIngo Molnaruname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
16686470930SIngo Molnar
16786470930SIngo Molnar# CFLAGS and LDFLAGS are for the users to override from the command line.
16886470930SIngo Molnar
16983a0944fSIngo Molnar#
17083a0944fSIngo Molnar# Include saner warnings here, which can catch bugs:
17183a0944fSIngo Molnar#
17261562445SIngo Molnar
173ec29b8d2SPaul MundtEXTRA_WARNINGS := -Wformat
17461562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
17561562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
17661562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
17761562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
17861562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
17961562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
18061562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector
18161562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
18261562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
18361562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
18461562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
18561562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
18661562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var
18761562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
18861562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
18961562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
19061562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes
19161562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs
19261562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
19361562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
19461562445SIngo MolnarEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
19583a0944fSIngo Molnar
19660d526f7SSteven Rostedtifeq ("$(origin DEBUG)", "command line")
19760d526f7SSteven Rostedt  PERF_DEBUG = $(DEBUG)
19860d526f7SSteven Rostedtendif
19960d526f7SSteven Rostedtifndef PERF_DEBUG
20060d526f7SSteven Rostedt  CFLAGS_OPTIMIZE = -O6
20160d526f7SSteven Rostedtendif
20260d526f7SSteven Rostedt
20381516c5fSMichael S. TsirkinCFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
20475138650SMichael S. TsirkinEXTLIBS = -lpthread -lrt -lelf -lm
20586470930SIngo MolnarALL_CFLAGS = $(CFLAGS)
20686470930SIngo MolnarALL_LDFLAGS = $(LDFLAGS)
20786470930SIngo MolnarSTRIP ?= strip
20886470930SIngo Molnar
20986470930SIngo Molnar# Among the variables below, these:
21086470930SIngo Molnar#   perfexecdir
21186470930SIngo Molnar#   template_dir
21286470930SIngo Molnar#   mandir
21386470930SIngo Molnar#   infodir
21486470930SIngo Molnar#   htmldir
21586470930SIngo Molnar#   ETC_PERFCONFIG (but not sysconfdir)
21686470930SIngo Molnar# can be specified as a relative path some/where/else;
21786470930SIngo Molnar# this is interpreted as relative to $(prefix) and "perf" at
21886470930SIngo Molnar# runtime figures out where they are based on the path to the executable.
21986470930SIngo Molnar# This can help installing the suite in a relocatable way.
22086470930SIngo Molnar
2217ae5f213SJohn Kacur# Make the path relative to DESTDIR, not to prefix
2227ae5f213SJohn Kacurifndef DESTDIR
22386470930SIngo Molnarprefix = $(HOME)
2247ae5f213SJohn Kacurendif
22586470930SIngo Molnarbindir_relative = bin
22686470930SIngo Molnarbindir = $(prefix)/$(bindir_relative)
22786470930SIngo Molnarmandir = share/man
22886470930SIngo Molnarinfodir = share/info
22986470930SIngo Molnarperfexecdir = libexec/perf-core
23086470930SIngo Molnarsharedir = $(prefix)/share
23186470930SIngo Molnartemplate_dir = share/perf-core/templates
23286470930SIngo Molnarhtmldir = share/doc/perf-doc
23386470930SIngo Molnarifeq ($(prefix),/usr)
23486470930SIngo Molnarsysconfdir = /etc
23586470930SIngo MolnarETC_PERFCONFIG = $(sysconfdir)/perfconfig
23686470930SIngo Molnarelse
23786470930SIngo Molnarsysconfdir = $(prefix)/etc
23886470930SIngo MolnarETC_PERFCONFIG = etc/perfconfig
23986470930SIngo Molnarendif
24086470930SIngo Molnarlib = lib
24186470930SIngo Molnar
24286470930SIngo Molnarexport prefix bindir sharedir sysconfdir
24386470930SIngo Molnar
244cc835752SJamie IlesCC = $(CROSS_COMPILE)gcc
245cc835752SJamie IlesAR = $(CROSS_COMPILE)ar
24686470930SIngo MolnarRM = rm -f
24786470930SIngo MolnarTAR = tar
24886470930SIngo MolnarFIND = find
24986470930SIngo MolnarINSTALL = install
25086470930SIngo MolnarRPMBUILD = rpmbuild
25186470930SIngo MolnarPTHREAD_LIBS = -lpthread
25286470930SIngo Molnar
25386470930SIngo Molnar# sparse is architecture-neutral, which means that we need to tell it
25486470930SIngo Molnar# explicitly what architecture to check for. Fix this up for yours..
25586470930SIngo MolnarSPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
25686470930SIngo Molnar
25783039518SArnaldo Carvalho de Meloifeq ($(V), 2)
25883039518SArnaldo Carvalho de Melo	QUIET_STDERR = ">/dev/null"
25983039518SArnaldo Carvalho de Meloelse
26083039518SArnaldo Carvalho de Melo	QUIET_STDERR = ">/dev/null 2>&1"
26183039518SArnaldo Carvalho de Meloendif
26283039518SArnaldo Carvalho de Melo
2631703f2c3SArnaldo Carvalho de MeloBITBUCKET = "/dev/null"
2641703f2c3SArnaldo Carvalho de Melo
2651703f2c3SArnaldo Carvalho de Meloifneq ($(shell sh -c "(echo '\#include <stdio.h>'; echo 'int main(void) { return puts(\"hi\"); }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y)
2661703f2c3SArnaldo Carvalho de Melo	BITBUCKET = .perf.dev.null
2671703f2c3SArnaldo Carvalho de Meloendif
2681703f2c3SArnaldo Carvalho de Melo
2691703f2c3SArnaldo Carvalho de Meloifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y)
2705d7bdab7SMichael Cree  CFLAGS := $(CFLAGS) -fstack-protector-all
2715d7bdab7SMichael Creeendif
27286470930SIngo Molnar
27386470930SIngo Molnar
27486470930SIngo Molnar### --- END CONFIGURATION SECTION ---
27586470930SIngo Molnar
27686470930SIngo Molnar# Those must not be GNU-specific; they are shared with perl/ which may
27786470930SIngo Molnar# be built by a different compiler. (Note that this is an artifact now
27886470930SIngo Molnar# but it still might be nice to keep that distinction.)
27943cbcd8aSArnaldo Carvalho de MeloBASIC_CFLAGS = -Iutil/include
28086470930SIngo MolnarBASIC_LDFLAGS =
28186470930SIngo Molnar
28286470930SIngo Molnar# Guard against environment variables
28386470930SIngo MolnarBUILTIN_OBJS =
28486470930SIngo MolnarBUILT_INS =
28586470930SIngo MolnarCOMPAT_CFLAGS =
28686470930SIngo MolnarCOMPAT_OBJS =
28786470930SIngo MolnarLIB_H =
28886470930SIngo MolnarLIB_OBJS =
28986470930SIngo MolnarSCRIPT_PERL =
29086470930SIngo MolnarSCRIPT_SH =
29186470930SIngo MolnarTEST_PROGRAMS =
29286470930SIngo Molnar
2932c585174SArnaldo Carvalho de MeloSCRIPT_SH += perf-archive.sh
29486470930SIngo Molnar
29586470930SIngo Molnar#
29686470930SIngo Molnar# No Perl scripts right now:
29786470930SIngo Molnar#
29886470930SIngo Molnar
29986470930SIngo Molnar# SCRIPT_PERL += perf-add--interactive.perl
30086470930SIngo Molnar
30186470930SIngo MolnarSCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
30286470930SIngo Molnar	  $(patsubst %.perl,%,$(SCRIPT_PERL))
30386470930SIngo Molnar
30486470930SIngo Molnar# Empty...
30586470930SIngo MolnarEXTRA_PROGRAMS =
30686470930SIngo Molnar
30786470930SIngo Molnar# ... and all the rest that could be moved out of bindir to perfexecdir
30886470930SIngo MolnarPROGRAMS += $(EXTRA_PROGRAMS)
30986470930SIngo Molnar
31086470930SIngo Molnar#
31186470930SIngo Molnar# Single 'perf' binary right now:
31286470930SIngo Molnar#
31386470930SIngo MolnarPROGRAMS += perf
31486470930SIngo Molnar
31586470930SIngo Molnar# List built-in command $C whose implementation cmd_$C() is not in
31686470930SIngo Molnar# builtin-$C.o but is linked in as part of some other command.
31786470930SIngo Molnar#
31886470930SIngo Molnar
31986470930SIngo Molnar# what 'all' will build and 'install' will install, in perfexecdir
32086470930SIngo MolnarALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
32186470930SIngo Molnar
32286470930SIngo Molnar# what 'all' will build but not install in perfexecdir
32386470930SIngo MolnarOTHER_PROGRAMS = perf$X
32486470930SIngo Molnar
32586470930SIngo Molnar# Set paths to tools early so that they can be used for version tests.
32686470930SIngo Molnarifndef SHELL_PATH
32786470930SIngo Molnar	SHELL_PATH = /bin/sh
32886470930SIngo Molnarendif
32986470930SIngo Molnarifndef PERL_PATH
33086470930SIngo Molnar	PERL_PATH = /usr/bin/perl
33186470930SIngo Molnarendif
33286470930SIngo Molnar
33386470930SIngo Molnarexport PERL_PATH
33486470930SIngo Molnar
33586470930SIngo MolnarLIB_FILE=libperf.a
33686470930SIngo Molnar
337cdd6c482SIngo MolnarLIB_H += ../../include/linux/perf_event.h
33843cbcd8aSArnaldo Carvalho de MeloLIB_H += ../../include/linux/rbtree.h
3395da50258SArnaldo Carvalho de MeloLIB_H += ../../include/linux/list.h
34018e97e06SHitoshi MitakeLIB_H += ../../include/linux/hash.h
3419769833bSMasami HiramatsuLIB_H += ../../include/linux/stringify.h
34279b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/bitmap.h
34379b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/bitops.h
34479b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/compiler.h
34579b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/ctype.h
34679b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/kernel.h
3475da50258SArnaldo Carvalho de MeloLIB_H += util/include/linux/list.h
34879b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/module.h
34979b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/poison.h
35079b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/prefetch.h
35179b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/rbtree.h
35220639c15SArnaldo Carvalho de MeloLIB_H += util/include/linux/string.h
35379b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/linux/types.h
35479b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/asm/asm-offsets.h
35579b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/asm/bitops.h
356049ae80bSArnaldo Carvalho de MeloLIB_H += util/include/asm/bug.h
35779b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/asm/byteorder.h
35879b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/asm/swab.h
35979b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/asm/system.h
36079b9ad36SArnaldo Carvalho de MeloLIB_H += util/include/asm/uaccess.h
36186470930SIngo MolnarLIB_H += perf.h
362049ae80bSArnaldo Carvalho de MeloLIB_H += util/cache.h
363049ae80bSArnaldo Carvalho de MeloLIB_H += util/callchain.h
3647b2567c1SArnaldo Carvalho de MeloLIB_H += util/build-id.h
365049ae80bSArnaldo Carvalho de MeloLIB_H += util/debug.h
366afe61f67SClark WilliamsLIB_H += util/debugfs.h
367ec218fc4SArnaldo Carvalho de MeloLIB_H += util/event.h
368049ae80bSArnaldo Carvalho de MeloLIB_H += util/exec_cmd.h
3697c6a1c65SPeter ZijlstraLIB_H += util/types.h
37086470930SIngo MolnarLIB_H += util/levenshtein.h
3714a58e611SArnaldo Carvalho de MeloLIB_H += util/map.h
37286470930SIngo MolnarLIB_H += util/parse-options.h
37386470930SIngo MolnarLIB_H += util/parse-events.h
37486470930SIngo MolnarLIB_H += util/quote.h
37586470930SIngo MolnarLIB_H += util/util.h
37694c744b6SArnaldo Carvalho de MeloLIB_H += util/header.h
37786470930SIngo MolnarLIB_H += util/help.h
37894c744b6SArnaldo Carvalho de MeloLIB_H += util/session.h
37986470930SIngo MolnarLIB_H += util/strbuf.h
38086470930SIngo MolnarLIB_H += util/string.h
38125903407SArnaldo Carvalho de MeloLIB_H += util/strlist.h
382049ae80bSArnaldo Carvalho de MeloLIB_H += util/svghelper.h
38386470930SIngo MolnarLIB_H += util/run-command.h
38486470930SIngo MolnarLIB_H += util/sigchain.h
38586470930SIngo MolnarLIB_H += util/symbol.h
38686470930SIngo MolnarLIB_H += util/color.h
3878d513270SBrice GoglinLIB_H += util/values.h
388dd68ada2SJohn KacurLIB_H += util/sort.h
3893d1d07ecSJohn KacurLIB_H += util/hist.h
3901b46cddfSArnaldo Carvalho de MeloLIB_H += util/thread.h
391049ae80bSArnaldo Carvalho de MeloLIB_H += util/trace-event.h
39257d250dfSMasami HiramatsuLIB_H += util/probe-finder.h
39350656eecSMasami HiramatsuLIB_H += util/probe-event.h
394a12b51c4SPaul MackerrasLIB_H += util/cpumap.h
39586470930SIngo Molnar
39686470930SIngo MolnarLIB_OBJS += util/abspath.o
39786470930SIngo MolnarLIB_OBJS += util/alias.o
3987b2567c1SArnaldo Carvalho de MeloLIB_OBJS += util/build-id.o
39986470930SIngo MolnarLIB_OBJS += util/config.o
40086470930SIngo MolnarLIB_OBJS += util/ctype.o
401afe61f67SClark WilliamsLIB_OBJS += util/debugfs.o
40286470930SIngo MolnarLIB_OBJS += util/environment.o
403234fbbf5SArnaldo Carvalho de MeloLIB_OBJS += util/event.o
40486470930SIngo MolnarLIB_OBJS += util/exec_cmd.o
40586470930SIngo MolnarLIB_OBJS += util/help.o
40686470930SIngo MolnarLIB_OBJS += util/levenshtein.o
40786470930SIngo MolnarLIB_OBJS += util/parse-options.o
40886470930SIngo MolnarLIB_OBJS += util/parse-events.o
40986470930SIngo MolnarLIB_OBJS += util/path.o
41086470930SIngo MolnarLIB_OBJS += util/rbtree.o
4115a116dd2SFrederic WeisbeckerLIB_OBJS += util/bitmap.o
4125a116dd2SFrederic WeisbeckerLIB_OBJS += util/hweight.o
4135a116dd2SFrederic WeisbeckerLIB_OBJS += util/find_next_bit.o
41486470930SIngo MolnarLIB_OBJS += util/run-command.o
41586470930SIngo MolnarLIB_OBJS += util/quote.o
41686470930SIngo MolnarLIB_OBJS += util/strbuf.o
41786470930SIngo MolnarLIB_OBJS += util/string.o
41825903407SArnaldo Carvalho de MeloLIB_OBJS += util/strlist.o
41986470930SIngo MolnarLIB_OBJS += util/usage.o
42086470930SIngo MolnarLIB_OBJS += util/wrapper.o
42186470930SIngo MolnarLIB_OBJS += util/sigchain.o
42286470930SIngo MolnarLIB_OBJS += util/symbol.o
42386470930SIngo MolnarLIB_OBJS += util/color.o
42486470930SIngo MolnarLIB_OBJS += util/pager.o
4257c6a1c65SPeter ZijlstraLIB_OBJS += util/header.o
4268cb76d99SFrederic WeisbeckerLIB_OBJS += util/callchain.o
4278d513270SBrice GoglinLIB_OBJS += util/values.o
428cd84c2acSFrederic WeisbeckerLIB_OBJS += util/debug.o
42966e274f3SFrederic WeisbeckerLIB_OBJS += util/map.o
43094c744b6SArnaldo Carvalho de MeloLIB_OBJS += util/session.o
4316baa0a5aSFrederic WeisbeckerLIB_OBJS += util/thread.o
4325f9c39dcSFrederic WeisbeckerLIB_OBJS += util/trace-event-parse.o
4335f9c39dcSFrederic WeisbeckerLIB_OBJS += util/trace-event-read.o
4345f9c39dcSFrederic WeisbeckerLIB_OBJS += util/trace-event-info.o
43582d156cdSTom ZanussiLIB_OBJS += util/trace-event-scripting.o
436f48d55ceSArjan van de VenLIB_OBJS += util/svghelper.o
437dd68ada2SJohn KacurLIB_OBJS += util/sort.o
4383d1d07ecSJohn KacurLIB_OBJS += util/hist.o
43950656eecSMasami HiramatsuLIB_OBJS += util/probe-event.o
4404cf40131SArnaldo Carvalho de MeloLIB_OBJS += util/util.o
441a12b51c4SPaul MackerrasLIB_OBJS += util/cpumap.o
44286470930SIngo Molnar
44386470930SIngo MolnarBUILTIN_OBJS += builtin-annotate.o
444bfde82efSHitoshi Mitake
445bfde82efSHitoshi MitakeBUILTIN_OBJS += builtin-bench.o
446bfde82efSHitoshi Mitake
447bfde82efSHitoshi Mitake# Benchmark modules
448bfde82efSHitoshi MitakeBUILTIN_OBJS += bench/sched-messaging.o
449bfde82efSHitoshi MitakeBUILTIN_OBJS += bench/sched-pipe.o
450827f3b49SHitoshi MitakeBUILTIN_OBJS += bench/mem-memcpy.o
451bfde82efSHitoshi Mitake
45286a9eee0SArnaldo Carvalho de MeloBUILTIN_OBJS += builtin-diff.o
45386470930SIngo MolnarBUILTIN_OBJS += builtin-help.o
4540a02ad93SIngo MolnarBUILTIN_OBJS += builtin-sched.o
455c34984b2SArnaldo Carvalho de MeloBUILTIN_OBJS += builtin-buildid-list.o
456ef12a141SArnaldo Carvalho de MeloBUILTIN_OBJS += builtin-buildid-cache.o
45786470930SIngo MolnarBUILTIN_OBJS += builtin-list.o
45886470930SIngo MolnarBUILTIN_OBJS += builtin-record.o
45986470930SIngo MolnarBUILTIN_OBJS += builtin-report.o
46086470930SIngo MolnarBUILTIN_OBJS += builtin-stat.o
46110274989SArjan van de VenBUILTIN_OBJS += builtin-timechart.o
46286470930SIngo MolnarBUILTIN_OBJS += builtin-top.o
4635f9c39dcSFrederic WeisbeckerBUILTIN_OBJS += builtin-trace.o
46423e8ec0dSMasami HiramatsuBUILTIN_OBJS += builtin-probe.o
465ba77c9e1SLi ZefanBUILTIN_OBJS += builtin-kmem.o
4669b5e350cSHitoshi MitakeBUILTIN_OBJS += builtin-lock.o
46786470930SIngo Molnar
46886470930SIngo MolnarPERFLIBS = $(LIB_FILE)
46986470930SIngo Molnar
47086470930SIngo Molnar#
47186470930SIngo Molnar# Platform specific tweaks
47286470930SIngo Molnar#
47386470930SIngo Molnar
47486470930SIngo Molnar# We choose to avoid "if .. else if .. else .. endif endif"
47586470930SIngo Molnar# because maintaining the nesting to match is a pain.  If
47686470930SIngo Molnar# we had "elif" things would have been much nicer...
47786470930SIngo Molnar
47886470930SIngo Molnar-include config.mak.autogen
47986470930SIngo Molnar-include config.mak
48086470930SIngo Molnar
48186470930SIngo Molnarifeq ($(uname_S),Darwin)
48286470930SIngo Molnar	ifndef NO_FINK
48386470930SIngo Molnar		ifeq ($(shell test -d /sw/lib && echo y),y)
48486470930SIngo Molnar			BASIC_CFLAGS += -I/sw/include
48586470930SIngo Molnar			BASIC_LDFLAGS += -L/sw/lib
48686470930SIngo Molnar		endif
48786470930SIngo Molnar	endif
48886470930SIngo Molnar	ifndef NO_DARWIN_PORTS
48986470930SIngo Molnar		ifeq ($(shell test -d /opt/local/lib && echo y),y)
49086470930SIngo Molnar			BASIC_CFLAGS += -I/opt/local/include
49186470930SIngo Molnar			BASIC_LDFLAGS += -L/opt/local/lib
49286470930SIngo Molnar		endif
49386470930SIngo Molnar	endif
49486470930SIngo Molnar	PTHREAD_LIBS =
49586470930SIngo Molnarendif
49686470930SIngo Molnar
4971703f2c3SArnaldo Carvalho de Meloifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
4981703f2c3SArnaldo Carvalho de Meloifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
499b197c7efSMichael S. Tsirkin	msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
5001abc7f55SRandy Dunlapendif
5011abc7f55SRandy Dunlap
5021703f2c3SArnaldo Carvalho de Melo	ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
50384087126SMarti Raudsepp		BASIC_CFLAGS += -DLIBELF_NO_MMAP
50484087126SMarti Raudsepp	endif
50584087126SMarti Raudseppelse
50655621ccfSIngo Molnar	msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
5079424edc2SPeter Zijlstraendif
5089424edc2SPeter Zijlstra
509804b3606SMasami Hiramatsuifneq ($(shell sh -c "(echo '\#include <dwarf.h>'; echo '\#include <libdw.h>'; echo 'int main(void) { Dwarf *dbg; dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/elfutils -ldw -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
510804b3606SMasami Hiramatsu	msg := $(warning No libdw.h found or old libdw.h found, disables dwarf support. Please install elfutils-devel/elfutils-dev);
5114ea42b18SMasami Hiramatsuelse
512*ca721e45SMasami Hiramatsuifndef NO_DWARF
5134b4da7f7SMasami Hiramatsu	BASIC_CFLAGS += -I/usr/include/elfutils -DDWARF_SUPPORT
514804b3606SMasami Hiramatsu	EXTLIBS += -lelf -ldw
5154ea42b18SMasami Hiramatsu	LIB_OBJS += util/probe-finder.o
5164ea42b18SMasami Hiramatsuendif
517*ca721e45SMasami Hiramatsuendif
5184ea42b18SMasami Hiramatsu
519f9224c5cSArnaldo Carvalho de Meloifneq ($(shell sh -c "(echo '\#include <newt.h>'; echo 'int main(void) { newtInit(); newtCls(); return newtFinished(); }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -lnewt -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
520f9224c5cSArnaldo Carvalho de Melo	msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev);
521f9224c5cSArnaldo Carvalho de Melo	BASIC_CFLAGS += -DNO_NEWT_SUPPORT
522f9224c5cSArnaldo Carvalho de Meloelse
523f9224c5cSArnaldo Carvalho de Melo	EXTLIBS += -lnewt
524f9224c5cSArnaldo Carvalho de Melo	LIB_OBJS += util/newt.o
525f9224c5cSArnaldo Carvalho de Meloendif
526f9224c5cSArnaldo Carvalho de Melo
527cc835752SJamie Ilesifndef NO_LIBPERL
528f8be4231STom ZanussiPERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null`
529f8be4231STom ZanussiPERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
530cc835752SJamie Ilesendif
53116c632deSTom Zanussi
5321703f2c3SArnaldo Carvalho de Meloifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o $(BITBUCKET) $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y)
53316c632deSTom Zanussi	BASIC_CFLAGS += -DNO_LIBPERL
53416c632deSTom Zanussielse
53516c632deSTom Zanussi	ALL_LDFLAGS += $(PERL_EMBED_LDOPTS)
53682d156cdSTom Zanussi	LIB_OBJS += util/scripting-engines/trace-event-perl.o
537d1b93772STom Zanussi	LIB_OBJS += scripts/perl/Perf-Trace-Util/Context.o
53816c632deSTom Zanussiendif
53916c632deSTom Zanussi
5407e4b21b8STom Zanussiifndef NO_LIBPYTHON
5417e4b21b8STom ZanussiPYTHON_EMBED_LDOPTS = `python-config --ldflags 2>/dev/null`
5427e4b21b8STom ZanussiPYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
5437e4b21b8STom Zanussiendif
5447e4b21b8STom Zanussi
5457e4b21b8STom Zanussiifneq ($(shell sh -c "(echo '\#include <Python.h>'; echo 'int main(void) { Py_Initialize(); return 0; }') | $(CC) -x c - $(PYTHON_EMBED_CCOPTS) -o /dev/null $(PYTHON_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y)
5467e4b21b8STom Zanussi	BASIC_CFLAGS += -DNO_LIBPYTHON
5477e4b21b8STom Zanussielse
5487e4b21b8STom Zanussi	ALL_LDFLAGS += $(PYTHON_EMBED_LDOPTS)
5497e4b21b8STom Zanussi	LIB_OBJS += util/scripting-engines/trace-event-python.o
5507e4b21b8STom Zanussi	LIB_OBJS += scripts/python/Perf-Trace-Util/Context.o
5517e4b21b8STom Zanussiendif
5527e4b21b8STom Zanussi
5532cdbc46dSPeter Zijlstraifdef NO_DEMANGLE
5542cdbc46dSPeter Zijlstra	BASIC_CFLAGS += -DNO_DEMANGLE
5552cdbc46dSPeter Zijlstraelse
5561703f2c3SArnaldo Carvalho de Melo	has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y")
5572cdbc46dSPeter Zijlstra
5582cdbc46dSPeter Zijlstra	ifeq ($(has_bfd),y)
5592cdbc46dSPeter Zijlstra		EXTLIBS += -lbfd
560247648e3SArnaldo Carvalho de Melo	else
5611703f2c3SArnaldo Carvalho de Melo		has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y")
562247648e3SArnaldo Carvalho de Melo		ifeq ($(has_bfd_iberty),y)
5632cdbc46dSPeter Zijlstra			EXTLIBS += -lbfd -liberty
564247648e3SArnaldo Carvalho de Melo		else
5651703f2c3SArnaldo Carvalho de Melo			has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y")
566247648e3SArnaldo Carvalho de Melo			ifeq ($(has_bfd_iberty_z),y)
567183f3b08SMike Galbraith				EXTLIBS += -lbfd -liberty -lz
5682cdbc46dSPeter Zijlstra			else
5691703f2c3SArnaldo Carvalho de Melo				has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y")
570247648e3SArnaldo Carvalho de Melo				ifeq ($(has_cplus_demangle),y)
571247648e3SArnaldo Carvalho de Melo					EXTLIBS += -liberty
572247648e3SArnaldo Carvalho de Melo					BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
573247648e3SArnaldo Carvalho de Melo				else
574b197c7efSMichael S. Tsirkin					msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
5752cdbc46dSPeter Zijlstra					BASIC_CFLAGS += -DNO_DEMANGLE
5762cdbc46dSPeter Zijlstra				endif
5772cdbc46dSPeter Zijlstra			endif
578247648e3SArnaldo Carvalho de Melo		endif
579247648e3SArnaldo Carvalho de Melo	endif
580247648e3SArnaldo Carvalho de Meloendif
5812cdbc46dSPeter Zijlstra
58286470930SIngo Molnarifndef CC_LD_DYNPATH
58386470930SIngo Molnar	ifdef NO_R_TO_GCC_LINKER
58486470930SIngo Molnar		# Some gcc does not accept and pass -R to the linker to specify
58586470930SIngo Molnar		# the runtime dynamic library path.
58686470930SIngo Molnar		CC_LD_DYNPATH = -Wl,-rpath,
58786470930SIngo Molnar	else
58886470930SIngo Molnar		CC_LD_DYNPATH = -R
58986470930SIngo Molnar	endif
59086470930SIngo Molnarendif
59186470930SIngo Molnar
59286470930SIngo Molnarifdef NEEDS_SOCKET
59386470930SIngo Molnar	EXTLIBS += -lsocket
59486470930SIngo Molnarendif
59586470930SIngo Molnarifdef NEEDS_NSL
59686470930SIngo Molnar	EXTLIBS += -lnsl
59786470930SIngo Molnarendif
59886470930SIngo Molnarifdef NO_D_TYPE_IN_DIRENT
59986470930SIngo Molnar	BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
60086470930SIngo Molnarendif
60186470930SIngo Molnarifdef NO_D_INO_IN_DIRENT
60286470930SIngo Molnar	BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
60386470930SIngo Molnarendif
60486470930SIngo Molnarifdef NO_ST_BLOCKS_IN_STRUCT_STAT
60586470930SIngo Molnar	BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
60686470930SIngo Molnarendif
60786470930SIngo Molnarifdef USE_NSEC
60886470930SIngo Molnar	BASIC_CFLAGS += -DUSE_NSEC
60986470930SIngo Molnarendif
61086470930SIngo Molnarifdef USE_ST_TIMESPEC
61186470930SIngo Molnar	BASIC_CFLAGS += -DUSE_ST_TIMESPEC
61286470930SIngo Molnarendif
61386470930SIngo Molnarifdef NO_NSEC
61486470930SIngo Molnar	BASIC_CFLAGS += -DNO_NSEC
61586470930SIngo Molnarendif
61686470930SIngo Molnarifdef NO_C99_FORMAT
61786470930SIngo Molnar	BASIC_CFLAGS += -DNO_C99_FORMAT
61886470930SIngo Molnarendif
61986470930SIngo Molnarifdef SNPRINTF_RETURNS_BOGUS
62086470930SIngo Molnar	COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
62186470930SIngo Molnar	COMPAT_OBJS += compat/snprintf.o
62286470930SIngo Molnarendif
62386470930SIngo Molnarifdef FREAD_READS_DIRECTORIES
62486470930SIngo Molnar	COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
62586470930SIngo Molnar	COMPAT_OBJS += compat/fopen.o
62686470930SIngo Molnarendif
62786470930SIngo Molnarifdef NO_SYMLINK_HEAD
62886470930SIngo Molnar	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
62986470930SIngo Molnarendif
63086470930SIngo Molnarifdef NO_STRCASESTR
63186470930SIngo Molnar	COMPAT_CFLAGS += -DNO_STRCASESTR
63286470930SIngo Molnar	COMPAT_OBJS += compat/strcasestr.o
63386470930SIngo Molnarendif
63486470930SIngo Molnarifdef NO_STRTOUMAX
63586470930SIngo Molnar	COMPAT_CFLAGS += -DNO_STRTOUMAX
63686470930SIngo Molnar	COMPAT_OBJS += compat/strtoumax.o
63786470930SIngo Molnarendif
63886470930SIngo Molnarifdef NO_STRTOULL
63986470930SIngo Molnar	COMPAT_CFLAGS += -DNO_STRTOULL
64086470930SIngo Molnarendif
64186470930SIngo Molnarifdef NO_SETENV
64286470930SIngo Molnar	COMPAT_CFLAGS += -DNO_SETENV
64386470930SIngo Molnar	COMPAT_OBJS += compat/setenv.o
64486470930SIngo Molnarendif
64586470930SIngo Molnarifdef NO_MKDTEMP
64686470930SIngo Molnar	COMPAT_CFLAGS += -DNO_MKDTEMP
64786470930SIngo Molnar	COMPAT_OBJS += compat/mkdtemp.o
64886470930SIngo Molnarendif
64986470930SIngo Molnarifdef NO_UNSETENV
65086470930SIngo Molnar	COMPAT_CFLAGS += -DNO_UNSETENV
65186470930SIngo Molnar	COMPAT_OBJS += compat/unsetenv.o
65286470930SIngo Molnarendif
65386470930SIngo Molnarifdef NO_SYS_SELECT_H
65486470930SIngo Molnar	BASIC_CFLAGS += -DNO_SYS_SELECT_H
65586470930SIngo Molnarendif
65686470930SIngo Molnarifdef NO_MMAP
65786470930SIngo Molnar	COMPAT_CFLAGS += -DNO_MMAP
65886470930SIngo Molnar	COMPAT_OBJS += compat/mmap.o
65986470930SIngo Molnarelse
66086470930SIngo Molnar	ifdef USE_WIN32_MMAP
66186470930SIngo Molnar		COMPAT_CFLAGS += -DUSE_WIN32_MMAP
66286470930SIngo Molnar		COMPAT_OBJS += compat/win32mmap.o
66386470930SIngo Molnar	endif
66486470930SIngo Molnarendif
66586470930SIngo Molnarifdef NO_PREAD
66686470930SIngo Molnar	COMPAT_CFLAGS += -DNO_PREAD
66786470930SIngo Molnar	COMPAT_OBJS += compat/pread.o
66886470930SIngo Molnarendif
66986470930SIngo Molnarifdef NO_FAST_WORKING_DIRECTORY
67086470930SIngo Molnar	BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
67186470930SIngo Molnarendif
67286470930SIngo Molnarifdef NO_TRUSTABLE_FILEMODE
67386470930SIngo Molnar	BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
67486470930SIngo Molnarendif
67586470930SIngo Molnarifdef NO_IPV6
67686470930SIngo Molnar	BASIC_CFLAGS += -DNO_IPV6
67786470930SIngo Molnarendif
67886470930SIngo Molnarifdef NO_UINTMAX_T
67986470930SIngo Molnar	BASIC_CFLAGS += -Duintmax_t=uint32_t
68086470930SIngo Molnarendif
68186470930SIngo Molnarifdef NO_SOCKADDR_STORAGE
68286470930SIngo Molnarifdef NO_IPV6
68386470930SIngo Molnar	BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
68486470930SIngo Molnarelse
68586470930SIngo Molnar	BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
68686470930SIngo Molnarendif
68786470930SIngo Molnarendif
68886470930SIngo Molnarifdef NO_INET_NTOP
68986470930SIngo Molnar	LIB_OBJS += compat/inet_ntop.o
69086470930SIngo Molnarendif
69186470930SIngo Molnarifdef NO_INET_PTON
69286470930SIngo Molnar	LIB_OBJS += compat/inet_pton.o
69386470930SIngo Molnarendif
69486470930SIngo Molnar
69586470930SIngo Molnarifdef NO_ICONV
69686470930SIngo Molnar	BASIC_CFLAGS += -DNO_ICONV
69786470930SIngo Molnarendif
69886470930SIngo Molnar
69986470930SIngo Molnarifdef OLD_ICONV
70086470930SIngo Molnar	BASIC_CFLAGS += -DOLD_ICONV
70186470930SIngo Molnarendif
70286470930SIngo Molnar
70386470930SIngo Molnarifdef NO_DEFLATE_BOUND
70486470930SIngo Molnar	BASIC_CFLAGS += -DNO_DEFLATE_BOUND
70586470930SIngo Molnarendif
70686470930SIngo Molnar
70786470930SIngo Molnarifdef PPC_SHA1
70886470930SIngo Molnar	SHA1_HEADER = "ppc/sha1.h"
70986470930SIngo Molnar	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
71086470930SIngo Molnarelse
71186470930SIngo Molnarifdef ARM_SHA1
71286470930SIngo Molnar	SHA1_HEADER = "arm/sha1.h"
71386470930SIngo Molnar	LIB_OBJS += arm/sha1.o arm/sha1_arm.o
71486470930SIngo Molnarelse
71586470930SIngo Molnarifdef MOZILLA_SHA1
71686470930SIngo Molnar	SHA1_HEADER = "mozilla-sha1/sha1.h"
71786470930SIngo Molnar	LIB_OBJS += mozilla-sha1/sha1.o
71886470930SIngo Molnarelse
71986470930SIngo Molnar	SHA1_HEADER = <openssl/sha.h>
72086470930SIngo Molnar	EXTLIBS += $(LIB_4_CRYPTO)
72186470930SIngo Molnarendif
72286470930SIngo Molnarendif
72386470930SIngo Molnarendif
72486470930SIngo Molnarifdef NO_PERL_MAKEMAKER
72586470930SIngo Molnar	export NO_PERL_MAKEMAKER
72686470930SIngo Molnarendif
72786470930SIngo Molnarifdef NO_HSTRERROR
72886470930SIngo Molnar	COMPAT_CFLAGS += -DNO_HSTRERROR
72986470930SIngo Molnar	COMPAT_OBJS += compat/hstrerror.o
73086470930SIngo Molnarendif
73186470930SIngo Molnarifdef NO_MEMMEM
73286470930SIngo Molnar	COMPAT_CFLAGS += -DNO_MEMMEM
73386470930SIngo Molnar	COMPAT_OBJS += compat/memmem.o
73486470930SIngo Molnarendif
73586470930SIngo Molnarifdef INTERNAL_QSORT
73686470930SIngo Molnar	COMPAT_CFLAGS += -DINTERNAL_QSORT
73786470930SIngo Molnar	COMPAT_OBJS += compat/qsort.o
73886470930SIngo Molnarendif
73986470930SIngo Molnarifdef RUNTIME_PREFIX
74086470930SIngo Molnar	COMPAT_CFLAGS += -DRUNTIME_PREFIX
74186470930SIngo Molnarendif
74286470930SIngo Molnar
74386470930SIngo Molnarifdef DIR_HAS_BSD_GROUP_SEMANTICS
74486470930SIngo Molnar	COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
74586470930SIngo Molnarendif
74686470930SIngo Molnarifdef NO_EXTERNAL_GREP
74786470930SIngo Molnar	BASIC_CFLAGS += -DNO_EXTERNAL_GREP
74886470930SIngo Molnarendif
74986470930SIngo Molnar
75086470930SIngo Molnarifeq ($(PERL_PATH),)
75186470930SIngo MolnarNO_PERL=NoThanks
75286470930SIngo Molnarendif
75386470930SIngo Molnar
75486470930SIngo MolnarQUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
75586470930SIngo MolnarQUIET_SUBDIR1  =
75686470930SIngo Molnar
75786470930SIngo Molnarifneq ($(findstring $(MAKEFLAGS),w),w)
75886470930SIngo MolnarPRINT_DIR = --no-print-directory
75986470930SIngo Molnarelse # "make -w"
76086470930SIngo MolnarNO_SUBDIR = :
76186470930SIngo Molnarendif
76286470930SIngo Molnar
76386470930SIngo Molnarifneq ($(findstring $(MAKEFLAGS),s),s)
76486470930SIngo Molnarifndef V
76586470930SIngo Molnar	QUIET_CC       = @echo '   ' CC $@;
76686470930SIngo Molnar	QUIET_AR       = @echo '   ' AR $@;
76786470930SIngo Molnar	QUIET_LINK     = @echo '   ' LINK $@;
76886470930SIngo Molnar	QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
76986470930SIngo Molnar	QUIET_GEN      = @echo '   ' GEN $@;
77086470930SIngo Molnar	QUIET_SUBDIR0  = +@subdir=
77186470930SIngo Molnar	QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
77286470930SIngo Molnar			 $(MAKE) $(PRINT_DIR) -C $$subdir
77386470930SIngo Molnar	export V
77486470930SIngo Molnar	export QUIET_GEN
77586470930SIngo Molnar	export QUIET_BUILT_IN
77686470930SIngo Molnarendif
77786470930SIngo Molnarendif
77886470930SIngo Molnar
77986470930SIngo Molnarifdef ASCIIDOC8
78086470930SIngo Molnar	export ASCIIDOC8
78186470930SIngo Molnarendif
78286470930SIngo Molnar
78386470930SIngo Molnar# Shell quote (do not use $(call) to accommodate ancient setups);
78486470930SIngo Molnar
78586470930SIngo MolnarSHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
78686470930SIngo MolnarETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
78786470930SIngo Molnar
78886470930SIngo MolnarDESTDIR_SQ = $(subst ','\'',$(DESTDIR))
78986470930SIngo Molnarbindir_SQ = $(subst ','\'',$(bindir))
79086470930SIngo Molnarbindir_relative_SQ = $(subst ','\'',$(bindir_relative))
79186470930SIngo Molnarmandir_SQ = $(subst ','\'',$(mandir))
79286470930SIngo Molnarinfodir_SQ = $(subst ','\'',$(infodir))
79386470930SIngo Molnarperfexecdir_SQ = $(subst ','\'',$(perfexecdir))
79486470930SIngo Molnartemplate_dir_SQ = $(subst ','\'',$(template_dir))
79586470930SIngo Molnarhtmldir_SQ = $(subst ','\'',$(htmldir))
79686470930SIngo Molnarprefix_SQ = $(subst ','\'',$(prefix))
79786470930SIngo Molnar
79886470930SIngo MolnarSHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
79986470930SIngo MolnarPERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
80086470930SIngo Molnar
80186470930SIngo MolnarLIBS = $(PERFLIBS) $(EXTLIBS)
80286470930SIngo Molnar
80386470930SIngo MolnarBASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
80486470930SIngo Molnar	$(COMPAT_CFLAGS)
80586470930SIngo MolnarLIB_OBJS += $(COMPAT_OBJS)
80686470930SIngo Molnar
80786470930SIngo MolnarALL_CFLAGS += $(BASIC_CFLAGS)
80886470930SIngo MolnarALL_LDFLAGS += $(BASIC_LDFLAGS)
80986470930SIngo Molnar
81086470930SIngo Molnarexport TAR INSTALL DESTDIR SHELL_PATH
81186470930SIngo Molnar
81286470930SIngo Molnar
81386470930SIngo Molnar### Build rules
81486470930SIngo Molnar
81586470930SIngo MolnarSHELL = $(SHELL_PATH)
81686470930SIngo Molnar
8171703f2c3SArnaldo Carvalho de Meloall:: .perf.dev.null shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS
81886470930SIngo Molnarifneq (,$X)
81986470930SIngo Molnar	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
82086470930SIngo Molnarendif
82186470930SIngo Molnar
82286470930SIngo Molnarall::
82386470930SIngo Molnar
82486470930SIngo Molnarplease_set_SHELL_PATH_to_a_more_modern_shell:
82586470930SIngo Molnar	@$$(:)
82686470930SIngo Molnar
82786470930SIngo Molnarshell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
82886470930SIngo Molnar
82986470930SIngo Molnarstrip: $(PROGRAMS) perf$X
83086470930SIngo Molnar	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) perf$X
83186470930SIngo Molnar
83286470930SIngo Molnarperf.o: perf.c common-cmds.h PERF-CFLAGS
83386470930SIngo Molnar	$(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
83486470930SIngo Molnar		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
83586470930SIngo Molnar		$(ALL_CFLAGS) -c $(filter %.c,$^)
83686470930SIngo Molnar
83786470930SIngo Molnarperf$X: perf.o $(BUILTIN_OBJS) $(PERFLIBS)
83886470930SIngo Molnar	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ perf.o \
83986470930SIngo Molnar		$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
84086470930SIngo Molnar
84186470930SIngo Molnarbuiltin-help.o: builtin-help.c common-cmds.h PERF-CFLAGS
84286470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
84386470930SIngo Molnar		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
84486470930SIngo Molnar		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
84586470930SIngo Molnar		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
84686470930SIngo Molnar
84710274989SArjan van de Venbuiltin-timechart.o: builtin-timechart.c common-cmds.h PERF-CFLAGS
84810274989SArjan van de Ven	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
84910274989SArjan van de Ven		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
85010274989SArjan van de Ven		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
85110274989SArjan van de Ven		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
85210274989SArjan van de Ven
85386470930SIngo Molnar$(BUILT_INS): perf$X
85486470930SIngo Molnar	$(QUIET_BUILT_IN)$(RM) $@ && \
85586470930SIngo Molnar	ln perf$X $@ 2>/dev/null || \
85686470930SIngo Molnar	ln -s perf$X $@ 2>/dev/null || \
85786470930SIngo Molnar	cp perf$X $@
85886470930SIngo Molnar
85986470930SIngo Molnarcommon-cmds.h: util/generate-cmdlist.sh command-list.txt
86086470930SIngo Molnar
86186470930SIngo Molnarcommon-cmds.h: $(wildcard Documentation/perf-*.txt)
8621ad0560eSMulyadi Santosa	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
86386470930SIngo Molnar
86486470930SIngo Molnar$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
86586470930SIngo Molnar	$(QUIET_GEN)$(RM) $@ $@+ && \
86686470930SIngo Molnar	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
86786470930SIngo Molnar	    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
86886470930SIngo Molnar	    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
86986470930SIngo Molnar	    -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
87086470930SIngo Molnar	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
87186470930SIngo Molnar	    $@.sh >$@+ && \
87286470930SIngo Molnar	chmod +x $@+ && \
87386470930SIngo Molnar	mv $@+ $@
87486470930SIngo Molnar
87586470930SIngo Molnarconfigure: configure.ac
87686470930SIngo Molnar	$(QUIET_GEN)$(RM) $@ $<+ && \
87786470930SIngo Molnar	sed -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
87886470930SIngo Molnar	    $< > $<+ && \
87986470930SIngo Molnar	autoconf -o $@ $<+ && \
88086470930SIngo Molnar	$(RM) $<+
88186470930SIngo Molnar
88286470930SIngo Molnar# These can record PERF_VERSION
88386470930SIngo Molnarperf.o perf.spec \
88486470930SIngo Molnar	$(patsubst %.sh,%,$(SCRIPT_SH)) \
88586470930SIngo Molnar	$(patsubst %.perl,%,$(SCRIPT_PERL)) \
88686470930SIngo Molnar	: PERF-VERSION-FILE
88786470930SIngo Molnar
88886470930SIngo Molnar%.o: %.c PERF-CFLAGS
88986470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
89086470930SIngo Molnar%.s: %.c PERF-CFLAGS
89186470930SIngo Molnar	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
89286470930SIngo Molnar%.o: %.S
89386470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
89486470930SIngo Molnar
89586470930SIngo Molnarutil/exec_cmd.o: util/exec_cmd.c PERF-CFLAGS
89686470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
89786470930SIngo Molnar		'-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
89886470930SIngo Molnar		'-DBINDIR="$(bindir_relative_SQ)"' \
89986470930SIngo Molnar		'-DPREFIX="$(prefix_SQ)"' \
90086470930SIngo Molnar		$<
90186470930SIngo Molnar
90286470930SIngo Molnarbuiltin-init-db.o: builtin-init-db.c PERF-CFLAGS
90386470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_PERF_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
90486470930SIngo Molnar
90586470930SIngo Molnarutil/config.o: util/config.c PERF-CFLAGS
90686470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
90786470930SIngo Molnar
90843cbcd8aSArnaldo Carvalho de Meloutil/rbtree.o: ../../lib/rbtree.c PERF-CFLAGS
90943cbcd8aSArnaldo Carvalho de Melo	$(QUIET_CC)$(CC) -o util/rbtree.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
91043cbcd8aSArnaldo Carvalho de Melo
9115a116dd2SFrederic Weisbecker# some perf warning policies can't fit to lib/bitmap.c, eg: it warns about variable shadowing
9125a116dd2SFrederic Weisbecker# from <string.h> that comes from kernel headers wrapping.
9135a116dd2SFrederic WeisbeckerKBITMAP_FLAGS=`echo $(ALL_CFLAGS) | sed s/-Wshadow// | sed s/-Wswitch-default// | sed s/-Wextra//`
9145a116dd2SFrederic Weisbecker
9155a116dd2SFrederic Weisbeckerutil/bitmap.o: ../../lib/bitmap.c PERF-CFLAGS
9165a116dd2SFrederic Weisbecker	$(QUIET_CC)$(CC) -o util/bitmap.o -c $(KBITMAP_FLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
9175a116dd2SFrederic Weisbecker
9185a116dd2SFrederic Weisbeckerutil/hweight.o: ../../lib/hweight.c PERF-CFLAGS
9195a116dd2SFrederic Weisbecker	$(QUIET_CC)$(CC) -o util/hweight.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
9205a116dd2SFrederic Weisbecker
9215a116dd2SFrederic Weisbeckerutil/find_next_bit.o: ../../lib/find_next_bit.c PERF-CFLAGS
9225a116dd2SFrederic Weisbecker	$(QUIET_CC)$(CC) -o util/find_next_bit.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
9235a116dd2SFrederic Weisbecker
92482d156cdSTom Zanussiutil/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c PERF-CFLAGS
92582d156cdSTom Zanussi	$(QUIET_CC)$(CC) -o util/scripting-engines/trace-event-perl.o -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
92616c632deSTom Zanussi
927d1b93772STom Zanussiscripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c PERF-CFLAGS
928d1b93772STom Zanussi	$(QUIET_CC)$(CC) -o scripts/perl/Perf-Trace-Util/Context.o -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
929d1b93772STom Zanussi
9307e4b21b8STom Zanussiutil/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c PERF-CFLAGS
9317e4b21b8STom Zanussi	$(QUIET_CC)$(CC) -o util/scripting-engines/trace-event-python.o -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
9327e4b21b8STom Zanussi
9337e4b21b8STom Zanussiscripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c PERF-CFLAGS
9347e4b21b8STom Zanussi	$(QUIET_CC)$(CC) -o scripts/python/Perf-Trace-Util/Context.o -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
9357e4b21b8STom Zanussi
93686470930SIngo Molnarperf-%$X: %.o $(PERFLIBS)
93786470930SIngo Molnar	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
93886470930SIngo Molnar
93986470930SIngo Molnar$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
94086470930SIngo Molnar$(patsubst perf-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
94186470930SIngo Molnarbuiltin-revert.o wt-status.o: wt-status.h
94286470930SIngo Molnar
94386470930SIngo Molnar$(LIB_FILE): $(LIB_OBJS)
94486470930SIngo Molnar	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
94586470930SIngo Molnar
94686470930SIngo Molnardoc:
94786470930SIngo Molnar	$(MAKE) -C Documentation all
94886470930SIngo Molnar
94986470930SIngo Molnarman:
95086470930SIngo Molnar	$(MAKE) -C Documentation man
95186470930SIngo Molnar
95286470930SIngo Molnarhtml:
95386470930SIngo Molnar	$(MAKE) -C Documentation html
95486470930SIngo Molnar
95586470930SIngo Molnarinfo:
95686470930SIngo Molnar	$(MAKE) -C Documentation info
95786470930SIngo Molnar
95886470930SIngo Molnarpdf:
95986470930SIngo Molnar	$(MAKE) -C Documentation pdf
96086470930SIngo Molnar
96186470930SIngo MolnarTAGS:
96286470930SIngo Molnar	$(RM) TAGS
96386470930SIngo Molnar	$(FIND) . -name '*.[hcS]' -print | xargs etags -a
96486470930SIngo Molnar
96586470930SIngo Molnartags:
96686470930SIngo Molnar	$(RM) tags
96786470930SIngo Molnar	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
96886470930SIngo Molnar
96986470930SIngo Molnarcscope:
97086470930SIngo Molnar	$(RM) cscope*
97186470930SIngo Molnar	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
97286470930SIngo Molnar
97386470930SIngo Molnar### Detect prefix changes
97486470930SIngo MolnarTRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
97586470930SIngo Molnar             $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
97686470930SIngo Molnar
97786470930SIngo MolnarPERF-CFLAGS: .FORCE-PERF-CFLAGS
97886470930SIngo Molnar	@FLAGS='$(TRACK_CFLAGS)'; \
97986470930SIngo Molnar	    if test x"$$FLAGS" != x"`cat PERF-CFLAGS 2>/dev/null`" ; then \
98086470930SIngo Molnar		echo 1>&2 "    * new build flags or prefix"; \
98186470930SIngo Molnar		echo "$$FLAGS" >PERF-CFLAGS; \
98286470930SIngo Molnar            fi
98386470930SIngo Molnar
98486470930SIngo Molnar# We need to apply sq twice, once to protect from the shell
98586470930SIngo Molnar# that runs PERF-BUILD-OPTIONS, and then again to protect it
98686470930SIngo Molnar# and the first level quoting from the shell that runs "echo".
98786470930SIngo MolnarPERF-BUILD-OPTIONS: .FORCE-PERF-BUILD-OPTIONS
98886470930SIngo Molnar	@echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
98986470930SIngo Molnar	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
99086470930SIngo Molnar	@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
99186470930SIngo Molnar	@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
99286470930SIngo Molnar
99386470930SIngo Molnar### Testing rules
99486470930SIngo Molnar
99586470930SIngo Molnar#
99686470930SIngo Molnar# None right now:
99786470930SIngo Molnar#
99886470930SIngo Molnar# TEST_PROGRAMS += test-something$X
99986470930SIngo Molnar
100086470930SIngo Molnarall:: $(TEST_PROGRAMS)
100186470930SIngo Molnar
100286470930SIngo Molnar# GNU make supports exporting all variables by "export" without parameters.
100386470930SIngo Molnar# However, the environment gets quite big, and some programs have problems
100486470930SIngo Molnar# with that.
100586470930SIngo Molnar
100686470930SIngo Molnarexport NO_SVN_TESTS
100786470930SIngo Molnar
100886470930SIngo Molnarcheck: common-cmds.h
100986470930SIngo Molnar	if sparse; \
101086470930SIngo Molnar	then \
101186470930SIngo Molnar		for i in *.c */*.c; \
101286470930SIngo Molnar		do \
101386470930SIngo Molnar			sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
101486470930SIngo Molnar		done; \
101586470930SIngo Molnar	else \
101686470930SIngo Molnar		echo 2>&1 "Did you mean 'make test'?"; \
101786470930SIngo Molnar		exit 1; \
101886470930SIngo Molnar	fi
101986470930SIngo Molnar
102086470930SIngo Molnarremove-dashes:
102186470930SIngo Molnar	./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
102286470930SIngo Molnar
102386470930SIngo Molnar### Installation rules
102486470930SIngo Molnar
102586470930SIngo Molnarifneq ($(filter /%,$(firstword $(template_dir))),)
102686470930SIngo Molnartemplate_instdir = $(template_dir)
102786470930SIngo Molnarelse
102886470930SIngo Molnartemplate_instdir = $(prefix)/$(template_dir)
102986470930SIngo Molnarendif
103086470930SIngo Molnarexport template_instdir
103186470930SIngo Molnar
103286470930SIngo Molnarifneq ($(filter /%,$(firstword $(perfexecdir))),)
103386470930SIngo Molnarperfexec_instdir = $(perfexecdir)
103486470930SIngo Molnarelse
103586470930SIngo Molnarperfexec_instdir = $(prefix)/$(perfexecdir)
103686470930SIngo Molnarendif
103786470930SIngo Molnarperfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
103886470930SIngo Molnarexport perfexec_instdir
103986470930SIngo Molnar
104086470930SIngo Molnarinstall: all
104186470930SIngo Molnar	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
104286470930SIngo Molnar	$(INSTALL) perf$X '$(DESTDIR_SQ)$(bindir_SQ)'
1043bcefe12eSTom Zanussi	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
1044bcefe12eSTom Zanussi	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
1045d5526d8cSArnaldo Carvalho de Melo	$(INSTALL) perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
1046bcefe12eSTom Zanussi	$(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
1047bcefe12eSTom Zanussi	$(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
1048bcefe12eSTom Zanussi	$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
10497e4b21b8STom Zanussi	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
10504d161f03STom Zanussi	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
10517e4b21b8STom Zanussi	$(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
10524d161f03STom Zanussi	$(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
10534d161f03STom Zanussi	$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
105482d156cdSTom Zanussi
105586470930SIngo Molnarifdef BUILT_INS
105686470930SIngo Molnar	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
105786470930SIngo Molnar	$(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
105886470930SIngo Molnarifneq (,$X)
105986470930SIngo Molnar	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), $(RM) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$p';)
106086470930SIngo Molnarendif
106186470930SIngo Molnarendif
106286470930SIngo Molnar
106386470930SIngo Molnarinstall-doc:
106486470930SIngo Molnar	$(MAKE) -C Documentation install
106586470930SIngo Molnar
106686470930SIngo Molnarinstall-man:
106786470930SIngo Molnar	$(MAKE) -C Documentation install-man
106886470930SIngo Molnar
106986470930SIngo Molnarinstall-html:
107086470930SIngo Molnar	$(MAKE) -C Documentation install-html
107186470930SIngo Molnar
107286470930SIngo Molnarinstall-info:
107386470930SIngo Molnar	$(MAKE) -C Documentation install-info
107486470930SIngo Molnar
107586470930SIngo Molnarinstall-pdf:
107686470930SIngo Molnar	$(MAKE) -C Documentation install-pdf
107786470930SIngo Molnar
107886470930SIngo Molnarquick-install-doc:
107986470930SIngo Molnar	$(MAKE) -C Documentation quick-install
108086470930SIngo Molnar
108186470930SIngo Molnarquick-install-man:
108286470930SIngo Molnar	$(MAKE) -C Documentation quick-install-man
108386470930SIngo Molnar
108486470930SIngo Molnarquick-install-html:
108586470930SIngo Molnar	$(MAKE) -C Documentation quick-install-html
108686470930SIngo Molnar
108786470930SIngo Molnar
108886470930SIngo Molnar### Maintainer's dist rules
108986470930SIngo Molnar#
109086470930SIngo Molnar# None right now
109186470930SIngo Molnar#
109286470930SIngo Molnar#
109386470930SIngo Molnar# perf.spec: perf.spec.in
109486470930SIngo Molnar#	sed -e 's/@@VERSION@@/$(PERF_VERSION)/g' < $< > $@+
109586470930SIngo Molnar#	mv $@+ $@
109686470930SIngo Molnar#
109786470930SIngo Molnar# PERF_TARNAME=perf-$(PERF_VERSION)
109886470930SIngo Molnar# dist: perf.spec perf-archive$(X) configure
109986470930SIngo Molnar#	./perf-archive --format=tar \
110086470930SIngo Molnar#		--prefix=$(PERF_TARNAME)/ HEAD^{tree} > $(PERF_TARNAME).tar
110186470930SIngo Molnar#	@mkdir -p $(PERF_TARNAME)
110286470930SIngo Molnar#	@cp perf.spec configure $(PERF_TARNAME)
110386470930SIngo Molnar#	@echo $(PERF_VERSION) > $(PERF_TARNAME)/version
110486470930SIngo Molnar#	$(TAR) rf $(PERF_TARNAME).tar \
110586470930SIngo Molnar#		$(PERF_TARNAME)/perf.spec \
110686470930SIngo Molnar#		$(PERF_TARNAME)/configure \
110786470930SIngo Molnar#		$(PERF_TARNAME)/version
110886470930SIngo Molnar#	@$(RM) -r $(PERF_TARNAME)
110986470930SIngo Molnar#	gzip -f -9 $(PERF_TARNAME).tar
111086470930SIngo Molnar#
111186470930SIngo Molnar# htmldocs = perf-htmldocs-$(PERF_VERSION)
111286470930SIngo Molnar# manpages = perf-manpages-$(PERF_VERSION)
111386470930SIngo Molnar# dist-doc:
111486470930SIngo Molnar#	$(RM) -r .doc-tmp-dir
111586470930SIngo Molnar#	mkdir .doc-tmp-dir
111686470930SIngo Molnar#	$(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
111786470930SIngo Molnar#	cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
111886470930SIngo Molnar#	gzip -n -9 -f $(htmldocs).tar
111986470930SIngo Molnar#	:
112086470930SIngo Molnar#	$(RM) -r .doc-tmp-dir
112186470930SIngo Molnar#	mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
112286470930SIngo Molnar#	$(MAKE) -C Documentation DESTDIR=./ \
112386470930SIngo Molnar#		man1dir=../.doc-tmp-dir/man1 \
112486470930SIngo Molnar#		man5dir=../.doc-tmp-dir/man5 \
112586470930SIngo Molnar#		man7dir=../.doc-tmp-dir/man7 \
112686470930SIngo Molnar#		install
112786470930SIngo Molnar#	cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
112886470930SIngo Molnar#	gzip -n -9 -f $(manpages).tar
112986470930SIngo Molnar#	$(RM) -r .doc-tmp-dir
113086470930SIngo Molnar#
113186470930SIngo Molnar# rpm: dist
113286470930SIngo Molnar#	$(RPMBUILD) -ta $(PERF_TARNAME).tar.gz
113386470930SIngo Molnar
113486470930SIngo Molnar### Cleaning rules
113586470930SIngo Molnar
113686470930SIngo Molnardistclean: clean
113786470930SIngo Molnar#	$(RM) configure
113886470930SIngo Molnar
113986470930SIngo Molnarclean:
1140d1b93772STom Zanussi	$(RM) *.o */*.o */*/*.o */*/*/*.o $(LIB_FILE)
114186470930SIngo Molnar	$(RM) $(ALL_PROGRAMS) $(BUILT_INS) perf$X
114286470930SIngo Molnar	$(RM) $(TEST_PROGRAMS)
114386470930SIngo Molnar	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
114486470930SIngo Molnar	$(RM) -r autom4te.cache
114586470930SIngo Molnar	$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
114686470930SIngo Molnar	$(RM) -r $(PERF_TARNAME) .doc-tmp-dir
114786470930SIngo Molnar	$(RM) $(PERF_TARNAME).tar.gz perf-core_$(PERF_VERSION)-*.tar.gz
114886470930SIngo Molnar	$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
114986470930SIngo Molnar	$(MAKE) -C Documentation/ clean
115086470930SIngo Molnar	$(RM) PERF-VERSION-FILE PERF-CFLAGS PERF-BUILD-OPTIONS
115186470930SIngo Molnar
115286470930SIngo Molnar.PHONY: all install clean strip
115386470930SIngo Molnar.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
115486470930SIngo Molnar.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
115586470930SIngo Molnar.PHONY: .FORCE-PERF-BUILD-OPTIONS
115686470930SIngo Molnar
11571703f2c3SArnaldo Carvalho de Melo.perf.dev.null:
11581703f2c3SArnaldo Carvalho de Melo		touch .perf.dev.null
11591703f2c3SArnaldo Carvalho de Melo
11601703f2c3SArnaldo Carvalho de Melo.INTERMEDIATE:	.perf.dev.null
11611703f2c3SArnaldo Carvalho de Melo
116286470930SIngo Molnar### Make sure built-ins do not have dups and listed in perf.c
116386470930SIngo Molnar#
116486470930SIngo Molnarcheck-builtins::
116586470930SIngo Molnar	./check-builtins.sh
116686470930SIngo Molnar
116786470930SIngo Molnar### Test suite coverage testing
116886470930SIngo Molnar#
116986470930SIngo Molnar# None right now
117086470930SIngo Molnar#
117186470930SIngo Molnar# .PHONY: coverage coverage-clean coverage-build coverage-report
117286470930SIngo Molnar#
117386470930SIngo Molnar# coverage:
117486470930SIngo Molnar#	$(MAKE) coverage-build
117586470930SIngo Molnar#	$(MAKE) coverage-report
117686470930SIngo Molnar#
117786470930SIngo Molnar# coverage-clean:
117886470930SIngo Molnar#	rm -f *.gcda *.gcno
117986470930SIngo Molnar#
118086470930SIngo Molnar# COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
118186470930SIngo Molnar# COVERAGE_LDFLAGS = $(CFLAGS)  -O0 -lgcov
118286470930SIngo Molnar#
118386470930SIngo Molnar# coverage-build: coverage-clean
118486470930SIngo Molnar#	$(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
118586470930SIngo Molnar#	$(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
118686470930SIngo Molnar#		-j1 test
118786470930SIngo Molnar#
118886470930SIngo Molnar# coverage-report:
118986470930SIngo Molnar#	gcov -b *.c */*.c
119086470930SIngo Molnar#	grep '^function.*called 0 ' *.c.gcov */*.c.gcov \
119186470930SIngo Molnar#		| sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
119286470930SIngo Molnar#		| tee coverage-untested-functions
1193