xref: /linux/tools/perf/Makefile (revision 2cdbc46d7b2cb0acb68c3ecad93b000552121fa6)
186470930SIngo Molnar# The default target of this Makefile is...
286470930SIngo Molnarall::
386470930SIngo Molnar
486470930SIngo Molnar# Define V=1 to have a more verbose compile.
586470930SIngo Molnar#
686470930SIngo Molnar# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
786470930SIngo Molnar# or vsnprintf() return -1 instead of number of characters which would
886470930SIngo Molnar# have been written to the final string if enough space had been available.
986470930SIngo Molnar#
1086470930SIngo Molnar# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
1186470930SIngo Molnar# when attempting to read from an fopen'ed directory.
1286470930SIngo Molnar#
1386470930SIngo Molnar# Define NO_OPENSSL environment variable if you do not have OpenSSL.
1486470930SIngo Molnar# This also implies MOZILLA_SHA1.
1586470930SIngo Molnar#
1686470930SIngo Molnar# Define CURLDIR=/foo/bar if your curl header and library files are in
1786470930SIngo Molnar# /foo/bar/include and /foo/bar/lib directories.
1886470930SIngo Molnar#
1986470930SIngo Molnar# Define EXPATDIR=/foo/bar if your expat header and library files are in
2086470930SIngo Molnar# /foo/bar/include and /foo/bar/lib directories.
2186470930SIngo Molnar#
2286470930SIngo Molnar# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
2386470930SIngo Molnar#
2486470930SIngo Molnar# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
2586470930SIngo Molnar# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
2686470930SIngo Molnar#
2786470930SIngo Molnar# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
2886470930SIngo Molnar# do not support the 'size specifiers' introduced by C99, namely ll, hh,
2986470930SIngo Molnar# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
3086470930SIngo Molnar# some C compilers supported these specifiers prior to C99 as an extension.
3186470930SIngo Molnar#
3286470930SIngo Molnar# Define NO_STRCASESTR if you don't have strcasestr.
3386470930SIngo Molnar#
3486470930SIngo Molnar# Define NO_MEMMEM if you don't have memmem.
3586470930SIngo Molnar#
3686470930SIngo Molnar# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
3786470930SIngo Molnar# If your compiler also does not support long long or does not have
3886470930SIngo Molnar# strtoull, define NO_STRTOULL.
3986470930SIngo Molnar#
4086470930SIngo Molnar# Define NO_SETENV if you don't have setenv in the C library.
4186470930SIngo Molnar#
4286470930SIngo Molnar# Define NO_UNSETENV if you don't have unsetenv in the C library.
4386470930SIngo Molnar#
4486470930SIngo Molnar# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
4586470930SIngo Molnar#
4686470930SIngo Molnar# Define NO_SYS_SELECT_H if you don't have sys/select.h.
4786470930SIngo Molnar#
4886470930SIngo Molnar# Define NO_SYMLINK_HEAD if you never want .perf/HEAD to be a symbolic link.
4986470930SIngo Molnar# Enable it on Windows.  By default, symrefs are still used.
5086470930SIngo Molnar#
5186470930SIngo Molnar# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
5286470930SIngo Molnar# tests.  These tests take up a significant amount of the total test time
5386470930SIngo Molnar# but are not needed unless you plan to talk to SVN repos.
5486470930SIngo Molnar#
5586470930SIngo Molnar# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
5686470930SIngo Molnar# installed in /sw, but don't want PERF to link against any libraries
5786470930SIngo Molnar# installed there.  If defined you may specify your own (or Fink's)
5886470930SIngo Molnar# include directories and library directories by defining CFLAGS
5986470930SIngo Molnar# and LDFLAGS appropriately.
6086470930SIngo Molnar#
6186470930SIngo Molnar# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
6286470930SIngo Molnar# have DarwinPorts installed in /opt/local, but don't want PERF to
6386470930SIngo Molnar# link against any libraries installed there.  If defined you may
6486470930SIngo Molnar# specify your own (or DarwinPort's) include directories and
6586470930SIngo Molnar# library directories by defining CFLAGS and LDFLAGS appropriately.
6686470930SIngo Molnar#
6786470930SIngo Molnar# Define PPC_SHA1 environment variable when running make to make use of
6886470930SIngo Molnar# a bundled SHA1 routine optimized for PowerPC.
6986470930SIngo Molnar#
7086470930SIngo Molnar# Define ARM_SHA1 environment variable when running make to make use of
7186470930SIngo Molnar# a bundled SHA1 routine optimized for ARM.
7286470930SIngo Molnar#
7386470930SIngo Molnar# Define MOZILLA_SHA1 environment variable when running make to make use of
7486470930SIngo Molnar# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
7586470930SIngo Molnar# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
7686470930SIngo Molnar# choice) has very fast version optimized for i586.
7786470930SIngo Molnar#
7886470930SIngo Molnar# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
7986470930SIngo Molnar#
8086470930SIngo Molnar# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
8186470930SIngo Molnar#
8286470930SIngo Molnar# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
8386470930SIngo Molnar# Patrick Mauritz).
8486470930SIngo Molnar#
8586470930SIngo Molnar# Define NO_MMAP if you want to avoid mmap.
8686470930SIngo Molnar#
8786470930SIngo Molnar# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
8886470930SIngo Molnar#
8986470930SIngo Molnar# Define NO_PREAD if you have a problem with pread() system call (e.g.
9086470930SIngo Molnar# cygwin.dll before v1.5.22).
9186470930SIngo Molnar#
9286470930SIngo Molnar# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
9386470930SIngo Molnar# generally faster on your platform than accessing the working directory.
9486470930SIngo Molnar#
9586470930SIngo Molnar# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
9686470930SIngo Molnar# the executable mode bit, but doesn't really do so.
9786470930SIngo Molnar#
9886470930SIngo Molnar# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
9986470930SIngo Molnar#
10086470930SIngo Molnar# Define NO_SOCKADDR_STORAGE if your platform does not have struct
10186470930SIngo Molnar# sockaddr_storage.
10286470930SIngo Molnar#
10386470930SIngo Molnar# Define NO_ICONV if your libc does not properly support iconv.
10486470930SIngo Molnar#
10586470930SIngo Molnar# Define OLD_ICONV if your library has an old iconv(), where the second
10686470930SIngo Molnar# (input buffer pointer) parameter is declared with type (const char **).
10786470930SIngo Molnar#
10886470930SIngo Molnar# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
10986470930SIngo Molnar#
11086470930SIngo Molnar# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
11186470930SIngo Molnar# that tells runtime paths to dynamic libraries;
11286470930SIngo Molnar# "-Wl,-rpath=/path/lib" is used instead.
11386470930SIngo Molnar#
11486470930SIngo Molnar# Define USE_NSEC below if you want perf to care about sub-second file mtimes
11586470930SIngo Molnar# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
11686470930SIngo Molnar# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
11786470930SIngo Molnar# randomly break unless your underlying filesystem supports those sub-second
11886470930SIngo Molnar# times (my ext3 doesn't).
11986470930SIngo Molnar#
12086470930SIngo Molnar# Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
12186470930SIngo Molnar# "st_ctim"
12286470930SIngo Molnar#
12386470930SIngo Molnar# Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
12486470930SIngo Molnar# available.  This automatically turns USE_NSEC off.
12586470930SIngo Molnar#
12686470930SIngo Molnar# Define USE_STDEV below if you want perf to care about the underlying device
12786470930SIngo Molnar# change being considered an inode change from the update-index perspective.
12886470930SIngo Molnar#
12986470930SIngo Molnar# Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
13086470930SIngo Molnar# field that counts the on-disk footprint in 512-byte blocks.
13186470930SIngo Molnar#
13286470930SIngo Molnar# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
13386470930SIngo Molnar#
13486470930SIngo Molnar# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
13586470930SIngo Molnar#
13686470930SIngo Molnar# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
13786470930SIngo Molnar# MakeMaker (e.g. using ActiveState under Cygwin).
13886470930SIngo Molnar#
13986470930SIngo Molnar# Define NO_PERL if you do not want Perl scripts or libraries at all.
14086470930SIngo Molnar#
14186470930SIngo Molnar# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
14286470930SIngo Molnar# is a simplified version of the merge sort used in glibc. This is
14386470930SIngo Molnar# recommended if Git triggers O(n^2) behavior in your platform's qsort().
14486470930SIngo Molnar#
14586470930SIngo Molnar# Define NO_EXTERNAL_GREP if you don't want "perf grep" to ever call
14686470930SIngo Molnar# your external grep (e.g., if your system lacks grep, if its grep is
14786470930SIngo Molnar# broken, or spawning external process is slower than built-in grep perf has).
14886470930SIngo Molnar
14986470930SIngo MolnarPERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
15086470930SIngo Molnar	@$(SHELL_PATH) util/PERF-VERSION-GEN
15186470930SIngo Molnar-include PERF-VERSION-FILE
15286470930SIngo Molnar
15386470930SIngo Molnaruname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
15486470930SIngo Molnaruname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
15586470930SIngo Molnaruname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
15686470930SIngo Molnaruname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
15786470930SIngo Molnaruname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
15886470930SIngo Molnaruname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
15986470930SIngo Molnar
160e24a72c4SPaul Mackerras# If we're on a 64-bit kernel, use -m64
161e24a72c4SPaul Mackerrasifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
162e24a72c4SPaul Mackerras  M64 := -m64
163e24a72c4SPaul Mackerrasendif
164e24a72c4SPaul Mackerras
16586470930SIngo Molnar# CFLAGS and LDFLAGS are for the users to override from the command line.
16686470930SIngo Molnar
167f37a291cSIngo MolnarCFLAGS = $(M64) -ggdb3 -Wall -Wextra -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -Werror -O6
168ef281a19SIngo MolnarLDFLAGS = -lpthread -lrt -lelf -lm
16986470930SIngo MolnarALL_CFLAGS = $(CFLAGS)
17086470930SIngo MolnarALL_LDFLAGS = $(LDFLAGS)
17186470930SIngo MolnarSTRIP ?= strip
17286470930SIngo Molnar
17386470930SIngo Molnar# Among the variables below, these:
17486470930SIngo Molnar#   perfexecdir
17586470930SIngo Molnar#   template_dir
17686470930SIngo Molnar#   mandir
17786470930SIngo Molnar#   infodir
17886470930SIngo Molnar#   htmldir
17986470930SIngo Molnar#   ETC_PERFCONFIG (but not sysconfdir)
18086470930SIngo Molnar# can be specified as a relative path some/where/else;
18186470930SIngo Molnar# this is interpreted as relative to $(prefix) and "perf" at
18286470930SIngo Molnar# runtime figures out where they are based on the path to the executable.
18386470930SIngo Molnar# This can help installing the suite in a relocatable way.
18486470930SIngo Molnar
18586470930SIngo Molnarprefix = $(HOME)
18686470930SIngo Molnarbindir_relative = bin
18786470930SIngo Molnarbindir = $(prefix)/$(bindir_relative)
18886470930SIngo Molnarmandir = share/man
18986470930SIngo Molnarinfodir = share/info
19086470930SIngo Molnarperfexecdir = libexec/perf-core
19186470930SIngo Molnarsharedir = $(prefix)/share
19286470930SIngo Molnartemplate_dir = share/perf-core/templates
19386470930SIngo Molnarhtmldir = share/doc/perf-doc
19486470930SIngo Molnarifeq ($(prefix),/usr)
19586470930SIngo Molnarsysconfdir = /etc
19686470930SIngo MolnarETC_PERFCONFIG = $(sysconfdir)/perfconfig
19786470930SIngo Molnarelse
19886470930SIngo Molnarsysconfdir = $(prefix)/etc
19986470930SIngo MolnarETC_PERFCONFIG = etc/perfconfig
20086470930SIngo Molnarendif
20186470930SIngo Molnarlib = lib
20286470930SIngo Molnar# DESTDIR=
20386470930SIngo Molnar
20486470930SIngo Molnarexport prefix bindir sharedir sysconfdir
20586470930SIngo Molnar
20686470930SIngo MolnarCC = gcc
20786470930SIngo MolnarAR = ar
20886470930SIngo MolnarRM = rm -f
20986470930SIngo MolnarTAR = tar
21086470930SIngo MolnarFIND = find
21186470930SIngo MolnarINSTALL = install
21286470930SIngo MolnarRPMBUILD = rpmbuild
21386470930SIngo MolnarPTHREAD_LIBS = -lpthread
21486470930SIngo Molnar
21586470930SIngo Molnar# sparse is architecture-neutral, which means that we need to tell it
21686470930SIngo Molnar# explicitly what architecture to check for. Fix this up for yours..
21786470930SIngo MolnarSPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
21886470930SIngo Molnar
21986470930SIngo Molnar
22086470930SIngo Molnar
22186470930SIngo Molnar### --- END CONFIGURATION SECTION ---
22286470930SIngo Molnar
22386470930SIngo Molnar# Those must not be GNU-specific; they are shared with perl/ which may
22486470930SIngo Molnar# be built by a different compiler. (Note that this is an artifact now
22586470930SIngo Molnar# but it still might be nice to keep that distinction.)
22643cbcd8aSArnaldo Carvalho de MeloBASIC_CFLAGS = -Iutil/include
22786470930SIngo MolnarBASIC_LDFLAGS =
22886470930SIngo Molnar
22986470930SIngo Molnar# Guard against environment variables
23086470930SIngo MolnarBUILTIN_OBJS =
23186470930SIngo MolnarBUILT_INS =
23286470930SIngo MolnarCOMPAT_CFLAGS =
23386470930SIngo MolnarCOMPAT_OBJS =
23486470930SIngo MolnarLIB_H =
23586470930SIngo MolnarLIB_OBJS =
23686470930SIngo MolnarSCRIPT_PERL =
23786470930SIngo MolnarSCRIPT_SH =
23886470930SIngo MolnarTEST_PROGRAMS =
23986470930SIngo Molnar
24086470930SIngo Molnar#
24186470930SIngo Molnar# No scripts right now:
24286470930SIngo Molnar#
24386470930SIngo Molnar
24486470930SIngo Molnar# SCRIPT_SH += perf-am.sh
24586470930SIngo Molnar
24686470930SIngo Molnar#
24786470930SIngo Molnar# No Perl scripts right now:
24886470930SIngo Molnar#
24986470930SIngo Molnar
25086470930SIngo Molnar# SCRIPT_PERL += perf-add--interactive.perl
25186470930SIngo Molnar
25286470930SIngo MolnarSCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
25386470930SIngo Molnar	  $(patsubst %.perl,%,$(SCRIPT_PERL))
25486470930SIngo Molnar
25586470930SIngo Molnar# Empty...
25686470930SIngo MolnarEXTRA_PROGRAMS =
25786470930SIngo Molnar
25886470930SIngo Molnar# ... and all the rest that could be moved out of bindir to perfexecdir
25986470930SIngo MolnarPROGRAMS += $(EXTRA_PROGRAMS)
26086470930SIngo Molnar
26186470930SIngo Molnar#
26286470930SIngo Molnar# Single 'perf' binary right now:
26386470930SIngo Molnar#
26486470930SIngo MolnarPROGRAMS += perf
26586470930SIngo Molnar
26686470930SIngo Molnar# List built-in command $C whose implementation cmd_$C() is not in
26786470930SIngo Molnar# builtin-$C.o but is linked in as part of some other command.
26886470930SIngo Molnar#
26986470930SIngo Molnar# None right now:
27086470930SIngo Molnar#
27186470930SIngo Molnar# BUILT_INS += perf-init $X
27286470930SIngo Molnar
27386470930SIngo Molnar# what 'all' will build and 'install' will install, in perfexecdir
27486470930SIngo MolnarALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
27586470930SIngo Molnar
27686470930SIngo Molnar# what 'all' will build but not install in perfexecdir
27786470930SIngo MolnarOTHER_PROGRAMS = perf$X
27886470930SIngo Molnar
27986470930SIngo Molnar# Set paths to tools early so that they can be used for version tests.
28086470930SIngo Molnarifndef SHELL_PATH
28186470930SIngo Molnar	SHELL_PATH = /bin/sh
28286470930SIngo Molnarendif
28386470930SIngo Molnarifndef PERL_PATH
28486470930SIngo Molnar	PERL_PATH = /usr/bin/perl
28586470930SIngo Molnarendif
28686470930SIngo Molnar
28786470930SIngo Molnarexport PERL_PATH
28886470930SIngo Molnar
28986470930SIngo MolnarLIB_FILE=libperf.a
29086470930SIngo Molnar
29186470930SIngo MolnarLIB_H += ../../include/linux/perf_counter.h
29243cbcd8aSArnaldo Carvalho de MeloLIB_H += ../../include/linux/rbtree.h
2935da50258SArnaldo Carvalho de MeloLIB_H += ../../include/linux/list.h
2945da50258SArnaldo Carvalho de MeloLIB_H += util/include/linux/list.h
29586470930SIngo MolnarLIB_H += perf.h
2967c6a1c65SPeter ZijlstraLIB_H += util/types.h
29786470930SIngo MolnarLIB_H += util/levenshtein.h
29886470930SIngo MolnarLIB_H += util/parse-options.h
29986470930SIngo MolnarLIB_H += util/parse-events.h
30086470930SIngo MolnarLIB_H += util/quote.h
30186470930SIngo MolnarLIB_H += util/util.h
30286470930SIngo MolnarLIB_H += util/help.h
30386470930SIngo MolnarLIB_H += util/strbuf.h
30486470930SIngo MolnarLIB_H += util/string.h
30525903407SArnaldo Carvalho de MeloLIB_H += util/strlist.h
30686470930SIngo MolnarLIB_H += util/run-command.h
30786470930SIngo MolnarLIB_H += util/sigchain.h
30886470930SIngo MolnarLIB_H += util/symbol.h
309208b4b4aSMike GalbraithLIB_H += util/module.h
31086470930SIngo MolnarLIB_H += util/color.h
31186470930SIngo Molnar
31286470930SIngo MolnarLIB_OBJS += util/abspath.o
31386470930SIngo MolnarLIB_OBJS += util/alias.o
31486470930SIngo MolnarLIB_OBJS += util/config.o
31586470930SIngo MolnarLIB_OBJS += util/ctype.o
31686470930SIngo MolnarLIB_OBJS += util/environment.o
31786470930SIngo MolnarLIB_OBJS += util/exec_cmd.o
31886470930SIngo MolnarLIB_OBJS += util/help.o
31986470930SIngo MolnarLIB_OBJS += util/levenshtein.o
32086470930SIngo MolnarLIB_OBJS += util/parse-options.o
32186470930SIngo MolnarLIB_OBJS += util/parse-events.o
32286470930SIngo MolnarLIB_OBJS += util/path.o
32386470930SIngo MolnarLIB_OBJS += util/rbtree.o
32486470930SIngo MolnarLIB_OBJS += util/run-command.o
32586470930SIngo MolnarLIB_OBJS += util/quote.o
32686470930SIngo MolnarLIB_OBJS += util/strbuf.o
32786470930SIngo MolnarLIB_OBJS += util/string.o
32825903407SArnaldo Carvalho de MeloLIB_OBJS += util/strlist.o
32986470930SIngo MolnarLIB_OBJS += util/usage.o
33086470930SIngo MolnarLIB_OBJS += util/wrapper.o
33186470930SIngo MolnarLIB_OBJS += util/sigchain.o
33286470930SIngo MolnarLIB_OBJS += util/symbol.o
333208b4b4aSMike GalbraithLIB_OBJS += util/module.o
33486470930SIngo MolnarLIB_OBJS += util/color.o
33586470930SIngo MolnarLIB_OBJS += util/pager.o
3367c6a1c65SPeter ZijlstraLIB_OBJS += util/header.o
3378cb76d99SFrederic WeisbeckerLIB_OBJS += util/callchain.o
33886470930SIngo Molnar
33986470930SIngo MolnarBUILTIN_OBJS += builtin-annotate.o
34086470930SIngo MolnarBUILTIN_OBJS += builtin-help.o
34186470930SIngo MolnarBUILTIN_OBJS += builtin-list.o
34286470930SIngo MolnarBUILTIN_OBJS += builtin-record.o
34386470930SIngo MolnarBUILTIN_OBJS += builtin-report.o
34486470930SIngo MolnarBUILTIN_OBJS += builtin-stat.o
34586470930SIngo MolnarBUILTIN_OBJS += builtin-top.o
34686470930SIngo Molnar
34786470930SIngo MolnarPERFLIBS = $(LIB_FILE)
34886470930SIngo Molnar
34986470930SIngo Molnar#
35086470930SIngo Molnar# Platform specific tweaks
35186470930SIngo Molnar#
35286470930SIngo Molnar
35386470930SIngo Molnar# We choose to avoid "if .. else if .. else .. endif endif"
35486470930SIngo Molnar# because maintaining the nesting to match is a pain.  If
35586470930SIngo Molnar# we had "elif" things would have been much nicer...
35686470930SIngo Molnar
35786470930SIngo Molnar-include config.mak.autogen
35886470930SIngo Molnar-include config.mak
35986470930SIngo Molnar
36086470930SIngo Molnarifeq ($(uname_S),Darwin)
36186470930SIngo Molnar	ifndef NO_FINK
36286470930SIngo Molnar		ifeq ($(shell test -d /sw/lib && echo y),y)
36386470930SIngo Molnar			BASIC_CFLAGS += -I/sw/include
36486470930SIngo Molnar			BASIC_LDFLAGS += -L/sw/lib
36586470930SIngo Molnar		endif
36686470930SIngo Molnar	endif
36786470930SIngo Molnar	ifndef NO_DARWIN_PORTS
36886470930SIngo Molnar		ifeq ($(shell test -d /opt/local/lib && echo y),y)
36986470930SIngo Molnar			BASIC_CFLAGS += -I/opt/local/include
37086470930SIngo Molnar			BASIC_LDFLAGS += -L/opt/local/lib
37186470930SIngo Molnar		endif
37286470930SIngo Molnar	endif
37386470930SIngo Molnar	PTHREAD_LIBS =
37486470930SIngo Molnarendif
37586470930SIngo Molnar
376*2cdbc46dSPeter Zijlstraifdef NO_DEMANGLE
377*2cdbc46dSPeter Zijlstra	BASIC_CFLAGS += -DNO_DEMANGLE
378*2cdbc46dSPeter Zijlstraelse
379*2cdbc46dSPeter Zijlstra
380*2cdbc46dSPeter Zijlstra	has_bfd := $(shell sh -c "(echo '\#include <stdio.h>'; echo '\#include <bfd.h>'; echo '\#ifndef DMGL_PARAMS'; echo '\#define DMGL_PARAMS (1 << 0)'; echo '\#define DMGL_ANSI (1 << 1)'; echo '\#endif'; echo 'int main(int argc, char **argv) { bfd_demangle(NULL, argv[0], DMGL_PARAMS | DMGL_ANSI); return 0; }') | gcc -x c - -lbfd > /dev/null 2>&1 && echo y")
381*2cdbc46dSPeter Zijlstra
382*2cdbc46dSPeter Zijlstra	has_bfd_iberty := $(shell sh -c "(echo '\#include <stdio.h>'; echo '\#include <bfd.h>'; echo '\#ifndef DMGL_PARAMS'; echo '\#define DMGL_PARAMS (1 << 0)'; echo '\#define DMGL_ANSI (1 << 1)'; echo '\#endif'; echo 'int main(int argc, char **argv) { bfd_demangle(NULL, argv[0], DMGL_PARAMS | DMGL_ANSI); return 0; }') | gcc -x c - -lbfd -liberty > /dev/null 2>&1 && echo y")
383*2cdbc46dSPeter Zijlstra
384*2cdbc46dSPeter Zijlstra	ifeq ($(has_bfd),y)
385*2cdbc46dSPeter Zijlstra		EXTLIBS += -lbfd
386*2cdbc46dSPeter Zijlstra	else ifeq ($(has_bfd_iberty),y)
387*2cdbc46dSPeter Zijlstra		EXTLIBS += -lbfd -liberty
388*2cdbc46dSPeter Zijlstra	else
389*2cdbc46dSPeter Zijlstra		BASIC_CFLAGS += -DNO_DEMANGLE
390*2cdbc46dSPeter Zijlstra	endif
391*2cdbc46dSPeter Zijlstraendif
392*2cdbc46dSPeter Zijlstra
39386470930SIngo Molnarifndef CC_LD_DYNPATH
39486470930SIngo Molnar	ifdef NO_R_TO_GCC_LINKER
39586470930SIngo Molnar		# Some gcc does not accept and pass -R to the linker to specify
39686470930SIngo Molnar		# the runtime dynamic library path.
39786470930SIngo Molnar		CC_LD_DYNPATH = -Wl,-rpath,
39886470930SIngo Molnar	else
39986470930SIngo Molnar		CC_LD_DYNPATH = -R
40086470930SIngo Molnar	endif
40186470930SIngo Molnarendif
40286470930SIngo Molnar
40386470930SIngo Molnarifdef NEEDS_SOCKET
40486470930SIngo Molnar	EXTLIBS += -lsocket
40586470930SIngo Molnarendif
40686470930SIngo Molnarifdef NEEDS_NSL
40786470930SIngo Molnar	EXTLIBS += -lnsl
40886470930SIngo Molnarendif
40986470930SIngo Molnarifdef NO_D_TYPE_IN_DIRENT
41086470930SIngo Molnar	BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
41186470930SIngo Molnarendif
41286470930SIngo Molnarifdef NO_D_INO_IN_DIRENT
41386470930SIngo Molnar	BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
41486470930SIngo Molnarendif
41586470930SIngo Molnarifdef NO_ST_BLOCKS_IN_STRUCT_STAT
41686470930SIngo Molnar	BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
41786470930SIngo Molnarendif
41886470930SIngo Molnarifdef USE_NSEC
41986470930SIngo Molnar	BASIC_CFLAGS += -DUSE_NSEC
42086470930SIngo Molnarendif
42186470930SIngo Molnarifdef USE_ST_TIMESPEC
42286470930SIngo Molnar	BASIC_CFLAGS += -DUSE_ST_TIMESPEC
42386470930SIngo Molnarendif
42486470930SIngo Molnarifdef NO_NSEC
42586470930SIngo Molnar	BASIC_CFLAGS += -DNO_NSEC
42686470930SIngo Molnarendif
42786470930SIngo Molnarifdef NO_C99_FORMAT
42886470930SIngo Molnar	BASIC_CFLAGS += -DNO_C99_FORMAT
42986470930SIngo Molnarendif
43086470930SIngo Molnarifdef SNPRINTF_RETURNS_BOGUS
43186470930SIngo Molnar	COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
43286470930SIngo Molnar	COMPAT_OBJS += compat/snprintf.o
43386470930SIngo Molnarendif
43486470930SIngo Molnarifdef FREAD_READS_DIRECTORIES
43586470930SIngo Molnar	COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
43686470930SIngo Molnar	COMPAT_OBJS += compat/fopen.o
43786470930SIngo Molnarendif
43886470930SIngo Molnarifdef NO_SYMLINK_HEAD
43986470930SIngo Molnar	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
44086470930SIngo Molnarendif
44186470930SIngo Molnarifdef NO_STRCASESTR
44286470930SIngo Molnar	COMPAT_CFLAGS += -DNO_STRCASESTR
44386470930SIngo Molnar	COMPAT_OBJS += compat/strcasestr.o
44486470930SIngo Molnarendif
44586470930SIngo Molnarifdef NO_STRTOUMAX
44686470930SIngo Molnar	COMPAT_CFLAGS += -DNO_STRTOUMAX
44786470930SIngo Molnar	COMPAT_OBJS += compat/strtoumax.o
44886470930SIngo Molnarendif
44986470930SIngo Molnarifdef NO_STRTOULL
45086470930SIngo Molnar	COMPAT_CFLAGS += -DNO_STRTOULL
45186470930SIngo Molnarendif
45286470930SIngo Molnarifdef NO_SETENV
45386470930SIngo Molnar	COMPAT_CFLAGS += -DNO_SETENV
45486470930SIngo Molnar	COMPAT_OBJS += compat/setenv.o
45586470930SIngo Molnarendif
45686470930SIngo Molnarifdef NO_MKDTEMP
45786470930SIngo Molnar	COMPAT_CFLAGS += -DNO_MKDTEMP
45886470930SIngo Molnar	COMPAT_OBJS += compat/mkdtemp.o
45986470930SIngo Molnarendif
46086470930SIngo Molnarifdef NO_UNSETENV
46186470930SIngo Molnar	COMPAT_CFLAGS += -DNO_UNSETENV
46286470930SIngo Molnar	COMPAT_OBJS += compat/unsetenv.o
46386470930SIngo Molnarendif
46486470930SIngo Molnarifdef NO_SYS_SELECT_H
46586470930SIngo Molnar	BASIC_CFLAGS += -DNO_SYS_SELECT_H
46686470930SIngo Molnarendif
46786470930SIngo Molnarifdef NO_MMAP
46886470930SIngo Molnar	COMPAT_CFLAGS += -DNO_MMAP
46986470930SIngo Molnar	COMPAT_OBJS += compat/mmap.o
47086470930SIngo Molnarelse
47186470930SIngo Molnar	ifdef USE_WIN32_MMAP
47286470930SIngo Molnar		COMPAT_CFLAGS += -DUSE_WIN32_MMAP
47386470930SIngo Molnar		COMPAT_OBJS += compat/win32mmap.o
47486470930SIngo Molnar	endif
47586470930SIngo Molnarendif
47686470930SIngo Molnarifdef NO_PREAD
47786470930SIngo Molnar	COMPAT_CFLAGS += -DNO_PREAD
47886470930SIngo Molnar	COMPAT_OBJS += compat/pread.o
47986470930SIngo Molnarendif
48086470930SIngo Molnarifdef NO_FAST_WORKING_DIRECTORY
48186470930SIngo Molnar	BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
48286470930SIngo Molnarendif
48386470930SIngo Molnarifdef NO_TRUSTABLE_FILEMODE
48486470930SIngo Molnar	BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
48586470930SIngo Molnarendif
48686470930SIngo Molnarifdef NO_IPV6
48786470930SIngo Molnar	BASIC_CFLAGS += -DNO_IPV6
48886470930SIngo Molnarendif
48986470930SIngo Molnarifdef NO_UINTMAX_T
49086470930SIngo Molnar	BASIC_CFLAGS += -Duintmax_t=uint32_t
49186470930SIngo Molnarendif
49286470930SIngo Molnarifdef NO_SOCKADDR_STORAGE
49386470930SIngo Molnarifdef NO_IPV6
49486470930SIngo Molnar	BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
49586470930SIngo Molnarelse
49686470930SIngo Molnar	BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
49786470930SIngo Molnarendif
49886470930SIngo Molnarendif
49986470930SIngo Molnarifdef NO_INET_NTOP
50086470930SIngo Molnar	LIB_OBJS += compat/inet_ntop.o
50186470930SIngo Molnarendif
50286470930SIngo Molnarifdef NO_INET_PTON
50386470930SIngo Molnar	LIB_OBJS += compat/inet_pton.o
50486470930SIngo Molnarendif
50586470930SIngo Molnar
50686470930SIngo Molnarifdef NO_ICONV
50786470930SIngo Molnar	BASIC_CFLAGS += -DNO_ICONV
50886470930SIngo Molnarendif
50986470930SIngo Molnar
51086470930SIngo Molnarifdef OLD_ICONV
51186470930SIngo Molnar	BASIC_CFLAGS += -DOLD_ICONV
51286470930SIngo Molnarendif
51386470930SIngo Molnar
51486470930SIngo Molnarifdef NO_DEFLATE_BOUND
51586470930SIngo Molnar	BASIC_CFLAGS += -DNO_DEFLATE_BOUND
51686470930SIngo Molnarendif
51786470930SIngo Molnar
51886470930SIngo Molnarifdef PPC_SHA1
51986470930SIngo Molnar	SHA1_HEADER = "ppc/sha1.h"
52086470930SIngo Molnar	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
52186470930SIngo Molnarelse
52286470930SIngo Molnarifdef ARM_SHA1
52386470930SIngo Molnar	SHA1_HEADER = "arm/sha1.h"
52486470930SIngo Molnar	LIB_OBJS += arm/sha1.o arm/sha1_arm.o
52586470930SIngo Molnarelse
52686470930SIngo Molnarifdef MOZILLA_SHA1
52786470930SIngo Molnar	SHA1_HEADER = "mozilla-sha1/sha1.h"
52886470930SIngo Molnar	LIB_OBJS += mozilla-sha1/sha1.o
52986470930SIngo Molnarelse
53086470930SIngo Molnar	SHA1_HEADER = <openssl/sha.h>
53186470930SIngo Molnar	EXTLIBS += $(LIB_4_CRYPTO)
53286470930SIngo Molnarendif
53386470930SIngo Molnarendif
53486470930SIngo Molnarendif
53586470930SIngo Molnarifdef NO_PERL_MAKEMAKER
53686470930SIngo Molnar	export NO_PERL_MAKEMAKER
53786470930SIngo Molnarendif
53886470930SIngo Molnarifdef NO_HSTRERROR
53986470930SIngo Molnar	COMPAT_CFLAGS += -DNO_HSTRERROR
54086470930SIngo Molnar	COMPAT_OBJS += compat/hstrerror.o
54186470930SIngo Molnarendif
54286470930SIngo Molnarifdef NO_MEMMEM
54386470930SIngo Molnar	COMPAT_CFLAGS += -DNO_MEMMEM
54486470930SIngo Molnar	COMPAT_OBJS += compat/memmem.o
54586470930SIngo Molnarendif
54686470930SIngo Molnarifdef INTERNAL_QSORT
54786470930SIngo Molnar	COMPAT_CFLAGS += -DINTERNAL_QSORT
54886470930SIngo Molnar	COMPAT_OBJS += compat/qsort.o
54986470930SIngo Molnarendif
55086470930SIngo Molnarifdef RUNTIME_PREFIX
55186470930SIngo Molnar	COMPAT_CFLAGS += -DRUNTIME_PREFIX
55286470930SIngo Molnarendif
55386470930SIngo Molnar
55486470930SIngo Molnarifdef DIR_HAS_BSD_GROUP_SEMANTICS
55586470930SIngo Molnar	COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
55686470930SIngo Molnarendif
55786470930SIngo Molnarifdef NO_EXTERNAL_GREP
55886470930SIngo Molnar	BASIC_CFLAGS += -DNO_EXTERNAL_GREP
55986470930SIngo Molnarendif
56086470930SIngo Molnar
56186470930SIngo Molnarifeq ($(PERL_PATH),)
56286470930SIngo MolnarNO_PERL=NoThanks
56386470930SIngo Molnarendif
56486470930SIngo Molnar
56586470930SIngo MolnarQUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
56686470930SIngo MolnarQUIET_SUBDIR1  =
56786470930SIngo Molnar
56886470930SIngo Molnarifneq ($(findstring $(MAKEFLAGS),w),w)
56986470930SIngo MolnarPRINT_DIR = --no-print-directory
57086470930SIngo Molnarelse # "make -w"
57186470930SIngo MolnarNO_SUBDIR = :
57286470930SIngo Molnarendif
57386470930SIngo Molnar
57486470930SIngo Molnarifneq ($(findstring $(MAKEFLAGS),s),s)
57586470930SIngo Molnarifndef V
57686470930SIngo Molnar	QUIET_CC       = @echo '   ' CC $@;
57786470930SIngo Molnar	QUIET_AR       = @echo '   ' AR $@;
57886470930SIngo Molnar	QUIET_LINK     = @echo '   ' LINK $@;
57986470930SIngo Molnar	QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
58086470930SIngo Molnar	QUIET_GEN      = @echo '   ' GEN $@;
58186470930SIngo Molnar	QUIET_SUBDIR0  = +@subdir=
58286470930SIngo Molnar	QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
58386470930SIngo Molnar			 $(MAKE) $(PRINT_DIR) -C $$subdir
58486470930SIngo Molnar	export V
58586470930SIngo Molnar	export QUIET_GEN
58686470930SIngo Molnar	export QUIET_BUILT_IN
58786470930SIngo Molnarendif
58886470930SIngo Molnarendif
58986470930SIngo Molnar
59086470930SIngo Molnarifdef ASCIIDOC8
59186470930SIngo Molnar	export ASCIIDOC8
59286470930SIngo Molnarendif
59386470930SIngo Molnar
59486470930SIngo Molnar# Shell quote (do not use $(call) to accommodate ancient setups);
59586470930SIngo Molnar
59686470930SIngo MolnarSHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
59786470930SIngo MolnarETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
59886470930SIngo Molnar
59986470930SIngo MolnarDESTDIR_SQ = $(subst ','\'',$(DESTDIR))
60086470930SIngo Molnarbindir_SQ = $(subst ','\'',$(bindir))
60186470930SIngo Molnarbindir_relative_SQ = $(subst ','\'',$(bindir_relative))
60286470930SIngo Molnarmandir_SQ = $(subst ','\'',$(mandir))
60386470930SIngo Molnarinfodir_SQ = $(subst ','\'',$(infodir))
60486470930SIngo Molnarperfexecdir_SQ = $(subst ','\'',$(perfexecdir))
60586470930SIngo Molnartemplate_dir_SQ = $(subst ','\'',$(template_dir))
60686470930SIngo Molnarhtmldir_SQ = $(subst ','\'',$(htmldir))
60786470930SIngo Molnarprefix_SQ = $(subst ','\'',$(prefix))
60886470930SIngo Molnar
60986470930SIngo MolnarSHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
61086470930SIngo MolnarPERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
61186470930SIngo Molnar
61286470930SIngo MolnarLIBS = $(PERFLIBS) $(EXTLIBS)
61386470930SIngo Molnar
61486470930SIngo MolnarBASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
61586470930SIngo Molnar	$(COMPAT_CFLAGS)
61686470930SIngo MolnarLIB_OBJS += $(COMPAT_OBJS)
61786470930SIngo Molnar
61886470930SIngo MolnarALL_CFLAGS += $(BASIC_CFLAGS)
61986470930SIngo MolnarALL_LDFLAGS += $(BASIC_LDFLAGS)
62086470930SIngo Molnar
62186470930SIngo Molnarexport TAR INSTALL DESTDIR SHELL_PATH
62286470930SIngo Molnar
62386470930SIngo Molnar
62486470930SIngo Molnar### Build rules
62586470930SIngo Molnar
62686470930SIngo MolnarSHELL = $(SHELL_PATH)
62786470930SIngo Molnar
62886470930SIngo Molnarall:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS
62986470930SIngo Molnarifneq (,$X)
63086470930SIngo Molnar	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
63186470930SIngo Molnarendif
63286470930SIngo Molnar
63386470930SIngo Molnarall::
63486470930SIngo Molnar
63586470930SIngo Molnarplease_set_SHELL_PATH_to_a_more_modern_shell:
63686470930SIngo Molnar	@$$(:)
63786470930SIngo Molnar
63886470930SIngo Molnarshell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
63986470930SIngo Molnar
64086470930SIngo Molnarstrip: $(PROGRAMS) perf$X
64186470930SIngo Molnar	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) perf$X
64286470930SIngo Molnar
64386470930SIngo Molnarperf.o: perf.c common-cmds.h PERF-CFLAGS
64486470930SIngo Molnar	$(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
64586470930SIngo Molnar		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
64686470930SIngo Molnar		$(ALL_CFLAGS) -c $(filter %.c,$^)
64786470930SIngo Molnar
64886470930SIngo Molnarperf$X: perf.o $(BUILTIN_OBJS) $(PERFLIBS)
64986470930SIngo Molnar	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ perf.o \
65086470930SIngo Molnar		$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
65186470930SIngo Molnar
65286470930SIngo Molnarbuiltin-help.o: builtin-help.c common-cmds.h PERF-CFLAGS
65386470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
65486470930SIngo Molnar		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
65586470930SIngo Molnar		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
65686470930SIngo Molnar		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
65786470930SIngo Molnar
65886470930SIngo Molnar$(BUILT_INS): perf$X
65986470930SIngo Molnar	$(QUIET_BUILT_IN)$(RM) $@ && \
66086470930SIngo Molnar	ln perf$X $@ 2>/dev/null || \
66186470930SIngo Molnar	ln -s perf$X $@ 2>/dev/null || \
66286470930SIngo Molnar	cp perf$X $@
66386470930SIngo Molnar
66486470930SIngo Molnarcommon-cmds.h: util/generate-cmdlist.sh command-list.txt
66586470930SIngo Molnar
66686470930SIngo Molnarcommon-cmds.h: $(wildcard Documentation/perf-*.txt)
66786470930SIngo Molnar	$(QUIET_GEN)util/generate-cmdlist.sh > $@+ && mv $@+ $@
66886470930SIngo Molnar
66986470930SIngo Molnar$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
67086470930SIngo Molnar	$(QUIET_GEN)$(RM) $@ $@+ && \
67186470930SIngo Molnar	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
67286470930SIngo Molnar	    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
67386470930SIngo Molnar	    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
67486470930SIngo Molnar	    -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
67586470930SIngo Molnar	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
67686470930SIngo Molnar	    $@.sh >$@+ && \
67786470930SIngo Molnar	chmod +x $@+ && \
67886470930SIngo Molnar	mv $@+ $@
67986470930SIngo Molnar
68086470930SIngo Molnarconfigure: configure.ac
68186470930SIngo Molnar	$(QUIET_GEN)$(RM) $@ $<+ && \
68286470930SIngo Molnar	sed -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
68386470930SIngo Molnar	    $< > $<+ && \
68486470930SIngo Molnar	autoconf -o $@ $<+ && \
68586470930SIngo Molnar	$(RM) $<+
68686470930SIngo Molnar
68786470930SIngo Molnar# These can record PERF_VERSION
68886470930SIngo Molnarperf.o perf.spec \
68986470930SIngo Molnar	$(patsubst %.sh,%,$(SCRIPT_SH)) \
69086470930SIngo Molnar	$(patsubst %.perl,%,$(SCRIPT_PERL)) \
69186470930SIngo Molnar	: PERF-VERSION-FILE
69286470930SIngo Molnar
69386470930SIngo Molnar%.o: %.c PERF-CFLAGS
69486470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
69586470930SIngo Molnar%.s: %.c PERF-CFLAGS
69686470930SIngo Molnar	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
69786470930SIngo Molnar%.o: %.S
69886470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
69986470930SIngo Molnar
70086470930SIngo Molnarutil/exec_cmd.o: util/exec_cmd.c PERF-CFLAGS
70186470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
70286470930SIngo Molnar		'-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
70386470930SIngo Molnar		'-DBINDIR="$(bindir_relative_SQ)"' \
70486470930SIngo Molnar		'-DPREFIX="$(prefix_SQ)"' \
70586470930SIngo Molnar		$<
70686470930SIngo Molnar
70786470930SIngo Molnarbuiltin-init-db.o: builtin-init-db.c PERF-CFLAGS
70886470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_PERF_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
70986470930SIngo Molnar
71086470930SIngo Molnarutil/config.o: util/config.c PERF-CFLAGS
71186470930SIngo Molnar	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
71286470930SIngo Molnar
71343cbcd8aSArnaldo Carvalho de Meloutil/rbtree.o: ../../lib/rbtree.c PERF-CFLAGS
71443cbcd8aSArnaldo Carvalho de Melo	$(QUIET_CC)$(CC) -o util/rbtree.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
71543cbcd8aSArnaldo Carvalho de Melo
71686470930SIngo Molnarperf-%$X: %.o $(PERFLIBS)
71786470930SIngo Molnar	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
71886470930SIngo Molnar
71986470930SIngo Molnar$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
72086470930SIngo Molnar$(patsubst perf-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
72186470930SIngo Molnarbuiltin-revert.o wt-status.o: wt-status.h
72286470930SIngo Molnar
72386470930SIngo Molnar$(LIB_FILE): $(LIB_OBJS)
72486470930SIngo Molnar	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
72586470930SIngo Molnar
72686470930SIngo Molnardoc:
72786470930SIngo Molnar	$(MAKE) -C Documentation all
72886470930SIngo Molnar
72986470930SIngo Molnarman:
73086470930SIngo Molnar	$(MAKE) -C Documentation man
73186470930SIngo Molnar
73286470930SIngo Molnarhtml:
73386470930SIngo Molnar	$(MAKE) -C Documentation html
73486470930SIngo Molnar
73586470930SIngo Molnarinfo:
73686470930SIngo Molnar	$(MAKE) -C Documentation info
73786470930SIngo Molnar
73886470930SIngo Molnarpdf:
73986470930SIngo Molnar	$(MAKE) -C Documentation pdf
74086470930SIngo Molnar
74186470930SIngo MolnarTAGS:
74286470930SIngo Molnar	$(RM) TAGS
74386470930SIngo Molnar	$(FIND) . -name '*.[hcS]' -print | xargs etags -a
74486470930SIngo Molnar
74586470930SIngo Molnartags:
74686470930SIngo Molnar	$(RM) tags
74786470930SIngo Molnar	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
74886470930SIngo Molnar
74986470930SIngo Molnarcscope:
75086470930SIngo Molnar	$(RM) cscope*
75186470930SIngo Molnar	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
75286470930SIngo Molnar
75386470930SIngo Molnar### Detect prefix changes
75486470930SIngo MolnarTRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
75586470930SIngo Molnar             $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
75686470930SIngo Molnar
75786470930SIngo MolnarPERF-CFLAGS: .FORCE-PERF-CFLAGS
75886470930SIngo Molnar	@FLAGS='$(TRACK_CFLAGS)'; \
75986470930SIngo Molnar	    if test x"$$FLAGS" != x"`cat PERF-CFLAGS 2>/dev/null`" ; then \
76086470930SIngo Molnar		echo 1>&2 "    * new build flags or prefix"; \
76186470930SIngo Molnar		echo "$$FLAGS" >PERF-CFLAGS; \
76286470930SIngo Molnar            fi
76386470930SIngo Molnar
76486470930SIngo Molnar# We need to apply sq twice, once to protect from the shell
76586470930SIngo Molnar# that runs PERF-BUILD-OPTIONS, and then again to protect it
76686470930SIngo Molnar# and the first level quoting from the shell that runs "echo".
76786470930SIngo MolnarPERF-BUILD-OPTIONS: .FORCE-PERF-BUILD-OPTIONS
76886470930SIngo Molnar	@echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
76986470930SIngo Molnar	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
77086470930SIngo Molnar	@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
77186470930SIngo Molnar	@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
77286470930SIngo Molnar
77386470930SIngo Molnar### Testing rules
77486470930SIngo Molnar
77586470930SIngo Molnar#
77686470930SIngo Molnar# None right now:
77786470930SIngo Molnar#
77886470930SIngo Molnar# TEST_PROGRAMS += test-something$X
77986470930SIngo Molnar
78086470930SIngo Molnarall:: $(TEST_PROGRAMS)
78186470930SIngo Molnar
78286470930SIngo Molnar# GNU make supports exporting all variables by "export" without parameters.
78386470930SIngo Molnar# However, the environment gets quite big, and some programs have problems
78486470930SIngo Molnar# with that.
78586470930SIngo Molnar
78686470930SIngo Molnarexport NO_SVN_TESTS
78786470930SIngo Molnar
78886470930SIngo Molnarcheck: common-cmds.h
78986470930SIngo Molnar	if sparse; \
79086470930SIngo Molnar	then \
79186470930SIngo Molnar		for i in *.c */*.c; \
79286470930SIngo Molnar		do \
79386470930SIngo Molnar			sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
79486470930SIngo Molnar		done; \
79586470930SIngo Molnar	else \
79686470930SIngo Molnar		echo 2>&1 "Did you mean 'make test'?"; \
79786470930SIngo Molnar		exit 1; \
79886470930SIngo Molnar	fi
79986470930SIngo Molnar
80086470930SIngo Molnarremove-dashes:
80186470930SIngo Molnar	./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
80286470930SIngo Molnar
80386470930SIngo Molnar### Installation rules
80486470930SIngo Molnar
80586470930SIngo Molnarifneq ($(filter /%,$(firstword $(template_dir))),)
80686470930SIngo Molnartemplate_instdir = $(template_dir)
80786470930SIngo Molnarelse
80886470930SIngo Molnartemplate_instdir = $(prefix)/$(template_dir)
80986470930SIngo Molnarendif
81086470930SIngo Molnarexport template_instdir
81186470930SIngo Molnar
81286470930SIngo Molnarifneq ($(filter /%,$(firstword $(perfexecdir))),)
81386470930SIngo Molnarperfexec_instdir = $(perfexecdir)
81486470930SIngo Molnarelse
81586470930SIngo Molnarperfexec_instdir = $(prefix)/$(perfexecdir)
81686470930SIngo Molnarendif
81786470930SIngo Molnarperfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
81886470930SIngo Molnarexport perfexec_instdir
81986470930SIngo Molnar
82086470930SIngo Molnarinstall: all
82186470930SIngo Molnar	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
82286470930SIngo Molnar	$(INSTALL) perf$X '$(DESTDIR_SQ)$(bindir_SQ)'
82386470930SIngo Molnarifdef BUILT_INS
82486470930SIngo Molnar	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
82586470930SIngo Molnar	$(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
82686470930SIngo Molnarifneq (,$X)
82786470930SIngo Molnar	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), $(RM) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$p';)
82886470930SIngo Molnarendif
82986470930SIngo Molnarendif
83086470930SIngo Molnar
83186470930SIngo Molnarinstall-doc:
83286470930SIngo Molnar	$(MAKE) -C Documentation install
83386470930SIngo Molnar
83486470930SIngo Molnarinstall-man:
83586470930SIngo Molnar	$(MAKE) -C Documentation install-man
83686470930SIngo Molnar
83786470930SIngo Molnarinstall-html:
83886470930SIngo Molnar	$(MAKE) -C Documentation install-html
83986470930SIngo Molnar
84086470930SIngo Molnarinstall-info:
84186470930SIngo Molnar	$(MAKE) -C Documentation install-info
84286470930SIngo Molnar
84386470930SIngo Molnarinstall-pdf:
84486470930SIngo Molnar	$(MAKE) -C Documentation install-pdf
84586470930SIngo Molnar
84686470930SIngo Molnarquick-install-doc:
84786470930SIngo Molnar	$(MAKE) -C Documentation quick-install
84886470930SIngo Molnar
84986470930SIngo Molnarquick-install-man:
85086470930SIngo Molnar	$(MAKE) -C Documentation quick-install-man
85186470930SIngo Molnar
85286470930SIngo Molnarquick-install-html:
85386470930SIngo Molnar	$(MAKE) -C Documentation quick-install-html
85486470930SIngo Molnar
85586470930SIngo Molnar
85686470930SIngo Molnar### Maintainer's dist rules
85786470930SIngo Molnar#
85886470930SIngo Molnar# None right now
85986470930SIngo Molnar#
86086470930SIngo Molnar#
86186470930SIngo Molnar# perf.spec: perf.spec.in
86286470930SIngo Molnar#	sed -e 's/@@VERSION@@/$(PERF_VERSION)/g' < $< > $@+
86386470930SIngo Molnar#	mv $@+ $@
86486470930SIngo Molnar#
86586470930SIngo Molnar# PERF_TARNAME=perf-$(PERF_VERSION)
86686470930SIngo Molnar# dist: perf.spec perf-archive$(X) configure
86786470930SIngo Molnar#	./perf-archive --format=tar \
86886470930SIngo Molnar#		--prefix=$(PERF_TARNAME)/ HEAD^{tree} > $(PERF_TARNAME).tar
86986470930SIngo Molnar#	@mkdir -p $(PERF_TARNAME)
87086470930SIngo Molnar#	@cp perf.spec configure $(PERF_TARNAME)
87186470930SIngo Molnar#	@echo $(PERF_VERSION) > $(PERF_TARNAME)/version
87286470930SIngo Molnar#	$(TAR) rf $(PERF_TARNAME).tar \
87386470930SIngo Molnar#		$(PERF_TARNAME)/perf.spec \
87486470930SIngo Molnar#		$(PERF_TARNAME)/configure \
87586470930SIngo Molnar#		$(PERF_TARNAME)/version
87686470930SIngo Molnar#	@$(RM) -r $(PERF_TARNAME)
87786470930SIngo Molnar#	gzip -f -9 $(PERF_TARNAME).tar
87886470930SIngo Molnar#
87986470930SIngo Molnar# htmldocs = perf-htmldocs-$(PERF_VERSION)
88086470930SIngo Molnar# manpages = perf-manpages-$(PERF_VERSION)
88186470930SIngo Molnar# dist-doc:
88286470930SIngo Molnar#	$(RM) -r .doc-tmp-dir
88386470930SIngo Molnar#	mkdir .doc-tmp-dir
88486470930SIngo Molnar#	$(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
88586470930SIngo Molnar#	cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
88686470930SIngo Molnar#	gzip -n -9 -f $(htmldocs).tar
88786470930SIngo Molnar#	:
88886470930SIngo Molnar#	$(RM) -r .doc-tmp-dir
88986470930SIngo Molnar#	mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
89086470930SIngo Molnar#	$(MAKE) -C Documentation DESTDIR=./ \
89186470930SIngo Molnar#		man1dir=../.doc-tmp-dir/man1 \
89286470930SIngo Molnar#		man5dir=../.doc-tmp-dir/man5 \
89386470930SIngo Molnar#		man7dir=../.doc-tmp-dir/man7 \
89486470930SIngo Molnar#		install
89586470930SIngo Molnar#	cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
89686470930SIngo Molnar#	gzip -n -9 -f $(manpages).tar
89786470930SIngo Molnar#	$(RM) -r .doc-tmp-dir
89886470930SIngo Molnar#
89986470930SIngo Molnar# rpm: dist
90086470930SIngo Molnar#	$(RPMBUILD) -ta $(PERF_TARNAME).tar.gz
90186470930SIngo Molnar
90286470930SIngo Molnar### Cleaning rules
90386470930SIngo Molnar
90486470930SIngo Molnardistclean: clean
90586470930SIngo Molnar#	$(RM) configure
90686470930SIngo Molnar
90786470930SIngo Molnarclean:
90886470930SIngo Molnar	$(RM) *.o */*.o $(LIB_FILE)
90986470930SIngo Molnar	$(RM) $(ALL_PROGRAMS) $(BUILT_INS) perf$X
91086470930SIngo Molnar	$(RM) $(TEST_PROGRAMS)
91186470930SIngo Molnar	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
91286470930SIngo Molnar	$(RM) -r autom4te.cache
91386470930SIngo Molnar	$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
91486470930SIngo Molnar	$(RM) -r $(PERF_TARNAME) .doc-tmp-dir
91586470930SIngo Molnar	$(RM) $(PERF_TARNAME).tar.gz perf-core_$(PERF_VERSION)-*.tar.gz
91686470930SIngo Molnar	$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
91786470930SIngo Molnar	$(MAKE) -C Documentation/ clean
91886470930SIngo Molnar	$(RM) PERF-VERSION-FILE PERF-CFLAGS PERF-BUILD-OPTIONS
91986470930SIngo Molnar
92086470930SIngo Molnar.PHONY: all install clean strip
92186470930SIngo Molnar.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
92286470930SIngo Molnar.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
92386470930SIngo Molnar.PHONY: .FORCE-PERF-BUILD-OPTIONS
92486470930SIngo Molnar
92586470930SIngo Molnar### Make sure built-ins do not have dups and listed in perf.c
92686470930SIngo Molnar#
92786470930SIngo Molnarcheck-builtins::
92886470930SIngo Molnar	./check-builtins.sh
92986470930SIngo Molnar
93086470930SIngo Molnar### Test suite coverage testing
93186470930SIngo Molnar#
93286470930SIngo Molnar# None right now
93386470930SIngo Molnar#
93486470930SIngo Molnar# .PHONY: coverage coverage-clean coverage-build coverage-report
93586470930SIngo Molnar#
93686470930SIngo Molnar# coverage:
93786470930SIngo Molnar#	$(MAKE) coverage-build
93886470930SIngo Molnar#	$(MAKE) coverage-report
93986470930SIngo Molnar#
94086470930SIngo Molnar# coverage-clean:
94186470930SIngo Molnar#	rm -f *.gcda *.gcno
94286470930SIngo Molnar#
94386470930SIngo Molnar# COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
94486470930SIngo Molnar# COVERAGE_LDFLAGS = $(CFLAGS)  -O0 -lgcov
94586470930SIngo Molnar#
94686470930SIngo Molnar# coverage-build: coverage-clean
94786470930SIngo Molnar#	$(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
94886470930SIngo Molnar#	$(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
94986470930SIngo Molnar#		-j1 test
95086470930SIngo Molnar#
95186470930SIngo Molnar# coverage-report:
95286470930SIngo Molnar#	gcov -b *.c */*.c
95386470930SIngo Molnar#	grep '^function.*called 0 ' *.c.gcov */*.c.gcov \
95486470930SIngo Molnar#		| sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
95586470930SIngo Molnar#		| tee coverage-untested-functions
956