Makefile 40 KB

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