Makefile 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  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/strlist.h
  352. LIB_H += util/svghelper.h
  353. LIB_H += util/run-command.h
  354. LIB_H += util/sigchain.h
  355. LIB_H += util/symbol.h
  356. LIB_H += util/color.h
  357. LIB_H += util/values.h
  358. LIB_H += util/sort.h
  359. LIB_H += util/hist.h
  360. LIB_H += util/thread.h
  361. LIB_H += util/trace-event.h
  362. LIB_H += util/probe-finder.h
  363. LIB_H += util/probe-event.h
  364. LIB_H += util/cpumap.h
  365. LIB_OBJS += $(OUTPUT)util/abspath.o
  366. LIB_OBJS += $(OUTPUT)util/alias.o
  367. LIB_OBJS += $(OUTPUT)util/build-id.o
  368. LIB_OBJS += $(OUTPUT)util/config.o
  369. LIB_OBJS += $(OUTPUT)util/ctype.o
  370. LIB_OBJS += $(OUTPUT)util/debugfs.o
  371. LIB_OBJS += $(OUTPUT)util/environment.o
  372. LIB_OBJS += $(OUTPUT)util/event.o
  373. LIB_OBJS += $(OUTPUT)util/exec_cmd.o
  374. LIB_OBJS += $(OUTPUT)util/help.o
  375. LIB_OBJS += $(OUTPUT)util/levenshtein.o
  376. LIB_OBJS += $(OUTPUT)util/parse-options.o
  377. LIB_OBJS += $(OUTPUT)util/parse-events.o
  378. LIB_OBJS += $(OUTPUT)util/path.o
  379. LIB_OBJS += $(OUTPUT)util/rbtree.o
  380. LIB_OBJS += $(OUTPUT)util/bitmap.o
  381. LIB_OBJS += $(OUTPUT)util/hweight.o
  382. LIB_OBJS += $(OUTPUT)util/find_next_bit.o
  383. LIB_OBJS += $(OUTPUT)util/run-command.o
  384. LIB_OBJS += $(OUTPUT)util/quote.o
  385. LIB_OBJS += $(OUTPUT)util/strbuf.o
  386. LIB_OBJS += $(OUTPUT)util/string.o
  387. LIB_OBJS += $(OUTPUT)util/strlist.o
  388. LIB_OBJS += $(OUTPUT)util/usage.o
  389. LIB_OBJS += $(OUTPUT)util/wrapper.o
  390. LIB_OBJS += $(OUTPUT)util/sigchain.o
  391. LIB_OBJS += $(OUTPUT)util/symbol.o
  392. LIB_OBJS += $(OUTPUT)util/color.o
  393. LIB_OBJS += $(OUTPUT)util/pager.o
  394. LIB_OBJS += $(OUTPUT)util/header.o
  395. LIB_OBJS += $(OUTPUT)util/callchain.o
  396. LIB_OBJS += $(OUTPUT)util/values.o
  397. LIB_OBJS += $(OUTPUT)util/debug.o
  398. LIB_OBJS += $(OUTPUT)util/map.o
  399. LIB_OBJS += $(OUTPUT)util/session.o
  400. LIB_OBJS += $(OUTPUT)util/thread.o
  401. LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
  402. LIB_OBJS += $(OUTPUT)util/trace-event-read.o
  403. LIB_OBJS += $(OUTPUT)util/trace-event-info.o
  404. LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
  405. LIB_OBJS += $(OUTPUT)util/svghelper.o
  406. LIB_OBJS += $(OUTPUT)util/sort.o
  407. LIB_OBJS += $(OUTPUT)util/hist.o
  408. LIB_OBJS += $(OUTPUT)util/probe-event.o
  409. LIB_OBJS += $(OUTPUT)util/util.o
  410. LIB_OBJS += $(OUTPUT)util/cpumap.o
  411. BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
  412. BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
  413. # Benchmark modules
  414. BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
  415. BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
  416. BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
  417. BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
  418. BUILTIN_OBJS += $(OUTPUT)builtin-help.o
  419. BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
  420. BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
  421. BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
  422. BUILTIN_OBJS += $(OUTPUT)builtin-list.o
  423. BUILTIN_OBJS += $(OUTPUT)builtin-record.o
  424. BUILTIN_OBJS += $(OUTPUT)builtin-report.o
  425. BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
  426. BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
  427. BUILTIN_OBJS += $(OUTPUT)builtin-top.o
  428. BUILTIN_OBJS += $(OUTPUT)builtin-trace.o
  429. BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
  430. BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
  431. BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
  432. PERFLIBS = $(LIB_FILE)
  433. #
  434. # Platform specific tweaks
  435. #
  436. # We choose to avoid "if .. else if .. else .. endif endif"
  437. # because maintaining the nesting to match is a pain. If
  438. # we had "elif" things would have been much nicer...
  439. -include config.mak.autogen
  440. -include config.mak
  441. ifeq ($(uname_S),Darwin)
  442. ifndef NO_FINK
  443. ifeq ($(shell test -d /sw/lib && echo y),y)
  444. BASIC_CFLAGS += -I/sw/include
  445. BASIC_LDFLAGS += -L/sw/lib
  446. endif
  447. endif
  448. ifndef NO_DARWIN_PORTS
  449. ifeq ($(shell test -d /opt/local/lib && echo y),y)
  450. BASIC_CFLAGS += -I/opt/local/include
  451. BASIC_LDFLAGS += -L/opt/local/lib
  452. endif
  453. endif
  454. PTHREAD_LIBS =
  455. endif
  456. ifneq ($(OUTPUT),)
  457. BASIC_CFLAGS += -I$(OUTPUT)
  458. endif
  459. 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)
  460. 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)
  461. msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
  462. endif
  463. 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)
  464. BASIC_CFLAGS += -DLIBELF_NO_MMAP
  465. endif
  466. else
  467. msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
  468. endif
  469. 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)
  470. msg := $(warning No libdw.h found or old libdw.h found, disables dwarf support. Please install elfutils-devel/elfutils-dev);
  471. else
  472. ifndef NO_DWARF
  473. BASIC_CFLAGS += -I/usr/include/elfutils -DDWARF_SUPPORT
  474. EXTLIBS += -lelf -ldw
  475. LIB_OBJS += $(OUTPUT)util/probe-finder.o
  476. endif
  477. endif
  478. 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)
  479. msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev);
  480. BASIC_CFLAGS += -DNO_NEWT_SUPPORT
  481. else
  482. EXTLIBS += -lnewt
  483. LIB_OBJS += $(OUTPUT)util/newt.o
  484. endif
  485. ifndef NO_LIBPERL
  486. PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null`
  487. PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
  488. endif
  489. 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)
  490. BASIC_CFLAGS += -DNO_LIBPERL
  491. else
  492. ALL_LDFLAGS += $(PERL_EMBED_LDOPTS)
  493. LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
  494. LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
  495. endif
  496. ifndef NO_LIBPYTHON
  497. PYTHON_EMBED_LDOPTS = `python-config --ldflags 2>/dev/null`
  498. PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
  499. endif
  500. 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)
  501. BASIC_CFLAGS += -DNO_LIBPYTHON
  502. else
  503. ALL_LDFLAGS += $(PYTHON_EMBED_LDOPTS)
  504. LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
  505. LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
  506. endif
  507. ifdef NO_DEMANGLE
  508. BASIC_CFLAGS += -DNO_DEMANGLE
  509. else
  510. 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")
  511. ifeq ($(has_bfd),y)
  512. EXTLIBS += -lbfd
  513. else
  514. 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")
  515. ifeq ($(has_bfd_iberty),y)
  516. EXTLIBS += -lbfd -liberty
  517. else
  518. 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")
  519. ifeq ($(has_bfd_iberty_z),y)
  520. EXTLIBS += -lbfd -liberty -lz
  521. else
  522. 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")
  523. ifeq ($(has_cplus_demangle),y)
  524. EXTLIBS += -liberty
  525. BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
  526. else
  527. msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
  528. BASIC_CFLAGS += -DNO_DEMANGLE
  529. endif
  530. endif
  531. endif
  532. endif
  533. endif
  534. ifndef CC_LD_DYNPATH
  535. ifdef NO_R_TO_GCC_LINKER
  536. # Some gcc does not accept and pass -R to the linker to specify
  537. # the runtime dynamic library path.
  538. CC_LD_DYNPATH = -Wl,-rpath,
  539. else
  540. CC_LD_DYNPATH = -R
  541. endif
  542. endif
  543. ifdef NEEDS_SOCKET
  544. EXTLIBS += -lsocket
  545. endif
  546. ifdef NEEDS_NSL
  547. EXTLIBS += -lnsl
  548. endif
  549. ifdef NO_D_TYPE_IN_DIRENT
  550. BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
  551. endif
  552. ifdef NO_D_INO_IN_DIRENT
  553. BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
  554. endif
  555. ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
  556. BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
  557. endif
  558. ifdef USE_NSEC
  559. BASIC_CFLAGS += -DUSE_NSEC
  560. endif
  561. ifdef USE_ST_TIMESPEC
  562. BASIC_CFLAGS += -DUSE_ST_TIMESPEC
  563. endif
  564. ifdef NO_NSEC
  565. BASIC_CFLAGS += -DNO_NSEC
  566. endif
  567. ifdef NO_C99_FORMAT
  568. BASIC_CFLAGS += -DNO_C99_FORMAT
  569. endif
  570. ifdef SNPRINTF_RETURNS_BOGUS
  571. COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
  572. COMPAT_OBJS += $(OUTPUT)compat/snprintf.o
  573. endif
  574. ifdef FREAD_READS_DIRECTORIES
  575. COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
  576. COMPAT_OBJS += $(OUTPUT)compat/fopen.o
  577. endif
  578. ifdef NO_SYMLINK_HEAD
  579. BASIC_CFLAGS += -DNO_SYMLINK_HEAD
  580. endif
  581. ifdef NO_STRCASESTR
  582. COMPAT_CFLAGS += -DNO_STRCASESTR
  583. COMPAT_OBJS += $(OUTPUT)compat/strcasestr.o
  584. endif
  585. ifdef NO_STRTOUMAX
  586. COMPAT_CFLAGS += -DNO_STRTOUMAX
  587. COMPAT_OBJS += $(OUTPUT)compat/strtoumax.o
  588. endif
  589. ifdef NO_STRTOULL
  590. COMPAT_CFLAGS += -DNO_STRTOULL
  591. endif
  592. ifdef NO_SETENV
  593. COMPAT_CFLAGS += -DNO_SETENV
  594. COMPAT_OBJS += $(OUTPUT)compat/setenv.o
  595. endif
  596. ifdef NO_MKDTEMP
  597. COMPAT_CFLAGS += -DNO_MKDTEMP
  598. COMPAT_OBJS += $(OUTPUT)compat/mkdtemp.o
  599. endif
  600. ifdef NO_UNSETENV
  601. COMPAT_CFLAGS += -DNO_UNSETENV
  602. COMPAT_OBJS += $(OUTPUT)compat/unsetenv.o
  603. endif
  604. ifdef NO_SYS_SELECT_H
  605. BASIC_CFLAGS += -DNO_SYS_SELECT_H
  606. endif
  607. ifdef NO_MMAP
  608. COMPAT_CFLAGS += -DNO_MMAP
  609. COMPAT_OBJS += $(OUTPUT)compat/mmap.o
  610. else
  611. ifdef USE_WIN32_MMAP
  612. COMPAT_CFLAGS += -DUSE_WIN32_MMAP
  613. COMPAT_OBJS += $(OUTPUT)compat/win32mmap.o
  614. endif
  615. endif
  616. ifdef NO_PREAD
  617. COMPAT_CFLAGS += -DNO_PREAD
  618. COMPAT_OBJS += $(OUTPUT)compat/pread.o
  619. endif
  620. ifdef NO_FAST_WORKING_DIRECTORY
  621. BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
  622. endif
  623. ifdef NO_TRUSTABLE_FILEMODE
  624. BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
  625. endif
  626. ifdef NO_IPV6
  627. BASIC_CFLAGS += -DNO_IPV6
  628. endif
  629. ifdef NO_UINTMAX_T
  630. BASIC_CFLAGS += -Duintmax_t=uint32_t
  631. endif
  632. ifdef NO_SOCKADDR_STORAGE
  633. ifdef NO_IPV6
  634. BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
  635. else
  636. BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
  637. endif
  638. endif
  639. ifdef NO_INET_NTOP
  640. LIB_OBJS += $(OUTPUT)compat/inet_ntop.o
  641. endif
  642. ifdef NO_INET_PTON
  643. LIB_OBJS += $(OUTPUT)compat/inet_pton.o
  644. endif
  645. ifdef NO_ICONV
  646. BASIC_CFLAGS += -DNO_ICONV
  647. endif
  648. ifdef OLD_ICONV
  649. BASIC_CFLAGS += -DOLD_ICONV
  650. endif
  651. ifdef NO_DEFLATE_BOUND
  652. BASIC_CFLAGS += -DNO_DEFLATE_BOUND
  653. endif
  654. ifdef PPC_SHA1
  655. SHA1_HEADER = "ppc/sha1.h"
  656. LIB_OBJS += $(OUTPUT)ppc/sha1.o ppc/sha1ppc.o
  657. else
  658. ifdef ARM_SHA1
  659. SHA1_HEADER = "arm/sha1.h"
  660. LIB_OBJS += $(OUTPUT)arm/sha1.o $(OUTPUT)arm/sha1_arm.o
  661. else
  662. ifdef MOZILLA_SHA1
  663. SHA1_HEADER = "mozilla-sha1/sha1.h"
  664. LIB_OBJS += $(OUTPUT)mozilla-sha1/sha1.o
  665. else
  666. SHA1_HEADER = <openssl/sha.h>
  667. EXTLIBS += $(LIB_4_CRYPTO)
  668. endif
  669. endif
  670. endif
  671. ifdef NO_PERL_MAKEMAKER
  672. export NO_PERL_MAKEMAKER
  673. endif
  674. ifdef NO_HSTRERROR
  675. COMPAT_CFLAGS += -DNO_HSTRERROR
  676. COMPAT_OBJS += $(OUTPUT)compat/hstrerror.o
  677. endif
  678. ifdef NO_MEMMEM
  679. COMPAT_CFLAGS += -DNO_MEMMEM
  680. COMPAT_OBJS += $(OUTPUT)compat/memmem.o
  681. endif
  682. ifdef INTERNAL_QSORT
  683. COMPAT_CFLAGS += -DINTERNAL_QSORT
  684. COMPAT_OBJS += $(OUTPUT)compat/qsort.o
  685. endif
  686. ifdef RUNTIME_PREFIX
  687. COMPAT_CFLAGS += -DRUNTIME_PREFIX
  688. endif
  689. ifdef DIR_HAS_BSD_GROUP_SEMANTICS
  690. COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
  691. endif
  692. ifdef NO_EXTERNAL_GREP
  693. BASIC_CFLAGS += -DNO_EXTERNAL_GREP
  694. endif
  695. ifeq ($(PERL_PATH),)
  696. NO_PERL=NoThanks
  697. endif
  698. QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
  699. QUIET_SUBDIR1 =
  700. ifneq ($(findstring $(MAKEFLAGS),w),w)
  701. PRINT_DIR = --no-print-directory
  702. else # "make -w"
  703. NO_SUBDIR = :
  704. endif
  705. ifneq ($(findstring $(MAKEFLAGS),s),s)
  706. ifndef V
  707. QUIET_CC = @echo ' ' CC $@;
  708. QUIET_AR = @echo ' ' AR $@;
  709. QUIET_LINK = @echo ' ' LINK $@;
  710. QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
  711. QUIET_GEN = @echo ' ' GEN $@;
  712. QUIET_SUBDIR0 = +@subdir=
  713. QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
  714. $(MAKE) $(PRINT_DIR) -C $$subdir
  715. export V
  716. export QUIET_GEN
  717. export QUIET_BUILT_IN
  718. endif
  719. endif
  720. ifdef ASCIIDOC8
  721. export ASCIIDOC8
  722. endif
  723. # Shell quote (do not use $(call) to accommodate ancient setups);
  724. SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
  725. ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
  726. DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  727. bindir_SQ = $(subst ','\'',$(bindir))
  728. bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
  729. mandir_SQ = $(subst ','\'',$(mandir))
  730. infodir_SQ = $(subst ','\'',$(infodir))
  731. perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
  732. template_dir_SQ = $(subst ','\'',$(template_dir))
  733. htmldir_SQ = $(subst ','\'',$(htmldir))
  734. prefix_SQ = $(subst ','\'',$(prefix))
  735. SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  736. PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
  737. LIBS = $(PERFLIBS) $(EXTLIBS)
  738. BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
  739. $(COMPAT_CFLAGS)
  740. LIB_OBJS += $(COMPAT_OBJS)
  741. ALL_CFLAGS += $(BASIC_CFLAGS)
  742. ALL_LDFLAGS += $(BASIC_LDFLAGS)
  743. export TAR INSTALL DESTDIR SHELL_PATH
  744. ### Build rules
  745. SHELL = $(SHELL_PATH)
  746. all:: .perf.dev.null shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS
  747. ifneq (,$X)
  748. $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
  749. endif
  750. all::
  751. please_set_SHELL_PATH_to_a_more_modern_shell:
  752. @$$(:)
  753. shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
  754. strip: $(PROGRAMS) $(OUTPUT)perf$X
  755. $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf$X
  756. $(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  757. $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
  758. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  759. $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
  760. $(OUTPUT)perf$X: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
  761. $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(OUTPUT)perf.o \
  762. $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
  763. $(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  764. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  765. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  766. '-DPERF_MAN_PATH="$(mandir_SQ)"' \
  767. '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
  768. $(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  769. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  770. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  771. '-DPERF_MAN_PATH="$(mandir_SQ)"' \
  772. '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
  773. $(BUILT_INS): $(OUTPUT)perf$X
  774. $(QUIET_BUILT_IN)$(RM) $@ && \
  775. ln perf$X $@ 2>/dev/null || \
  776. ln -s perf$X $@ 2>/dev/null || \
  777. cp perf$X $@
  778. $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
  779. $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
  780. $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
  781. $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
  782. $(QUIET_GEN)$(RM) $@ $@+ && \
  783. sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
  784. -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
  785. -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
  786. -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
  787. -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
  788. $@.sh >$@+ && \
  789. chmod +x $@+ && \
  790. mv $@+ $(OUTPUT)$@
  791. configure: configure.ac
  792. $(QUIET_GEN)$(RM) $@ $<+ && \
  793. sed -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
  794. $< > $<+ && \
  795. autoconf -o $@ $<+ && \
  796. $(RM) $<+
  797. # These can record PERF_VERSION
  798. $(OUTPUT)perf.o perf.spec \
  799. $(patsubst %.sh,%,$(SCRIPT_SH)) \
  800. $(patsubst %.perl,%,$(SCRIPT_PERL)) \
  801. : $(OUTPUT)PERF-VERSION-FILE
  802. $(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
  803. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
  804. $(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
  805. $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
  806. $(OUTPUT)%.o: %.S
  807. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
  808. $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
  809. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  810. '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
  811. '-DBINDIR="$(bindir_relative_SQ)"' \
  812. '-DPREFIX="$(prefix_SQ)"' \
  813. $<
  814. $(OUTPUT)builtin-init-db.o: builtin-init-db.c $(OUTPUT)PERF-CFLAGS
  815. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_PERF_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
  816. $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
  817. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  818. $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
  819. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  820. # some perf warning policies can't fit to lib/bitmap.c, eg: it warns about variable shadowing
  821. # from <string.h> that comes from kernel headers wrapping.
  822. KBITMAP_FLAGS=`echo $(ALL_CFLAGS) | sed s/-Wshadow// | sed s/-Wswitch-default// | sed s/-Wextra//`
  823. $(OUTPUT)util/bitmap.o: ../../lib/bitmap.c $(OUTPUT)PERF-CFLAGS
  824. $(QUIET_CC)$(CC) -o $@ -c $(KBITMAP_FLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  825. $(OUTPUT)util/hweight.o: ../../lib/hweight.c $(OUTPUT)PERF-CFLAGS
  826. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  827. $(OUTPUT)util/find_next_bit.o: ../../lib/find_next_bit.c $(OUTPUT)PERF-CFLAGS
  828. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  829. $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
  830. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
  831. $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
  832. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
  833. $(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
  834. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
  835. $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
  836. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
  837. $(OUTPUT)perf-%$X: %.o $(PERFLIBS)
  838. $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
  839. $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
  840. $(patsubst perf-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
  841. builtin-revert.o wt-status.o: wt-status.h
  842. $(LIB_FILE): $(LIB_OBJS)
  843. $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
  844. doc:
  845. $(MAKE) -C Documentation all
  846. man:
  847. $(MAKE) -C Documentation man
  848. html:
  849. $(MAKE) -C Documentation html
  850. info:
  851. $(MAKE) -C Documentation info
  852. pdf:
  853. $(MAKE) -C Documentation pdf
  854. TAGS:
  855. $(RM) TAGS
  856. $(FIND) . -name '*.[hcS]' -print | xargs etags -a
  857. tags:
  858. $(RM) tags
  859. $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
  860. cscope:
  861. $(RM) cscope*
  862. $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
  863. ### Detect prefix changes
  864. TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
  865. $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
  866. $(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
  867. @FLAGS='$(TRACK_CFLAGS)'; \
  868. if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
  869. echo 1>&2 " * new build flags or prefix"; \
  870. echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
  871. fi
  872. # We need to apply sq twice, once to protect from the shell
  873. # that runs $(OUTPUT)PERF-BUILD-OPTIONS, and then again to protect it
  874. # and the first level quoting from the shell that runs "echo".
  875. $(OUTPUT)PERF-BUILD-OPTIONS: .FORCE-PERF-BUILD-OPTIONS
  876. @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
  877. @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
  878. @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
  879. @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
  880. ### Testing rules
  881. #
  882. # None right now:
  883. #
  884. # TEST_PROGRAMS += test-something$X
  885. all:: $(TEST_PROGRAMS)
  886. # GNU make supports exporting all variables by "export" without parameters.
  887. # However, the environment gets quite big, and some programs have problems
  888. # with that.
  889. export NO_SVN_TESTS
  890. check: $(OUTPUT)common-cmds.h
  891. if sparse; \
  892. then \
  893. for i in *.c */*.c; \
  894. do \
  895. sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
  896. done; \
  897. else \
  898. echo 2>&1 "Did you mean 'make test'?"; \
  899. exit 1; \
  900. fi
  901. remove-dashes:
  902. ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
  903. ### Installation rules
  904. ifneq ($(filter /%,$(firstword $(template_dir))),)
  905. template_instdir = $(template_dir)
  906. else
  907. template_instdir = $(prefix)/$(template_dir)
  908. endif
  909. export template_instdir
  910. ifneq ($(filter /%,$(firstword $(perfexecdir))),)
  911. perfexec_instdir = $(perfexecdir)
  912. else
  913. perfexec_instdir = $(prefix)/$(perfexecdir)
  914. endif
  915. perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
  916. export perfexec_instdir
  917. install: all
  918. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
  919. $(INSTALL) $(OUTPUT)perf$X '$(DESTDIR_SQ)$(bindir_SQ)'
  920. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
  921. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  922. $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  923. $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
  924. $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
  925. $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  926. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
  927. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  928. $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
  929. $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
  930. $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  931. ifdef BUILT_INS
  932. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  933. $(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  934. ifneq (,$X)
  935. $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) $(OUTPUT)perf$X)), $(RM) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$p';)
  936. endif
  937. endif
  938. install-doc:
  939. $(MAKE) -C Documentation install
  940. install-man:
  941. $(MAKE) -C Documentation install-man
  942. install-html:
  943. $(MAKE) -C Documentation install-html
  944. install-info:
  945. $(MAKE) -C Documentation install-info
  946. install-pdf:
  947. $(MAKE) -C Documentation install-pdf
  948. quick-install-doc:
  949. $(MAKE) -C Documentation quick-install
  950. quick-install-man:
  951. $(MAKE) -C Documentation quick-install-man
  952. quick-install-html:
  953. $(MAKE) -C Documentation quick-install-html
  954. ### Maintainer's dist rules
  955. #
  956. # None right now
  957. #
  958. #
  959. # perf.spec: perf.spec.in
  960. # sed -e 's/@@VERSION@@/$(PERF_VERSION)/g' < $< > $@+
  961. # mv $@+ $@
  962. #
  963. # PERF_TARNAME=perf-$(PERF_VERSION)
  964. # dist: perf.spec perf-archive$(X) configure
  965. # ./perf-archive --format=tar \
  966. # --prefix=$(PERF_TARNAME)/ HEAD^{tree} > $(PERF_TARNAME).tar
  967. # @mkdir -p $(PERF_TARNAME)
  968. # @cp perf.spec configure $(PERF_TARNAME)
  969. # @echo $(PERF_VERSION) > $(PERF_TARNAME)/version
  970. # $(TAR) rf $(PERF_TARNAME).tar \
  971. # $(PERF_TARNAME)/perf.spec \
  972. # $(PERF_TARNAME)/configure \
  973. # $(PERF_TARNAME)/version
  974. # @$(RM) -r $(PERF_TARNAME)
  975. # gzip -f -9 $(PERF_TARNAME).tar
  976. #
  977. # htmldocs = perf-htmldocs-$(PERF_VERSION)
  978. # manpages = perf-manpages-$(PERF_VERSION)
  979. # dist-doc:
  980. # $(RM) -r .doc-tmp-dir
  981. # mkdir .doc-tmp-dir
  982. # $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
  983. # cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
  984. # gzip -n -9 -f $(htmldocs).tar
  985. # :
  986. # $(RM) -r .doc-tmp-dir
  987. # mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
  988. # $(MAKE) -C Documentation DESTDIR=./ \
  989. # man1dir=../.doc-tmp-dir/man1 \
  990. # man5dir=../.doc-tmp-dir/man5 \
  991. # man7dir=../.doc-tmp-dir/man7 \
  992. # install
  993. # cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
  994. # gzip -n -9 -f $(manpages).tar
  995. # $(RM) -r .doc-tmp-dir
  996. #
  997. # rpm: dist
  998. # $(RPMBUILD) -ta $(PERF_TARNAME).tar.gz
  999. ### Cleaning rules
  1000. distclean: clean
  1001. # $(RM) configure
  1002. clean:
  1003. $(RM) *.o */*.o */*/*.o */*/*/*.o $(LIB_FILE)
  1004. $(RM) $(ALL_PROGRAMS) $(BUILT_INS) perf$X
  1005. $(RM) $(TEST_PROGRAMS)
  1006. $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
  1007. $(RM) -r autom4te.cache
  1008. $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
  1009. $(RM) -r $(PERF_TARNAME) .doc-tmp-dir
  1010. $(RM) $(PERF_TARNAME).tar.gz perf-core_$(PERF_VERSION)-*.tar.gz
  1011. $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
  1012. $(MAKE) -C Documentation/ clean
  1013. $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)PERF-BUILD-OPTIONS
  1014. .PHONY: all install clean strip
  1015. .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
  1016. .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
  1017. .PHONY: .FORCE-PERF-BUILD-OPTIONS
  1018. .perf.dev.null:
  1019. touch .perf.dev.null
  1020. .INTERMEDIATE: .perf.dev.null
  1021. ### Make sure built-ins do not have dups and listed in perf.c
  1022. #
  1023. check-builtins::
  1024. ./check-builtins.sh
  1025. ### Test suite coverage testing
  1026. #
  1027. # None right now
  1028. #
  1029. # .PHONY: coverage coverage-clean coverage-build coverage-report
  1030. #
  1031. # coverage:
  1032. # $(MAKE) coverage-build
  1033. # $(MAKE) coverage-report
  1034. #
  1035. # coverage-clean:
  1036. # rm -f *.gcda *.gcno
  1037. #
  1038. # COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
  1039. # COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov
  1040. #
  1041. # coverage-build: coverage-clean
  1042. # $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
  1043. # $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
  1044. # -j1 test
  1045. #
  1046. # coverage-report:
  1047. # gcov -b *.c */*.c
  1048. # grep '^function.*called 0 ' *.c.gcov */*.c.gcov \
  1049. # | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
  1050. # | tee coverage-untested-functions