]> bbs.cooldavid.org Git - net-next-2.6.git/blame - Documentation/perf_counter/Makefile
perf_counter tools: clean up after introduction of the Git command framework
[net-next-2.6.git] / Documentation / perf_counter / Makefile
CommitLineData
d24e473e
IM
1# The default target of this Makefile is...
2all::
e0143bad 3
d24e473e
IM
4# Define V=1 to have a more verbose compile.
5#
6# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
7# or vsnprintf() return -1 instead of number of characters which would
8# have been written to the final string if enough space had been available.
9#
10# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
11# when attempting to read from an fopen'ed directory.
12#
13# Define NO_OPENSSL environment variable if you do not have OpenSSL.
14# This also implies MOZILLA_SHA1.
15#
d24e473e
IM
16# Define CURLDIR=/foo/bar if your curl header and library files are in
17# /foo/bar/include and /foo/bar/lib directories.
18#
d24e473e
IM
19# Define EXPATDIR=/foo/bar if your expat header and library files are in
20# /foo/bar/include and /foo/bar/lib directories.
21#
22# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
23#
24# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
25# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
26#
27# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
28# do not support the 'size specifiers' introduced by C99, namely ll, hh,
29# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
30# some C compilers supported these specifiers prior to C99 as an extension.
31#
32# Define NO_STRCASESTR if you don't have strcasestr.
33#
34# Define NO_MEMMEM if you don't have memmem.
35#
d24e473e
IM
36# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
37# If your compiler also does not support long long or does not have
38# strtoull, define NO_STRTOULL.
39#
40# Define NO_SETENV if you don't have setenv in the C library.
41#
42# Define NO_UNSETENV if you don't have unsetenv in the C library.
43#
44# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
45#
46# Define NO_SYS_SELECT_H if you don't have sys/select.h.
47#
07800601 48# Define NO_SYMLINK_HEAD if you never want .perf/HEAD to be a symbolic link.
d24e473e
IM
49# Enable it on Windows. By default, symrefs are still used.
50#
51# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
52# tests. These tests take up a significant amount of the total test time
53# but are not needed unless you plan to talk to SVN repos.
54#
55# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
07800601 56# installed in /sw, but don't want PERF to link against any libraries
d24e473e
IM
57# installed there. If defined you may specify your own (or Fink's)
58# include directories and library directories by defining CFLAGS
59# and LDFLAGS appropriately.
60#
61# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
07800601 62# have DarwinPorts installed in /opt/local, but don't want PERF to
d24e473e
IM
63# link against any libraries installed there. If defined you may
64# specify your own (or DarwinPort's) include directories and
65# library directories by defining CFLAGS and LDFLAGS appropriately.
66#
67# Define PPC_SHA1 environment variable when running make to make use of
68# a bundled SHA1 routine optimized for PowerPC.
69#
70# Define ARM_SHA1 environment variable when running make to make use of
71# a bundled SHA1 routine optimized for ARM.
72#
73# Define MOZILLA_SHA1 environment variable when running make to make use of
74# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
75# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
76# choice) has very fast version optimized for i586.
77#
78# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
79#
80# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
81#
82# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
83# Patrick Mauritz).
84#
85# Define NO_MMAP if you want to avoid mmap.
86#
87# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
88#
89# Define NO_PREAD if you have a problem with pread() system call (e.g.
90# cygwin.dll before v1.5.22).
91#
92# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
93# generally faster on your platform than accessing the working directory.
94#
95# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
96# the executable mode bit, but doesn't really do so.
97#
98# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
99#
100# Define NO_SOCKADDR_STORAGE if your platform does not have struct
101# sockaddr_storage.
102#
103# Define NO_ICONV if your libc does not properly support iconv.
104#
105# Define OLD_ICONV if your library has an old iconv(), where the second
106# (input buffer pointer) parameter is declared with type (const char **).
107#
108# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
109#
110# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
111# that tells runtime paths to dynamic libraries;
112# "-Wl,-rpath=/path/lib" is used instead.
113#
07800601 114# Define USE_NSEC below if you want perf to care about sub-second file mtimes
d24e473e
IM
115# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
116# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
117# randomly break unless your underlying filesystem supports those sub-second
118# times (my ext3 doesn't).
119#
120# Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
121# "st_ctim"
122#
123# Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
124# available. This automatically turns USE_NSEC off.
125#
07800601 126# Define USE_STDEV below if you want perf to care about the underlying device
d24e473e
IM
127# change being considered an inode change from the update-index perspective.
128#
129# Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
130# field that counts the on-disk footprint in 512-byte blocks.
131#
132# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
133#
134# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
135#
136# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
137# MakeMaker (e.g. using ActiveState under Cygwin).
138#
139# Define NO_PERL if you do not want Perl scripts or libraries at all.
140#
d24e473e
IM
141# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
142# is a simplified version of the merge sort used in glibc. This is
143# recommended if Git triggers O(n^2) behavior in your platform's qsort().
144#
07800601 145# Define NO_EXTERNAL_GREP if you don't want "perf grep" to ever call
d24e473e 146# your external grep (e.g., if your system lacks grep, if its grep is
07800601 147# broken, or spawning external process is slower than built-in grep perf has).
e0143bad 148
07800601
IM
149PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
150 @$(SHELL_PATH) ./PERF-VERSION-GEN
151-include PERF-VERSION-FILE
e0143bad 152
d24e473e
IM
153uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
154uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
155uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
156uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
157uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
158uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
de9ac07b 159
d24e473e 160# CFLAGS and LDFLAGS are for the users to override from the command line.
de9ac07b 161
d24e473e 162CFLAGS = -g -O2 -Wall
07800601 163LDFLAGS = -lpthread -lrt
d24e473e
IM
164ALL_CFLAGS = $(CFLAGS)
165ALL_LDFLAGS = $(LDFLAGS)
166STRIP ?= strip
167
168# Among the variables below, these:
07800601 169# perfexecdir
d24e473e
IM
170# template_dir
171# mandir
172# infodir
173# htmldir
07800601 174# ETC_PERFCONFIG (but not sysconfdir)
d24e473e 175# can be specified as a relative path some/where/else;
07800601 176# this is interpreted as relative to $(prefix) and "perf" at
d24e473e
IM
177# runtime figures out where they are based on the path to the executable.
178# This can help installing the suite in a relocatable way.
179
180prefix = $(HOME)
181bindir_relative = bin
182bindir = $(prefix)/$(bindir_relative)
183mandir = share/man
184infodir = share/info
07800601 185perfexecdir = libexec/perf-core
d24e473e 186sharedir = $(prefix)/share
07800601
IM
187template_dir = share/perf-core/templates
188htmldir = share/doc/perf-doc
d24e473e
IM
189ifeq ($(prefix),/usr)
190sysconfdir = /etc
07800601 191ETC_PERFCONFIG = $(sysconfdir)/perfconfig
d24e473e
IM
192else
193sysconfdir = $(prefix)/etc
07800601 194ETC_PERFCONFIG = etc/perfconfig
d24e473e
IM
195endif
196lib = lib
197# DESTDIR=
198
d24e473e
IM
199export prefix bindir sharedir sysconfdir
200
201CC = gcc
202AR = ar
203RM = rm -f
204TAR = tar
205FIND = find
206INSTALL = install
207RPMBUILD = rpmbuild
d24e473e
IM
208PTHREAD_LIBS = -lpthread
209
d24e473e
IM
210# sparse is architecture-neutral, which means that we need to tell it
211# explicitly what architecture to check for. Fix this up for yours..
212SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
213
214
215
216### --- END CONFIGURATION SECTION ---
217
218# Those must not be GNU-specific; they are shared with perl/ which may
219# be built by a different compiler. (Note that this is an artifact now
220# but it still might be nice to keep that distinction.)
221BASIC_CFLAGS =
222BASIC_LDFLAGS =
223
224# Guard against environment variables
225BUILTIN_OBJS =
226BUILT_INS =
227COMPAT_CFLAGS =
228COMPAT_OBJS =
229LIB_H =
230LIB_OBJS =
231PROGRAMS =
232SCRIPT_PERL =
233SCRIPT_SH =
234TEST_PROGRAMS =
235
07800601
IM
236#
237# No scripts right now:
238#
239
240# SCRIPT_SH += perf-am.sh
241
242#
243# No Perl scripts right now:
244#
245
246# SCRIPT_PERL += perf-add--interactive.perl
d24e473e
IM
247
248SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
07800601 249 $(patsubst %.perl,%,$(SCRIPT_PERL))
d24e473e
IM
250
251# Empty...
252EXTRA_PROGRAMS =
253
07800601 254# ... and all the rest that could be moved out of bindir to perfexecdir
d24e473e 255PROGRAMS += $(EXTRA_PROGRAMS)
07800601
IM
256
257#
258# None right now:
259#
260# PROGRAMS += perf-fast-import$X
d24e473e
IM
261
262# List built-in command $C whose implementation cmd_$C() is not in
263# builtin-$C.o but is linked in as part of some other command.
07800601
IM
264BUILT_INS += $(patsubst builtin-%.o,perf-%$X,$(BUILTIN_OBJS))
265
266#
267# None right now:
268#
269# BUILT_INS += perf-init $X
270
271# what 'all' will build and 'install' will install, in perfexecdir
d24e473e
IM
272ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
273
07800601
IM
274# what 'all' will build but not install in perfexecdir
275OTHER_PROGRAMS = perf$X
d24e473e
IM
276
277# Set paths to tools early so that they can be used for version tests.
278ifndef SHELL_PATH
279 SHELL_PATH = /bin/sh
280endif
281ifndef PERL_PATH
282 PERL_PATH = /usr/bin/perl
283endif
284
285export PERL_PATH
286
07800601
IM
287LIB_FILE=libperf.a
288
289LIB_H += ../../include/linux/perf_counter.h
d24e473e 290LIB_H += levenshtein.h
d24e473e 291LIB_H += parse-options.h
d24e473e 292LIB_H += quote.h
d24e473e 293LIB_H += strbuf.h
07800601 294LIB_H += run-command.h
d24e473e
IM
295
296LIB_OBJS += abspath.o
297LIB_OBJS += alias.o
d24e473e 298LIB_OBJS += config.o
d24e473e 299LIB_OBJS += ctype.o
d24e473e 300LIB_OBJS += exec_cmd.o
d24e473e 301LIB_OBJS += help.o
d24e473e 302LIB_OBJS += levenshtein.o
d24e473e 303LIB_OBJS += parse-options.o
d24e473e 304LIB_OBJS += path.o
d24e473e 305LIB_OBJS += run-command.o
07800601 306LIB_OBJS += quote.o
d24e473e 307LIB_OBJS += strbuf.o
d24e473e 308LIB_OBJS += usage.o
d24e473e 309LIB_OBJS += wrapper.o
07800601 310
d24e473e 311BUILTIN_OBJS += builtin-help.o
07800601
IM
312BUILTIN_OBJS += builtin-top.o
313
314PERFLIBS = $(LIB_FILE)
d24e473e
IM
315EXTLIBS =
316
317#
318# Platform specific tweaks
319#
320
321# We choose to avoid "if .. else if .. else .. endif endif"
322# because maintaining the nesting to match is a pain. If
323# we had "elif" things would have been much nicer...
324
d24e473e
IM
325-include config.mak.autogen
326-include config.mak
327
328ifeq ($(uname_S),Darwin)
329 ifndef NO_FINK
330 ifeq ($(shell test -d /sw/lib && echo y),y)
331 BASIC_CFLAGS += -I/sw/include
332 BASIC_LDFLAGS += -L/sw/lib
333 endif
334 endif
335 ifndef NO_DARWIN_PORTS
336 ifeq ($(shell test -d /opt/local/lib && echo y),y)
337 BASIC_CFLAGS += -I/opt/local/include
338 BASIC_LDFLAGS += -L/opt/local/lib
339 endif
340 endif
341 PTHREAD_LIBS =
342endif
343
344ifndef CC_LD_DYNPATH
345 ifdef NO_R_TO_GCC_LINKER
346 # Some gcc does not accept and pass -R to the linker to specify
347 # the runtime dynamic library path.
348 CC_LD_DYNPATH = -Wl,-rpath,
349 else
350 CC_LD_DYNPATH = -R
351 endif
352endif
353
d24e473e
IM
354ifdef ZLIB_PATH
355 BASIC_CFLAGS += -I$(ZLIB_PATH)/include
356 EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
357endif
358EXTLIBS += -lz
359
d24e473e
IM
360ifdef NEEDS_SOCKET
361 EXTLIBS += -lsocket
362endif
363ifdef NEEDS_NSL
364 EXTLIBS += -lnsl
365endif
366ifdef NO_D_TYPE_IN_DIRENT
367 BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
368endif
369ifdef NO_D_INO_IN_DIRENT
370 BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
371endif
372ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
373 BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
374endif
375ifdef USE_NSEC
376 BASIC_CFLAGS += -DUSE_NSEC
377endif
378ifdef USE_ST_TIMESPEC
379 BASIC_CFLAGS += -DUSE_ST_TIMESPEC
380endif
381ifdef NO_NSEC
382 BASIC_CFLAGS += -DNO_NSEC
383endif
384ifdef NO_C99_FORMAT
385 BASIC_CFLAGS += -DNO_C99_FORMAT
386endif
387ifdef SNPRINTF_RETURNS_BOGUS
388 COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
389 COMPAT_OBJS += compat/snprintf.o
390endif
391ifdef FREAD_READS_DIRECTORIES
392 COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
393 COMPAT_OBJS += compat/fopen.o
394endif
395ifdef NO_SYMLINK_HEAD
396 BASIC_CFLAGS += -DNO_SYMLINK_HEAD
397endif
398ifdef NO_STRCASESTR
399 COMPAT_CFLAGS += -DNO_STRCASESTR
400 COMPAT_OBJS += compat/strcasestr.o
401endif
d24e473e
IM
402ifdef NO_STRTOUMAX
403 COMPAT_CFLAGS += -DNO_STRTOUMAX
404 COMPAT_OBJS += compat/strtoumax.o
405endif
406ifdef NO_STRTOULL
407 COMPAT_CFLAGS += -DNO_STRTOULL
408endif
409ifdef NO_SETENV
410 COMPAT_CFLAGS += -DNO_SETENV
411 COMPAT_OBJS += compat/setenv.o
412endif
413ifdef NO_MKDTEMP
414 COMPAT_CFLAGS += -DNO_MKDTEMP
415 COMPAT_OBJS += compat/mkdtemp.o
416endif
417ifdef NO_UNSETENV
418 COMPAT_CFLAGS += -DNO_UNSETENV
419 COMPAT_OBJS += compat/unsetenv.o
420endif
421ifdef NO_SYS_SELECT_H
422 BASIC_CFLAGS += -DNO_SYS_SELECT_H
423endif
424ifdef NO_MMAP
425 COMPAT_CFLAGS += -DNO_MMAP
426 COMPAT_OBJS += compat/mmap.o
427else
428 ifdef USE_WIN32_MMAP
429 COMPAT_CFLAGS += -DUSE_WIN32_MMAP
430 COMPAT_OBJS += compat/win32mmap.o
431 endif
432endif
433ifdef NO_PREAD
434 COMPAT_CFLAGS += -DNO_PREAD
435 COMPAT_OBJS += compat/pread.o
436endif
437ifdef NO_FAST_WORKING_DIRECTORY
438 BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
439endif
440ifdef NO_TRUSTABLE_FILEMODE
441 BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
442endif
443ifdef NO_IPV6
444 BASIC_CFLAGS += -DNO_IPV6
445endif
446ifdef NO_UINTMAX_T
447 BASIC_CFLAGS += -Duintmax_t=uint32_t
448endif
449ifdef NO_SOCKADDR_STORAGE
450ifdef NO_IPV6
451 BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
452else
453 BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
454endif
455endif
456ifdef NO_INET_NTOP
457 LIB_OBJS += compat/inet_ntop.o
458endif
459ifdef NO_INET_PTON
460 LIB_OBJS += compat/inet_pton.o
461endif
462
463ifdef NO_ICONV
464 BASIC_CFLAGS += -DNO_ICONV
465endif
466
467ifdef OLD_ICONV
468 BASIC_CFLAGS += -DOLD_ICONV
469endif
470
471ifdef NO_DEFLATE_BOUND
472 BASIC_CFLAGS += -DNO_DEFLATE_BOUND
473endif
474
475ifdef PPC_SHA1
476 SHA1_HEADER = "ppc/sha1.h"
477 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
478else
479ifdef ARM_SHA1
480 SHA1_HEADER = "arm/sha1.h"
481 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
482else
483ifdef MOZILLA_SHA1
484 SHA1_HEADER = "mozilla-sha1/sha1.h"
485 LIB_OBJS += mozilla-sha1/sha1.o
486else
487 SHA1_HEADER = <openssl/sha.h>
488 EXTLIBS += $(LIB_4_CRYPTO)
489endif
490endif
491endif
492ifdef NO_PERL_MAKEMAKER
493 export NO_PERL_MAKEMAKER
494endif
495ifdef NO_HSTRERROR
496 COMPAT_CFLAGS += -DNO_HSTRERROR
497 COMPAT_OBJS += compat/hstrerror.o
498endif
499ifdef NO_MEMMEM
500 COMPAT_CFLAGS += -DNO_MEMMEM
501 COMPAT_OBJS += compat/memmem.o
502endif
503ifdef INTERNAL_QSORT
504 COMPAT_CFLAGS += -DINTERNAL_QSORT
505 COMPAT_OBJS += compat/qsort.o
506endif
507ifdef RUNTIME_PREFIX
508 COMPAT_CFLAGS += -DRUNTIME_PREFIX
509endif
510
d24e473e
IM
511ifdef DIR_HAS_BSD_GROUP_SEMANTICS
512 COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
513endif
514ifdef NO_EXTERNAL_GREP
515 BASIC_CFLAGS += -DNO_EXTERNAL_GREP
516endif
517
d24e473e
IM
518ifeq ($(PERL_PATH),)
519NO_PERL=NoThanks
520endif
521
522QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
523QUIET_SUBDIR1 =
524
525ifneq ($(findstring $(MAKEFLAGS),w),w)
526PRINT_DIR = --no-print-directory
527else # "make -w"
528NO_SUBDIR = :
529endif
530
531ifneq ($(findstring $(MAKEFLAGS),s),s)
532ifndef V
533 QUIET_CC = @echo ' ' CC $@;
534 QUIET_AR = @echo ' ' AR $@;
535 QUIET_LINK = @echo ' ' LINK $@;
536 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
537 QUIET_GEN = @echo ' ' GEN $@;
538 QUIET_SUBDIR0 = +@subdir=
539 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
540 $(MAKE) $(PRINT_DIR) -C $$subdir
541 export V
542 export QUIET_GEN
543 export QUIET_BUILT_IN
544endif
545endif
546
547ifdef ASCIIDOC8
548 export ASCIIDOC8
549endif
550
551# Shell quote (do not use $(call) to accommodate ancient setups);
552
553SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
07800601 554ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
d24e473e
IM
555
556DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
557bindir_SQ = $(subst ','\'',$(bindir))
558bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
559mandir_SQ = $(subst ','\'',$(mandir))
560infodir_SQ = $(subst ','\'',$(infodir))
07800601 561perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
d24e473e
IM
562template_dir_SQ = $(subst ','\'',$(template_dir))
563htmldir_SQ = $(subst ','\'',$(htmldir))
564prefix_SQ = $(subst ','\'',$(prefix))
565
566SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
567PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
d24e473e 568
07800601 569LIBS = $(PERFLIBS) $(EXTLIBS)
d24e473e
IM
570
571BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
572 $(COMPAT_CFLAGS)
573LIB_OBJS += $(COMPAT_OBJS)
574
575ALL_CFLAGS += $(BASIC_CFLAGS)
576ALL_LDFLAGS += $(BASIC_LDFLAGS)
577
578export TAR INSTALL DESTDIR SHELL_PATH
579
580
581### Build rules
582
583SHELL = $(SHELL_PATH)
584
07800601 585all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS
d24e473e 586ifneq (,$X)
07800601 587 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
d24e473e
IM
588endif
589
590all::
d24e473e
IM
591
592please_set_SHELL_PATH_to_a_more_modern_shell:
593 @$$(:)
594
595shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
596
07800601
IM
597strip: $(PROGRAMS) perf$X
598 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) perf$X
d24e473e 599
07800601
IM
600perf.o: perf.c common-cmds.h PERF-CFLAGS
601 $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
602 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
d24e473e
IM
603 $(ALL_CFLAGS) -c $(filter %.c,$^)
604
07800601
IM
605perf$X: perf.o $(BUILTIN_OBJS) $(PERFLIBS)
606 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ perf.o \
d24e473e
IM
607 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
608
07800601 609builtin-help.o: builtin-help.c common-cmds.h PERF-CFLAGS
d24e473e 610 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
07800601
IM
611 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
612 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
613 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
d24e473e 614
07800601 615$(BUILT_INS): perf$X
d24e473e 616 $(QUIET_BUILT_IN)$(RM) $@ && \
07800601
IM
617 ln perf$X $@ 2>/dev/null || \
618 ln -s perf$X $@ 2>/dev/null || \
619 cp perf$X $@
d24e473e
IM
620
621common-cmds.h: ./generate-cmdlist.sh command-list.txt
622
07800601 623common-cmds.h: $(wildcard Documentation/perf-*.txt)
d24e473e
IM
624 $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
625
626$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
627 $(QUIET_GEN)$(RM) $@ $@+ && \
628 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
629 -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
630 -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
07800601 631 -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
d24e473e
IM
632 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
633 $@.sh >$@+ && \
634 chmod +x $@+ && \
635 mv $@+ $@
636
d24e473e
IM
637configure: configure.ac
638 $(QUIET_GEN)$(RM) $@ $<+ && \
07800601 639 sed -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
d24e473e
IM
640 $< > $<+ && \
641 autoconf -o $@ $<+ && \
642 $(RM) $<+
643
07800601
IM
644# These can record PERF_VERSION
645perf.o perf.spec \
d24e473e
IM
646 $(patsubst %.sh,%,$(SCRIPT_SH)) \
647 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
07800601 648 : PERF-VERSION-FILE
d24e473e 649
07800601 650%.o: %.c PERF-CFLAGS
d24e473e 651 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
07800601 652%.s: %.c PERF-CFLAGS
d24e473e
IM
653 $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
654%.o: %.S
655 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
656
07800601 657exec_cmd.o: exec_cmd.c PERF-CFLAGS
d24e473e 658 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
07800601 659 '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
d24e473e
IM
660 '-DBINDIR="$(bindir_relative_SQ)"' \
661 '-DPREFIX="$(prefix_SQ)"' \
662 $<
663
07800601
IM
664builtin-init-db.o: builtin-init-db.c PERF-CFLAGS
665 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_PERF_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
d24e473e 666
07800601
IM
667config.o: config.c PERF-CFLAGS
668 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
d24e473e 669
07800601 670perf-%$X: %.o $(PERFLIBS)
d24e473e
IM
671 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
672
d24e473e 673$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
07800601 674$(patsubst perf-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
d24e473e
IM
675builtin-revert.o wt-status.o: wt-status.h
676
677$(LIB_FILE): $(LIB_OBJS)
678 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
679
d24e473e
IM
680TAGS:
681 $(RM) TAGS
682 $(FIND) . -name '*.[hcS]' -print | xargs etags -a
683
684tags:
685 $(RM) tags
686 $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
687
688cscope:
689 $(RM) cscope*
690 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
691
692### Detect prefix changes
693TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
07800601 694 $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
d24e473e 695
07800601 696PERF-CFLAGS: .FORCE-PERF-CFLAGS
d24e473e 697 @FLAGS='$(TRACK_CFLAGS)'; \
07800601 698 if test x"$$FLAGS" != x"`cat PERF-CFLAGS 2>/dev/null`" ; then \
d24e473e 699 echo 1>&2 " * new build flags or prefix"; \
07800601 700 echo "$$FLAGS" >PERF-CFLAGS; \
d24e473e
IM
701 fi
702
703# We need to apply sq twice, once to protect from the shell
07800601 704# that runs PERF-BUILD-OPTIONS, and then again to protect it
d24e473e 705# and the first level quoting from the shell that runs "echo".
07800601 706PERF-BUILD-OPTIONS: .FORCE-PERF-BUILD-OPTIONS
d24e473e
IM
707 @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
708 @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
709 @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
710 @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
711
d24e473e
IM
712### Testing rules
713
6f06ccbc
IM
714#
715# None right now:
716#
717# TEST_PROGRAMS += test-something$X
d24e473e
IM
718
719all:: $(TEST_PROGRAMS)
720
721# GNU make supports exporting all variables by "export" without parameters.
722# However, the environment gets quite big, and some programs have problems
723# with that.
724
725export NO_SVN_TESTS
726
d24e473e
IM
727check: common-cmds.h
728 if sparse; \
729 then \
730 for i in *.c; \
731 do \
732 sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
733 done; \
734 else \
735 echo 2>&1 "Did you mean 'make test'?"; \
736 exit 1; \
737 fi
738
739remove-dashes:
740 ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
741
742### Installation rules
743
744ifneq ($(filter /%,$(firstword $(template_dir))),)
745template_instdir = $(template_dir)
746else
747template_instdir = $(prefix)/$(template_dir)
748endif
749export template_instdir
750
07800601
IM
751ifneq ($(filter /%,$(firstword $(perfexecdir))),)
752perfexec_instdir = $(perfexecdir)
d24e473e 753else
07800601 754perfexec_instdir = $(prefix)/$(perfexecdir)
d24e473e 755endif
07800601
IM
756perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
757export perfexec_instdir
d24e473e
IM
758
759install: all
760 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
07800601
IM
761 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
762 $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
763 $(INSTALL) perf$X perf-upload-pack$X perf-receive-pack$X perf-upload-archive$X perf-shell$X perf-cvsserver '$(DESTDIR_SQ)$(bindir_SQ)'
d24e473e
IM
764 $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
765 $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
d24e473e 766ifneq (,$X)
07800601 767 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), $(RM) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$p';)
d24e473e
IM
768endif
769 bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
07800601
IM
770 execdir=$$(cd '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' && pwd) && \
771 { $(RM) "$$execdir/perf-add$X" && \
772 ln "$$bindir/perf$X" "$$execdir/perf-add$X" 2>/dev/null || \
773 cp "$$bindir/perf$X" "$$execdir/perf-add$X"; } && \
774 { for p in $(filter-out perf-add$X,$(BUILT_INS)); do \
d24e473e 775 $(RM) "$$execdir/$$p" && \
07800601
IM
776 ln "$$execdir/perf-add$X" "$$execdir/$$p" 2>/dev/null || \
777 ln -s "perf-add$X" "$$execdir/$$p" 2>/dev/null || \
778 cp "$$execdir/perf-add$X" "$$execdir/$$p" || exit; \
d24e473e 779 done } && \
07800601 780 ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/perf-add$X"
d24e473e 781
d24e473e
IM
782### Maintainer's dist rules
783
07800601
IM
784perf.spec: perf.spec.in
785 sed -e 's/@@VERSION@@/$(PERF_VERSION)/g' < $< > $@+
d24e473e
IM
786 mv $@+ $@
787
07800601
IM
788PERF_TARNAME=perf-$(PERF_VERSION)
789dist: perf.spec perf-archive$(X) configure
790 ./perf-archive --format=tar \
791 --prefix=$(PERF_TARNAME)/ HEAD^{tree} > $(PERF_TARNAME).tar
792 @mkdir -p $(PERF_TARNAME)
793 @cp perf.spec configure $(PERF_TARNAME)
794 @echo $(PERF_VERSION) > $(PERF_TARNAME)/version
07800601
IM
795 $(TAR) rf $(PERF_TARNAME).tar \
796 $(PERF_TARNAME)/perf.spec \
797 $(PERF_TARNAME)/configure \
6f06ccbc 798 $(PERF_TARNAME)/version
07800601
IM
799 @$(RM) -r $(PERF_TARNAME)
800 gzip -f -9 $(PERF_TARNAME).tar
d24e473e
IM
801
802rpm: dist
07800601 803 $(RPMBUILD) -ta $(PERF_TARNAME).tar.gz
d24e473e 804
d24e473e
IM
805### Cleaning rules
806
807distclean: clean
808 $(RM) configure
e0143bad
IM
809
810clean:
07800601
IM
811 $(RM) *.o $(LIB_FILE)
812 $(RM) $(ALL_PROGRAMS) $(BUILT_INS) perf$X
d24e473e
IM
813 $(RM) $(TEST_PROGRAMS)
814 $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
815 $(RM) -r autom4te.cache
816 $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
07800601
IM
817 $(RM) -r $(PERF_TARNAME) .doc-tmp-dir
818 $(RM) $(PERF_TARNAME).tar.gz perf-core_$(PERF_VERSION)-*.tar.gz
d24e473e 819 $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
6f06ccbc 820 $(RM) PERF-VERSION-FILE PERF-CFLAGS PERF-BUILD-OPTIONS
d24e473e
IM
821
822.PHONY: all install clean strip
823.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
07800601
IM
824.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
825.PHONY: .FORCE-PERF-BUILD-OPTIONS
d24e473e 826
07800601 827### Make sure built-ins do not have dups and listed in perf.c
d24e473e
IM
828#
829check-builtins::
830 ./check-builtins.sh
831
832### Test suite coverage testing
833#
834.PHONY: coverage coverage-clean coverage-build coverage-report
835
836coverage:
837 $(MAKE) coverage-build
838 $(MAKE) coverage-report
839
840coverage-clean:
841 rm -f *.gcda *.gcno
842
843COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
844COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov
845
846coverage-build: coverage-clean
847 $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
848 $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
849 -j1 test
850
851coverage-report:
852 gcov -b *.c
853 grep '^function.*called 0 ' *.c.gcov \
854 | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
855 | tee coverage-untested-functions