Makefile 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. ifeq ("$(origin O)", "command line")
  2. OUTPUT := $(O)/
  3. endif
  4. # The default target of this Makefile is...
  5. all::
  6. # Define V=1 to have a more verbose compile.
  7. # Define V=2 to have an even more verbose compile.
  8. #
  9. # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
  10. # or vsnprintf() return -1 instead of number of characters which would
  11. # have been written to the final string if enough space had been available.
  12. #
  13. # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
  14. # when attempting to read from an fopen'ed directory.
  15. #
  16. # Define NO_OPENSSL environment variable if you do not have OpenSSL.
  17. # This also implies MOZILLA_SHA1.
  18. #
  19. # Define CURLDIR=/foo/bar if your curl header and library files are in
  20. # /foo/bar/include and /foo/bar/lib directories.
  21. #
  22. # Define EXPATDIR=/foo/bar if your expat header and library files are in
  23. # /foo/bar/include and /foo/bar/lib directories.
  24. #
  25. # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
  26. #
  27. # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
  28. # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
  29. #
  30. # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
  31. # do not support the 'size specifiers' introduced by C99, namely ll, hh,
  32. # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
  33. # some C compilers supported these specifiers prior to C99 as an extension.
  34. #
  35. # Define NO_STRCASESTR if you don't have strcasestr.
  36. #
  37. # Define NO_MEMMEM if you don't have memmem.
  38. #
  39. # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
  40. # If your compiler also does not support long long or does not have
  41. # strtoull, define NO_STRTOULL.
  42. #
  43. # Define NO_SETENV if you don't have setenv in the C library.
  44. #
  45. # Define NO_UNSETENV if you don't have unsetenv in the C library.
  46. #
  47. # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
  48. #
  49. # Define NO_SYS_SELECT_H if you don't have sys/select.h.
  50. #
  51. # Define NO_SYMLINK_HEAD if you never want .perf/HEAD to be a symbolic link.
  52. # Enable it on Windows. By default, symrefs are still used.
  53. #
  54. # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
  55. # tests. These tests take up a significant amount of the total test time
  56. # but are not needed unless you plan to talk to SVN repos.
  57. #
  58. # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
  59. # installed in /sw, but don't want PERF to link against any libraries
  60. # installed there. If defined you may specify your own (or Fink's)
  61. # include directories and library directories by defining CFLAGS
  62. # and LDFLAGS appropriately.
  63. #
  64. # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
  65. # have DarwinPorts installed in /opt/local, but don't want PERF to
  66. # link against any libraries installed there. If defined you may
  67. # specify your own (or DarwinPort's) include directories and
  68. # library directories by defining CFLAGS and LDFLAGS appropriately.
  69. #
  70. # Define PPC_SHA1 environment variable when running make to make use of
  71. # a bundled SHA1 routine optimized for PowerPC.
  72. #
  73. # Define ARM_SHA1 environment variable when running make to make use of
  74. # a bundled SHA1 routine optimized for ARM.
  75. #
  76. # Define MOZILLA_SHA1 environment variable when running make to make use of
  77. # a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
  78. # on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
  79. # choice) has very fast version optimized for i586.
  80. #
  81. # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
  82. #
  83. # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
  84. #
  85. # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
  86. # Patrick Mauritz).
  87. #
  88. # Define NO_MMAP if you want to avoid mmap.
  89. #
  90. # Define NO_PTHREADS if you do not have or do not want to use Pthreads.
  91. #
  92. # Define NO_PREAD if you have a problem with pread() system call (e.g.
  93. # cygwin.dll before v1.5.22).
  94. #
  95. # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
  96. # generally faster on your platform than accessing the working directory.
  97. #
  98. # Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
  99. # the executable mode bit, but doesn't really do so.
  100. #
  101. # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
  102. #
  103. # Define NO_SOCKADDR_STORAGE if your platform does not have struct
  104. # sockaddr_storage.
  105. #
  106. # Define NO_ICONV if your libc does not properly support iconv.
  107. #
  108. # Define OLD_ICONV if your library has an old iconv(), where the second
  109. # (input buffer pointer) parameter is declared with type (const char **).
  110. #
  111. # Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
  112. #
  113. # Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
  114. # that tells runtime paths to dynamic libraries;
  115. # "-Wl,-rpath=/path/lib" is used instead.
  116. #
  117. # Define USE_NSEC below if you want perf to care about sub-second file mtimes
  118. # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
  119. # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
  120. # randomly break unless your underlying filesystem supports those sub-second
  121. # times (my ext3 doesn't).
  122. #
  123. # Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
  124. # "st_ctim"
  125. #
  126. # Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
  127. # available. This automatically turns USE_NSEC off.
  128. #
  129. # Define USE_STDEV below if you want perf to care about the underlying device
  130. # change being considered an inode change from the update-index perspective.
  131. #
  132. # Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
  133. # field that counts the on-disk footprint in 512-byte blocks.
  134. #
  135. # Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
  136. #
  137. # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
  138. #
  139. # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
  140. # MakeMaker (e.g. using ActiveState under Cygwin).
  141. #
  142. # Define NO_PERL if you do not want Perl scripts or libraries at all.
  143. #
  144. # Define INTERNAL_QSORT to use Git's implementation of qsort(), which
  145. # is a simplified version of the merge sort used in glibc. This is
  146. # recommended if Git triggers O(n^2) behavior in your platform's qsort().
  147. #
  148. # Define NO_EXTERNAL_GREP if you don't want "perf grep" to ever call
  149. # your external grep (e.g., if your system lacks grep, if its grep is
  150. # broken, or spawning external process is slower than built-in grep perf has).
  151. #
  152. # Define LDFLAGS=-static to build a static binary.
  153. #
  154. # Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
  155. #
  156. # Define NO_DWARF if you do not want debug-info analysis feature at all.
  157. $(shell sh -c 'mkdir -p $(OUTPUT)scripts/python/Perf-Trace-Util/' 2> /dev/null)
  158. $(shell sh -c 'mkdir -p $(OUTPUT)util/scripting-engines/' 2> /dev/null)
  159. $(shell sh -c 'mkdir $(OUTPUT)bench' 2> /dev/null)
  160. $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
  161. @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
  162. -include $(OUTPUT)PERF-VERSION-FILE
  163. uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
  164. uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
  165. uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
  166. uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
  167. uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
  168. uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
  169. # CFLAGS and LDFLAGS are for the users to override from the command line.
  170. #
  171. # Include saner warnings here, which can catch bugs:
  172. #
  173. EXTRA_WARNINGS := -Wformat
  174. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
  175. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
  176. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
  177. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
  178. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
  179. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
  180. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector
  181. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
  182. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
  183. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
  184. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
  185. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
  186. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var
  187. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
  188. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
  189. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
  190. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes
  191. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs
  192. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
  193. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
  194. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
  195. ifeq ("$(origin DEBUG)", "command line")
  196. PERF_DEBUG = $(DEBUG)
  197. endif
  198. ifndef PERF_DEBUG
  199. CFLAGS_OPTIMIZE = -O6
  200. endif
  201. CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
  202. EXTLIBS = -lpthread -lrt -lelf -lm
  203. ALL_CFLAGS = $(CFLAGS)
  204. ALL_LDFLAGS = $(LDFLAGS)
  205. STRIP ?= strip
  206. # Among the variables below, these:
  207. # perfexecdir
  208. # template_dir
  209. # mandir
  210. # infodir
  211. # htmldir
  212. # ETC_PERFCONFIG (but not sysconfdir)
  213. # can be specified as a relative path some/where/else;
  214. # this is interpreted as relative to $(prefix) and "perf" at
  215. # runtime figures out where they are based on the path to the executable.
  216. # This can help installing the suite in a relocatable way.
  217. # Make the path relative to DESTDIR, not to prefix
  218. ifndef DESTDIR
  219. prefix = $(HOME)
  220. endif
  221. bindir_relative = bin
  222. bindir = $(prefix)/$(bindir_relative)
  223. mandir = share/man
  224. infodir = share/info
  225. perfexecdir = libexec/perf-core
  226. sharedir = $(prefix)/share
  227. template_dir = share/perf-core/templates
  228. htmldir = share/doc/perf-doc
  229. ifeq ($(prefix),/usr)
  230. sysconfdir = /etc
  231. ETC_PERFCONFIG = $(sysconfdir)/perfconfig
  232. else
  233. sysconfdir = $(prefix)/etc
  234. ETC_PERFCONFIG = etc/perfconfig
  235. endif
  236. lib = lib
  237. export prefix bindir sharedir sysconfdir
  238. CC = $(CROSS_COMPILE)gcc
  239. AR = $(CROSS_COMPILE)ar
  240. RM = rm -f
  241. TAR = tar
  242. FIND = find
  243. INSTALL = install
  244. RPMBUILD = rpmbuild
  245. PTHREAD_LIBS = -lpthread
  246. # sparse is architecture-neutral, which means that we need to tell it
  247. # explicitly what architecture to check for. Fix this up for yours..
  248. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
  249. ifeq ($(V), 2)
  250. QUIET_STDERR = ">/dev/null"
  251. else
  252. QUIET_STDERR = ">/dev/null 2>&1"
  253. endif
  254. BITBUCKET = "/dev/null"
  255. ifneq ($(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)
  256. BITBUCKET = .perf.dev.null
  257. endif
  258. ifeq ($(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)
  259. CFLAGS := $(CFLAGS) -fstack-protector-all
  260. endif
  261. ### --- END CONFIGURATION SECTION ---
  262. # Those must not be GNU-specific; they are shared with perl/ which may
  263. # be built by a different compiler. (Note that this is an artifact now
  264. # but it still might be nice to keep that distinction.)
  265. BASIC_CFLAGS = -Iutil/include
  266. BASIC_LDFLAGS =
  267. # Guard against environment variables
  268. BUILTIN_OBJS =
  269. BUILT_INS =
  270. COMPAT_CFLAGS =
  271. COMPAT_OBJS =
  272. LIB_H =
  273. LIB_OBJS =
  274. SCRIPT_PERL =
  275. SCRIPT_SH =
  276. TEST_PROGRAMS =
  277. SCRIPT_SH += perf-archive.sh
  278. #
  279. # No Perl scripts right now:
  280. #
  281. # SCRIPT_PERL += perf-add--interactive.perl
  282. SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
  283. $(patsubst %.perl,%,$(SCRIPT_PERL))
  284. # Empty...
  285. EXTRA_PROGRAMS =
  286. # ... and all the rest that could be moved out of bindir to perfexecdir
  287. PROGRAMS += $(EXTRA_PROGRAMS)
  288. #
  289. # Single 'perf' binary right now:
  290. #
  291. PROGRAMS += $(OUTPUT)perf
  292. # List built-in command $C whose implementation cmd_$C() is not in
  293. # builtin-$C.o but is linked in as part of some other command.
  294. #
  295. # what 'all' will build and 'install' will install, in perfexecdir
  296. ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
  297. # what 'all' will build but not install in perfexecdir
  298. OTHER_PROGRAMS = $(OUTPUT)perf$X
  299. # Set paths to tools early so that they can be used for version tests.
  300. ifndef SHELL_PATH
  301. SHELL_PATH = /bin/sh
  302. endif
  303. ifndef PERL_PATH
  304. PERL_PATH = /usr/bin/perl
  305. endif
  306. export PERL_PATH
  307. LIB_FILE=$(OUTPUT)libperf.a
  308. LIB_H += ../../include/linux/perf_event.h
  309. LIB_H += ../../include/linux/rbtree.h
  310. LIB_H += ../../include/linux/list.h
  311. LIB_H += ../../include/linux/hash.h
  312. LIB_H += ../../include/linux/stringify.h
  313. LIB_H += util/include/linux/bitmap.h
  314. LIB_H += util/include/linux/bitops.h
  315. LIB_H += util/include/linux/compiler.h
  316. LIB_H += util/include/linux/ctype.h
  317. LIB_H += util/include/linux/kernel.h
  318. LIB_H += util/include/linux/list.h
  319. LIB_H += util/include/linux/module.h
  320. LIB_H += util/include/linux/poison.h
  321. LIB_H += util/include/linux/prefetch.h
  322. LIB_H += util/include/linux/rbtree.h
  323. LIB_H += util/include/linux/string.h
  324. LIB_H += util/include/linux/types.h
  325. LIB_H += util/include/asm/asm-offsets.h
  326. LIB_H += util/include/asm/bitops.h
  327. LIB_H += util/include/asm/bug.h
  328. LIB_H += util/include/asm/byteorder.h
  329. LIB_H += util/include/asm/swab.h
  330. LIB_H += util/include/asm/system.h
  331. LIB_H += util/include/asm/uaccess.h
  332. LIB_H += perf.h
  333. LIB_H += util/cache.h
  334. LIB_H += util/callchain.h
  335. LIB_H += util/build-id.h
  336. LIB_H += util/debug.h
  337. LIB_H += util/debugfs.h
  338. LIB_H += util/event.h
  339. LIB_H += util/exec_cmd.h
  340. LIB_H += util/types.h
  341. LIB_H += util/levenshtein.h
  342. LIB_H += util/map.h
  343. LIB_H += util/parse-options.h
  344. LIB_H += util/parse-events.h
  345. LIB_H += util/quote.h
  346. LIB_H += util/util.h
  347. LIB_H += util/header.h
  348. LIB_H += util/help.h
  349. LIB_H += util/session.h
  350. LIB_H += util/strbuf.h
  351. LIB_H += util/string.h
  352. LIB_H += util/strlist.h
  353. LIB_H += util/svghelper.h
  354. LIB_H += util/run-command.h
  355. LIB_H += util/sigchain.h
  356. LIB_H += util/symbol.h
  357. LIB_H += util/color.h
  358. LIB_H += util/values.h
  359. LIB_H += util/sort.h
  360. LIB_H += util/hist.h
  361. LIB_H += util/thread.h
  362. LIB_H += util/trace-event.h
  363. LIB_H += util/probe-finder.h
  364. LIB_H += util/probe-event.h
  365. LIB_H += util/cpumap.h
  366. LIB_OBJS += $(OUTPUT)util/abspath.o
  367. LIB_OBJS += $(OUTPUT)util/alias.o
  368. LIB_OBJS += $(OUTPUT)util/build-id.o
  369. LIB_OBJS += $(OUTPUT)util/config.o
  370. LIB_OBJS += $(OUTPUT)util/ctype.o
  371. LIB_OBJS += $(OUTPUT)util/debugfs.o
  372. LIB_OBJS += $(OUTPUT)util/environment.o
  373. LIB_OBJS += $(OUTPUT)util/event.o
  374. LIB_OBJS += $(OUTPUT)util/exec_cmd.o
  375. LIB_OBJS += $(OUTPUT)util/help.o
  376. LIB_OBJS += $(OUTPUT)util/levenshtein.o
  377. LIB_OBJS += $(OUTPUT)util/parse-options.o
  378. LIB_OBJS += $(OUTPUT)util/parse-events.o
  379. LIB_OBJS += $(OUTPUT)util/path.o
  380. LIB_OBJS += $(OUTPUT)util/rbtree.o
  381. LIB_OBJS += $(OUTPUT)util/bitmap.o
  382. LIB_OBJS += $(OUTPUT)util/hweight.o
  383. LIB_OBJS += $(OUTPUT)util/find_next_bit.o
  384. LIB_OBJS += $(OUTPUT)util/run-command.o
  385. LIB_OBJS += $(OUTPUT)util/quote.o
  386. LIB_OBJS += $(OUTPUT)util/strbuf.o
  387. LIB_OBJS += $(OUTPUT)util/string.o
  388. LIB_OBJS += $(OUTPUT)util/strlist.o
  389. LIB_OBJS += $(OUTPUT)util/usage.o
  390. LIB_OBJS += $(OUTPUT)util/wrapper.o
  391. LIB_OBJS += $(OUTPUT)util/sigchain.o
  392. LIB_OBJS += $(OUTPUT)util/symbol.o
  393. LIB_OBJS += $(OUTPUT)util/color.o
  394. LIB_OBJS += $(OUTPUT)util/pager.o
  395. LIB_OBJS += $(OUTPUT)util/header.o
  396. LIB_OBJS += $(OUTPUT)util/callchain.o
  397. LIB_OBJS += $(OUTPUT)util/values.o
  398. LIB_OBJS += $(OUTPUT)util/debug.o
  399. LIB_OBJS += $(OUTPUT)util/map.o
  400. LIB_OBJS += $(OUTPUT)util/session.o
  401. LIB_OBJS += $(OUTPUT)util/thread.o
  402. LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
  403. LIB_OBJS += $(OUTPUT)util/trace-event-read.o
  404. LIB_OBJS += $(OUTPUT)util/trace-event-info.o
  405. LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
  406. LIB_OBJS += $(OUTPUT)util/svghelper.o
  407. LIB_OBJS += $(OUTPUT)util/sort.o
  408. LIB_OBJS += $(OUTPUT)util/hist.o
  409. LIB_OBJS += $(OUTPUT)util/probe-event.o
  410. LIB_OBJS += $(OUTPUT)util/util.o
  411. LIB_OBJS += $(OUTPUT)util/cpumap.o
  412. BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
  413. BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
  414. # Benchmark modules
  415. BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
  416. BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
  417. BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
  418. BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
  419. BUILTIN_OBJS += $(OUTPUT)builtin-help.o
  420. BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
  421. BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
  422. BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
  423. BUILTIN_OBJS += $(OUTPUT)builtin-list.o
  424. BUILTIN_OBJS += $(OUTPUT)builtin-record.o
  425. BUILTIN_OBJS += $(OUTPUT)builtin-report.o
  426. BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
  427. BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
  428. BUILTIN_OBJS += $(OUTPUT)builtin-top.o
  429. BUILTIN_OBJS += $(OUTPUT)builtin-trace.o
  430. BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
  431. BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
  432. BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
  433. PERFLIBS = $(LIB_FILE)
  434. #
  435. # Platform specific tweaks
  436. #
  437. # We choose to avoid "if .. else if .. else .. endif endif"
  438. # because maintaining the nesting to match is a pain. If
  439. # we had "elif" things would have been much nicer...
  440. -include config.mak.autogen
  441. -include config.mak
  442. ifeq ($(uname_S),Darwin)
  443. ifndef NO_FINK
  444. ifeq ($(shell test -d /sw/lib && echo y),y)
  445. BASIC_CFLAGS += -I/sw/include
  446. BASIC_LDFLAGS += -L/sw/lib
  447. endif
  448. endif
  449. ifndef NO_DARWIN_PORTS
  450. ifeq ($(shell test -d /opt/local/lib && echo y),y)
  451. BASIC_CFLAGS += -I/opt/local/include
  452. BASIC_LDFLAGS += -L/opt/local/lib
  453. endif
  454. endif
  455. PTHREAD_LIBS =
  456. endif
  457. ifneq ($(OUTPUT),)
  458. BASIC_CFLAGS += -I$(OUTPUT)
  459. endif
  460. ifeq ($(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)
  461. ifneq ($(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)
  462. msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
  463. endif
  464. 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)
  465. BASIC_CFLAGS += -DLIBELF_NO_MMAP
  466. endif
  467. else
  468. msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
  469. endif
  470. ifneq ($(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)
  471. msg := $(warning No libdw.h found or old libdw.h found, disables dwarf support. Please install elfutils-devel/elfutils-dev);
  472. else
  473. ifndef NO_DWARF
  474. BASIC_CFLAGS += -I/usr/include/elfutils -DDWARF_SUPPORT
  475. EXTLIBS += -lelf -ldw
  476. LIB_OBJS += $(OUTPUT)util/probe-finder.o
  477. endif
  478. endif
  479. ifneq ($(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)
  480. msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev);
  481. BASIC_CFLAGS += -DNO_NEWT_SUPPORT
  482. else
  483. EXTLIBS += -lnewt
  484. LIB_OBJS += $(OUTPUT)util/newt.o
  485. endif
  486. ifndef NO_LIBPERL
  487. PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null`
  488. PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
  489. endif
  490. ifneq ($(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)
  491. BASIC_CFLAGS += -DNO_LIBPERL
  492. else
  493. ALL_LDFLAGS += $(PERL_EMBED_LDOPTS)
  494. LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
  495. LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
  496. endif
  497. ifndef NO_LIBPYTHON
  498. PYTHON_EMBED_LDOPTS = `python-config --ldflags 2>/dev/null`
  499. PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
  500. endif
  501. ifneq ($(shell sh -c "(echo '\#include <Python.h>'; echo 'int main(void) { Py_Initialize(); return 0; }') | $(CC) -x c - $(PYTHON_EMBED_CCOPTS) -o $(BITBUCKET) $(PYTHON_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y)
  502. BASIC_CFLAGS += -DNO_LIBPYTHON
  503. else
  504. ALL_LDFLAGS += $(PYTHON_EMBED_LDOPTS)
  505. LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
  506. LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
  507. endif
  508. ifdef NO_DEMANGLE
  509. BASIC_CFLAGS += -DNO_DEMANGLE
  510. else
  511. 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")
  512. ifeq ($(has_bfd),y)
  513. EXTLIBS += -lbfd
  514. else
  515. 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")
  516. ifeq ($(has_bfd_iberty),y)
  517. EXTLIBS += -lbfd -liberty
  518. else
  519. 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")
  520. ifeq ($(has_bfd_iberty_z),y)
  521. EXTLIBS += -lbfd -liberty -lz
  522. else
  523. 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")
  524. ifeq ($(has_cplus_demangle),y)
  525. EXTLIBS += -liberty
  526. BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
  527. else
  528. msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
  529. BASIC_CFLAGS += -DNO_DEMANGLE
  530. endif
  531. endif
  532. endif
  533. endif
  534. endif
  535. ifndef CC_LD_DYNPATH
  536. ifdef NO_R_TO_GCC_LINKER
  537. # Some gcc does not accept and pass -R to the linker to specify
  538. # the runtime dynamic library path.
  539. CC_LD_DYNPATH = -Wl,-rpath,
  540. else
  541. CC_LD_DYNPATH = -R
  542. endif
  543. endif
  544. ifdef NEEDS_SOCKET
  545. EXTLIBS += -lsocket
  546. endif
  547. ifdef NEEDS_NSL
  548. EXTLIBS += -lnsl
  549. endif
  550. ifdef NO_D_TYPE_IN_DIRENT
  551. BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
  552. endif
  553. ifdef NO_D_INO_IN_DIRENT
  554. BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
  555. endif
  556. ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
  557. BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
  558. endif
  559. ifdef USE_NSEC
  560. BASIC_CFLAGS += -DUSE_NSEC
  561. endif
  562. ifdef USE_ST_TIMESPEC
  563. BASIC_CFLAGS += -DUSE_ST_TIMESPEC
  564. endif
  565. ifdef NO_NSEC
  566. BASIC_CFLAGS += -DNO_NSEC
  567. endif
  568. ifdef NO_C99_FORMAT
  569. BASIC_CFLAGS += -DNO_C99_FORMAT
  570. endif
  571. ifdef SNPRINTF_RETURNS_BOGUS
  572. COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
  573. COMPAT_OBJS += $(OUTPUT)compat/snprintf.o
  574. endif
  575. ifdef FREAD_READS_DIRECTORIES
  576. COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
  577. COMPAT_OBJS += $(OUTPUT)compat/fopen.o
  578. endif
  579. ifdef NO_SYMLINK_HEAD
  580. BASIC_CFLAGS += -DNO_SYMLINK_HEAD
  581. endif
  582. ifdef NO_STRCASESTR
  583. COMPAT_CFLAGS += -DNO_STRCASESTR
  584. COMPAT_OBJS += $(OUTPUT)compat/strcasestr.o
  585. endif
  586. ifdef NO_STRTOUMAX
  587. COMPAT_CFLAGS += -DNO_STRTOUMAX
  588. COMPAT_OBJS += $(OUTPUT)compat/strtoumax.o
  589. endif
  590. ifdef NO_STRTOULL
  591. COMPAT_CFLAGS += -DNO_STRTOULL
  592. endif
  593. ifdef NO_SETENV
  594. COMPAT_CFLAGS += -DNO_SETENV
  595. COMPAT_OBJS += $(OUTPUT)compat/setenv.o
  596. endif
  597. ifdef NO_MKDTEMP
  598. COMPAT_CFLAGS += -DNO_MKDTEMP
  599. COMPAT_OBJS += $(OUTPUT)compat/mkdtemp.o
  600. endif
  601. ifdef NO_UNSETENV
  602. COMPAT_CFLAGS += -DNO_UNSETENV
  603. COMPAT_OBJS += $(OUTPUT)compat/unsetenv.o
  604. endif
  605. ifdef NO_SYS_SELECT_H
  606. BASIC_CFLAGS += -DNO_SYS_SELECT_H
  607. endif
  608. ifdef NO_MMAP
  609. COMPAT_CFLAGS += -DNO_MMAP
  610. COMPAT_OBJS += $(OUTPUT)compat/mmap.o
  611. else
  612. ifdef USE_WIN32_MMAP
  613. COMPAT_CFLAGS += -DUSE_WIN32_MMAP
  614. COMPAT_OBJS += $(OUTPUT)compat/win32mmap.o
  615. endif
  616. endif
  617. ifdef NO_PREAD
  618. COMPAT_CFLAGS += -DNO_PREAD
  619. COMPAT_OBJS += $(OUTPUT)compat/pread.o
  620. endif
  621. ifdef NO_FAST_WORKING_DIRECTORY
  622. BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
  623. endif
  624. ifdef NO_TRUSTABLE_FILEMODE
  625. BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
  626. endif
  627. ifdef NO_IPV6
  628. BASIC_CFLAGS += -DNO_IPV6
  629. endif
  630. ifdef NO_UINTMAX_T
  631. BASIC_CFLAGS += -Duintmax_t=uint32_t
  632. endif
  633. ifdef NO_SOCKADDR_STORAGE
  634. ifdef NO_IPV6
  635. BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
  636. else
  637. BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
  638. endif
  639. endif
  640. ifdef NO_INET_NTOP
  641. LIB_OBJS += $(OUTPUT)compat/inet_ntop.o
  642. endif
  643. ifdef NO_INET_PTON
  644. LIB_OBJS += $(OUTPUT)compat/inet_pton.o
  645. endif
  646. ifdef NO_ICONV
  647. BASIC_CFLAGS += -DNO_ICONV
  648. endif
  649. ifdef OLD_ICONV
  650. BASIC_CFLAGS += -DOLD_ICONV
  651. endif
  652. ifdef NO_DEFLATE_BOUND
  653. BASIC_CFLAGS += -DNO_DEFLATE_BOUND
  654. endif
  655. ifdef PPC_SHA1
  656. SHA1_HEADER = "ppc/sha1.h"
  657. LIB_OBJS += $(OUTPUT)ppc/sha1.o ppc/sha1ppc.o
  658. else
  659. ifdef ARM_SHA1
  660. SHA1_HEADER = "arm/sha1.h"
  661. LIB_OBJS += $(OUTPUT)arm/sha1.o $(OUTPUT)arm/sha1_arm.o
  662. else
  663. ifdef MOZILLA_SHA1
  664. SHA1_HEADER = "mozilla-sha1/sha1.h"
  665. LIB_OBJS += $(OUTPUT)mozilla-sha1/sha1.o
  666. else
  667. SHA1_HEADER = <openssl/sha.h>
  668. EXTLIBS += $(LIB_4_CRYPTO)
  669. endif
  670. endif
  671. endif
  672. ifdef NO_PERL_MAKEMAKER
  673. export NO_PERL_MAKEMAKER
  674. endif
  675. ifdef NO_HSTRERROR
  676. COMPAT_CFLAGS += -DNO_HSTRERROR
  677. COMPAT_OBJS += $(OUTPUT)compat/hstrerror.o
  678. endif
  679. ifdef NO_MEMMEM
  680. COMPAT_CFLAGS += -DNO_MEMMEM
  681. COMPAT_OBJS += $(OUTPUT)compat/memmem.o
  682. endif
  683. ifdef INTERNAL_QSORT
  684. COMPAT_CFLAGS += -DINTERNAL_QSORT
  685. COMPAT_OBJS += $(OUTPUT)compat/qsort.o
  686. endif
  687. ifdef RUNTIME_PREFIX
  688. COMPAT_CFLAGS += -DRUNTIME_PREFIX
  689. endif
  690. ifdef DIR_HAS_BSD_GROUP_SEMANTICS
  691. COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
  692. endif
  693. ifdef NO_EXTERNAL_GREP
  694. BASIC_CFLAGS += -DNO_EXTERNAL_GREP
  695. endif
  696. ifeq ($(PERL_PATH),)
  697. NO_PERL=NoThanks
  698. endif
  699. QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
  700. QUIET_SUBDIR1 =
  701. ifneq ($(findstring $(MAKEFLAGS),w),w)
  702. PRINT_DIR = --no-print-directory
  703. else # "make -w"
  704. NO_SUBDIR = :
  705. endif
  706. ifneq ($(findstring $(MAKEFLAGS),s),s)
  707. ifndef V
  708. QUIET_CC = @echo ' ' CC $@;
  709. QUIET_AR = @echo ' ' AR $@;
  710. QUIET_LINK = @echo ' ' LINK $@;
  711. QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
  712. QUIET_GEN = @echo ' ' GEN $@;
  713. QUIET_SUBDIR0 = +@subdir=
  714. QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
  715. $(MAKE) $(PRINT_DIR) -C $$subdir
  716. export V
  717. export QUIET_GEN
  718. export QUIET_BUILT_IN
  719. endif
  720. endif
  721. ifdef ASCIIDOC8
  722. export ASCIIDOC8
  723. endif
  724. # Shell quote (do not use $(call) to accommodate ancient setups);
  725. SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
  726. ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
  727. DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  728. bindir_SQ = $(subst ','\'',$(bindir))
  729. bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
  730. mandir_SQ = $(subst ','\'',$(mandir))
  731. infodir_SQ = $(subst ','\'',$(infodir))
  732. perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
  733. template_dir_SQ = $(subst ','\'',$(template_dir))
  734. htmldir_SQ = $(subst ','\'',$(htmldir))
  735. prefix_SQ = $(subst ','\'',$(prefix))
  736. SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  737. PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
  738. LIBS = $(PERFLIBS) $(EXTLIBS)
  739. BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
  740. $(COMPAT_CFLAGS)
  741. LIB_OBJS += $(COMPAT_OBJS)
  742. ALL_CFLAGS += $(BASIC_CFLAGS)
  743. ALL_LDFLAGS += $(BASIC_LDFLAGS)
  744. export TAR INSTALL DESTDIR SHELL_PATH
  745. ### Build rules
  746. SHELL = $(SHELL_PATH)
  747. all:: .perf.dev.null shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS
  748. ifneq (,$X)
  749. $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
  750. endif
  751. all::
  752. please_set_SHELL_PATH_to_a_more_modern_shell:
  753. @$$(:)
  754. shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
  755. strip: $(PROGRAMS) $(OUTPUT)perf$X
  756. $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf$X
  757. $(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  758. $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
  759. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  760. $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
  761. $(OUTPUT)perf$X: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
  762. $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(OUTPUT)perf.o \
  763. $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
  764. $(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  765. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  766. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  767. '-DPERF_MAN_PATH="$(mandir_SQ)"' \
  768. '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
  769. $(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  770. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  771. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  772. '-DPERF_MAN_PATH="$(mandir_SQ)"' \
  773. '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
  774. $(BUILT_INS): $(OUTPUT)perf$X
  775. $(QUIET_BUILT_IN)$(RM) $@ && \
  776. ln perf$X $@ 2>/dev/null || \
  777. ln -s perf$X $@ 2>/dev/null || \
  778. cp perf$X $@
  779. $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
  780. $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
  781. $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
  782. $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
  783. $(QUIET_GEN)$(RM) $@ $@+ && \
  784. sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
  785. -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
  786. -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
  787. -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
  788. -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
  789. $@.sh >$@+ && \
  790. chmod +x $@+ && \
  791. mv $@+ $(OUTPUT)$@
  792. configure: configure.ac
  793. $(QUIET_GEN)$(RM) $@ $<+ && \
  794. sed -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
  795. $< > $<+ && \
  796. autoconf -o $@ $<+ && \
  797. $(RM) $<+
  798. # These can record PERF_VERSION
  799. $(OUTPUT)perf.o perf.spec \
  800. $(patsubst %.sh,%,$(SCRIPT_SH)) \
  801. $(patsubst %.perl,%,$(SCRIPT_PERL)) \
  802. : $(OUTPUT)PERF-VERSION-FILE
  803. $(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
  804. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
  805. $(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
  806. $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
  807. $(OUTPUT)%.o: %.S
  808. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
  809. $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
  810. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  811. '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
  812. '-DBINDIR="$(bindir_relative_SQ)"' \
  813. '-DPREFIX="$(prefix_SQ)"' \
  814. $<
  815. $(OUTPUT)builtin-init-db.o: builtin-init-db.c $(OUTPUT)PERF-CFLAGS
  816. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_PERF_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
  817. $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
  818. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  819. $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
  820. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  821. # some perf warning policies can't fit to lib/bitmap.c, eg: it warns about variable shadowing
  822. # from <string.h> that comes from kernel headers wrapping.
  823. KBITMAP_FLAGS=`echo $(ALL_CFLAGS) | sed s/-Wshadow// | sed s/-Wswitch-default// | sed s/-Wextra//`
  824. $(OUTPUT)util/bitmap.o: ../../lib/bitmap.c $(OUTPUT)PERF-CFLAGS
  825. $(QUIET_CC)$(CC) -o $@ -c $(KBITMAP_FLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  826. $(OUTPUT)util/hweight.o: ../../lib/hweight.c $(OUTPUT)PERF-CFLAGS
  827. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  828. $(OUTPUT)util/find_next_bit.o: ../../lib/find_next_bit.c $(OUTPUT)PERF-CFLAGS
  829. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  830. $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
  831. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
  832. $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
  833. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
  834. $(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
  835. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
  836. $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
  837. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
  838. $(OUTPUT)perf-%$X: %.o $(PERFLIBS)
  839. $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
  840. $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
  841. $(patsubst perf-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
  842. builtin-revert.o wt-status.o: wt-status.h
  843. $(LIB_FILE): $(LIB_OBJS)
  844. $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
  845. doc:
  846. $(MAKE) -C Documentation all
  847. man:
  848. $(MAKE) -C Documentation man
  849. html:
  850. $(MAKE) -C Documentation html
  851. info:
  852. $(MAKE) -C Documentation info
  853. pdf:
  854. $(MAKE) -C Documentation pdf
  855. TAGS:
  856. $(RM) TAGS
  857. $(FIND) . -name '*.[hcS]' -print | xargs etags -a
  858. tags:
  859. $(RM) tags
  860. $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
  861. cscope:
  862. $(RM) cscope*
  863. $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
  864. ### Detect prefix changes
  865. TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
  866. $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
  867. $(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
  868. @FLAGS='$(TRACK_CFLAGS)'; \
  869. if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
  870. echo 1>&2 " * new build flags or prefix"; \
  871. echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
  872. fi
  873. # We need to apply sq twice, once to protect from the shell
  874. # that runs $(OUTPUT)PERF-BUILD-OPTIONS, and then again to protect it
  875. # and the first level quoting from the shell that runs "echo".
  876. $(OUTPUT)PERF-BUILD-OPTIONS: .FORCE-PERF-BUILD-OPTIONS
  877. @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
  878. @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
  879. @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
  880. @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
  881. ### Testing rules
  882. #
  883. # None right now:
  884. #
  885. # TEST_PROGRAMS += test-something$X
  886. all:: $(TEST_PROGRAMS)
  887. # GNU make supports exporting all variables by "export" without parameters.
  888. # However, the environment gets quite big, and some programs have problems
  889. # with that.
  890. export NO_SVN_TESTS
  891. check: $(OUTPUT)common-cmds.h
  892. if sparse; \
  893. then \
  894. for i in *.c */*.c; \
  895. do \
  896. sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
  897. done; \
  898. else \
  899. echo 2>&1 "Did you mean 'make test'?"; \
  900. exit 1; \
  901. fi
  902. remove-dashes:
  903. ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
  904. ### Installation rules
  905. ifneq ($(filter /%,$(firstword $(template_dir))),)
  906. template_instdir = $(template_dir)
  907. else
  908. template_instdir = $(prefix)/$(template_dir)
  909. endif
  910. export template_instdir
  911. ifneq ($(filter /%,$(firstword $(perfexecdir))),)
  912. perfexec_instdir = $(perfexecdir)
  913. else
  914. perfexec_instdir = $(prefix)/$(perfexecdir)
  915. endif
  916. perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
  917. export perfexec_instdir
  918. install: all
  919. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
  920. $(INSTALL) $(OUTPUT)perf$X '$(DESTDIR_SQ)$(bindir_SQ)'
  921. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
  922. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  923. $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  924. $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
  925. $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
  926. $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  927. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
  928. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  929. $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
  930. $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
  931. $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  932. ifdef BUILT_INS
  933. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  934. $(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  935. ifneq (,$X)
  936. $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) $(OUTPUT)perf$X)), $(RM) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$p';)
  937. endif
  938. endif
  939. install-doc:
  940. $(MAKE) -C Documentation install
  941. install-man:
  942. $(MAKE) -C Documentation install-man
  943. install-html:
  944. $(MAKE) -C Documentation install-html
  945. install-info:
  946. $(MAKE) -C Documentation install-info
  947. install-pdf:
  948. $(MAKE) -C Documentation install-pdf
  949. quick-install-doc:
  950. $(MAKE) -C Documentation quick-install
  951. quick-install-man:
  952. $(MAKE) -C Documentation quick-install-man
  953. quick-install-html:
  954. $(MAKE) -C Documentation quick-install-html
  955. ### Maintainer's dist rules
  956. #
  957. # None right now
  958. #
  959. #
  960. # perf.spec: perf.spec.in
  961. # sed -e 's/@@VERSION@@/$(PERF_VERSION)/g' < $< > $@+
  962. # mv $@+ $@
  963. #
  964. # PERF_TARNAME=perf-$(PERF_VERSION)
  965. # dist: perf.spec perf-archive$(X) configure
  966. # ./perf-archive --format=tar \
  967. # --prefix=$(PERF_TARNAME)/ HEAD^{tree} > $(PERF_TARNAME).tar
  968. # @mkdir -p $(PERF_TARNAME)
  969. # @cp perf.spec configure $(PERF_TARNAME)
  970. # @echo $(PERF_VERSION) > $(PERF_TARNAME)/version
  971. # $(TAR) rf $(PERF_TARNAME).tar \
  972. # $(PERF_TARNAME)/perf.spec \
  973. # $(PERF_TARNAME)/configure \
  974. # $(PERF_TARNAME)/version
  975. # @$(RM) -r $(PERF_TARNAME)
  976. # gzip -f -9 $(PERF_TARNAME).tar
  977. #
  978. # htmldocs = perf-htmldocs-$(PERF_VERSION)
  979. # manpages = perf-manpages-$(PERF_VERSION)
  980. # dist-doc:
  981. # $(RM) -r .doc-tmp-dir
  982. # mkdir .doc-tmp-dir
  983. # $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
  984. # cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
  985. # gzip -n -9 -f $(htmldocs).tar
  986. # :
  987. # $(RM) -r .doc-tmp-dir
  988. # mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
  989. # $(MAKE) -C Documentation DESTDIR=./ \
  990. # man1dir=../.doc-tmp-dir/man1 \
  991. # man5dir=../.doc-tmp-dir/man5 \
  992. # man7dir=../.doc-tmp-dir/man7 \
  993. # install
  994. # cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
  995. # gzip -n -9 -f $(manpages).tar
  996. # $(RM) -r .doc-tmp-dir
  997. #
  998. # rpm: dist
  999. # $(RPMBUILD) -ta $(PERF_TARNAME).tar.gz
  1000. ### Cleaning rules
  1001. distclean: clean
  1002. # $(RM) configure
  1003. clean:
  1004. $(RM) *.o */*.o */*/*.o */*/*/*.o $(LIB_FILE)
  1005. $(RM) $(ALL_PROGRAMS) $(BUILT_INS) perf$X
  1006. $(RM) $(TEST_PROGRAMS)
  1007. $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
  1008. $(RM) -r autom4te.cache
  1009. $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
  1010. $(RM) -r $(PERF_TARNAME) .doc-tmp-dir
  1011. $(RM) $(PERF_TARNAME).tar.gz perf-core_$(PERF_VERSION)-*.tar.gz
  1012. $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
  1013. $(MAKE) -C Documentation/ clean
  1014. $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)PERF-BUILD-OPTIONS
  1015. .PHONY: all install clean strip
  1016. .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
  1017. .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
  1018. .PHONY: .FORCE-PERF-BUILD-OPTIONS
  1019. .perf.dev.null:
  1020. touch .perf.dev.null
  1021. .INTERMEDIATE: .perf.dev.null
  1022. ### Make sure built-ins do not have dups and listed in perf.c
  1023. #
  1024. check-builtins::
  1025. ./check-builtins.sh
  1026. ### Test suite coverage testing
  1027. #
  1028. # None right now
  1029. #
  1030. # .PHONY: coverage coverage-clean coverage-build coverage-report
  1031. #
  1032. # coverage:
  1033. # $(MAKE) coverage-build
  1034. # $(MAKE) coverage-report
  1035. #
  1036. # coverage-clean:
  1037. # rm -f *.gcda *.gcno
  1038. #
  1039. # COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
  1040. # COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov
  1041. #
  1042. # coverage-build: coverage-clean
  1043. # $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
  1044. # $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
  1045. # -j1 test
  1046. #
  1047. # coverage-report:
  1048. # gcov -b *.c */*.c
  1049. # grep '^function.*called 0 ' *.c.gcov */*.c.gcov \
  1050. # | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
  1051. # | tee coverage-untested-functions