Makefile 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  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 CURLDIR=/foo/bar if your curl header and library files are in
  15. # /foo/bar/include and /foo/bar/lib directories.
  16. #
  17. # Define EXPATDIR=/foo/bar if your expat header and library files are in
  18. # /foo/bar/include and /foo/bar/lib directories.
  19. #
  20. # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
  21. # do not support the 'size specifiers' introduced by C99, namely ll, hh,
  22. # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
  23. # some C compilers supported these specifiers prior to C99 as an extension.
  24. #
  25. # Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
  26. #
  27. # Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
  28. # that tells runtime paths to dynamic libraries;
  29. # "-Wl,-rpath=/path/lib" is used instead.
  30. #
  31. # Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
  32. #
  33. # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
  34. #
  35. # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
  36. # MakeMaker (e.g. using ActiveState under Cygwin).
  37. #
  38. # Define NO_PERL if you do not want Perl scripts or libraries at all.
  39. #
  40. # Define INTERNAL_QSORT to use Git's implementation of qsort(), which
  41. # is a simplified version of the merge sort used in glibc. This is
  42. # recommended if Git triggers O(n^2) behavior in your platform's qsort().
  43. #
  44. # Define NO_EXTERNAL_GREP if you don't want "perf grep" to ever call
  45. # your external grep (e.g., if your system lacks grep, if its grep is
  46. # broken, or spawning external process is slower than built-in grep perf has).
  47. #
  48. # Define LDFLAGS=-static to build a static binary.
  49. #
  50. # Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
  51. #
  52. # Define NO_DWARF if you do not want debug-info analysis feature at all.
  53. $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
  54. @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
  55. -include $(OUTPUT)PERF-VERSION-FILE
  56. uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
  57. uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
  58. uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
  59. uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
  60. uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
  61. uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
  62. ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
  63. -e s/arm.*/arm/ -e s/sa110/arm/ \
  64. -e s/s390x/s390/ -e s/parisc64/parisc/ \
  65. -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
  66. -e s/sh[234].*/sh/ )
  67. # Additional ARCH settings for x86
  68. ifeq ($(ARCH),i386)
  69. ARCH := x86
  70. endif
  71. ifeq ($(ARCH),x86_64)
  72. RAW_ARCH := x86_64
  73. ARCH := x86
  74. ARCH_CFLAGS := -DARCH_X86_64
  75. ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S
  76. endif
  77. # CFLAGS and LDFLAGS are for the users to override from the command line.
  78. #
  79. # Include saner warnings here, which can catch bugs:
  80. #
  81. EXTRA_WARNINGS := -Wformat
  82. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
  83. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
  84. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
  85. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
  86. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
  87. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
  88. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
  89. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
  90. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
  91. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
  92. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
  93. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
  94. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
  95. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
  96. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes
  97. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs
  98. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
  99. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
  100. EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
  101. ifeq ("$(origin DEBUG)", "command line")
  102. PERF_DEBUG = $(DEBUG)
  103. endif
  104. ifndef PERF_DEBUG
  105. CFLAGS_OPTIMIZE = -O6
  106. endif
  107. CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
  108. EXTLIBS = -lpthread -lrt -lelf -lm
  109. ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
  110. ALL_LDFLAGS = $(LDFLAGS)
  111. STRIP ?= strip
  112. # Among the variables below, these:
  113. # perfexecdir
  114. # template_dir
  115. # mandir
  116. # infodir
  117. # htmldir
  118. # ETC_PERFCONFIG (but not sysconfdir)
  119. # can be specified as a relative path some/where/else;
  120. # this is interpreted as relative to $(prefix) and "perf" at
  121. # runtime figures out where they are based on the path to the executable.
  122. # This can help installing the suite in a relocatable way.
  123. # Make the path relative to DESTDIR, not to prefix
  124. ifndef DESTDIR
  125. prefix = $(HOME)
  126. endif
  127. bindir_relative = bin
  128. bindir = $(prefix)/$(bindir_relative)
  129. mandir = share/man
  130. infodir = share/info
  131. perfexecdir = libexec/perf-core
  132. sharedir = $(prefix)/share
  133. template_dir = share/perf-core/templates
  134. htmldir = share/doc/perf-doc
  135. ifeq ($(prefix),/usr)
  136. sysconfdir = /etc
  137. ETC_PERFCONFIG = $(sysconfdir)/perfconfig
  138. else
  139. sysconfdir = $(prefix)/etc
  140. ETC_PERFCONFIG = etc/perfconfig
  141. endif
  142. lib = lib
  143. export prefix bindir sharedir sysconfdir
  144. CC = $(CROSS_COMPILE)gcc
  145. AR = $(CROSS_COMPILE)ar
  146. RM = rm -f
  147. MKDIR = mkdir
  148. TAR = tar
  149. FIND = find
  150. INSTALL = install
  151. RPMBUILD = rpmbuild
  152. PTHREAD_LIBS = -lpthread
  153. # sparse is architecture-neutral, which means that we need to tell it
  154. # explicitly what architecture to check for. Fix this up for yours..
  155. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
  156. ifeq ($(V), 2)
  157. QUIET_STDERR = ">/dev/null"
  158. else
  159. QUIET_STDERR = ">/dev/null 2>&1"
  160. endif
  161. -include feature-tests.mak
  162. ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y)
  163. CFLAGS := $(CFLAGS) -fstack-protector-all
  164. endif
  165. ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wstack-protector),y)
  166. CFLAGS := $(CFLAGS) -Wstack-protector
  167. endif
  168. ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wvolatile-register-var),y)
  169. CFLAGS := $(CFLAGS) -Wvolatile-register-var
  170. endif
  171. ### --- END CONFIGURATION SECTION ---
  172. # Those must not be GNU-specific; they are shared with perl/ which may
  173. # be built by a different compiler. (Note that this is an artifact now
  174. # but it still might be nice to keep that distinction.)
  175. BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include
  176. BASIC_LDFLAGS =
  177. # Guard against environment variables
  178. BUILTIN_OBJS =
  179. BUILT_INS =
  180. LIB_H =
  181. LIB_OBJS =
  182. PYRF_OBJS =
  183. SCRIPT_PERL =
  184. SCRIPT_SH =
  185. TEST_PROGRAMS =
  186. SCRIPT_SH += perf-archive.sh
  187. grep-libs = $(filter -l%,$(1))
  188. strip-libs = $(filter-out -l%,$(1))
  189. $(OUTPUT)python/perf.so: $(PYRF_OBJS)
  190. $(QUIET_GEN)python util/setup.py --quiet build_ext --build-lib='$(OUTPUT)python' \
  191. --build-temp='$(OUTPUT)python/temp'
  192. #
  193. # No Perl scripts right now:
  194. #
  195. # SCRIPT_PERL += perf-add--interactive.perl
  196. SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
  197. $(patsubst %.perl,%,$(SCRIPT_PERL))
  198. # Empty...
  199. EXTRA_PROGRAMS =
  200. # ... and all the rest that could be moved out of bindir to perfexecdir
  201. PROGRAMS += $(EXTRA_PROGRAMS)
  202. #
  203. # Single 'perf' binary right now:
  204. #
  205. PROGRAMS += $(OUTPUT)perf
  206. LANG_BINDINGS =
  207. # List built-in command $C whose implementation cmd_$C() is not in
  208. # builtin-$C.o but is linked in as part of some other command.
  209. #
  210. # what 'all' will build and 'install' will install, in perfexecdir
  211. ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
  212. # what 'all' will build but not install in perfexecdir
  213. OTHER_PROGRAMS = $(OUTPUT)perf
  214. # Set paths to tools early so that they can be used for version tests.
  215. ifndef SHELL_PATH
  216. SHELL_PATH = /bin/sh
  217. endif
  218. ifndef PERL_PATH
  219. PERL_PATH = /usr/bin/perl
  220. endif
  221. export PERL_PATH
  222. LIB_FILE=$(OUTPUT)libperf.a
  223. LIB_H += ../../include/linux/perf_event.h
  224. LIB_H += ../../include/linux/rbtree.h
  225. LIB_H += ../../include/linux/list.h
  226. LIB_H += ../../include/linux/hash.h
  227. LIB_H += ../../include/linux/stringify.h
  228. LIB_H += util/include/linux/bitmap.h
  229. LIB_H += util/include/linux/bitops.h
  230. LIB_H += util/include/linux/compiler.h
  231. LIB_H += util/include/linux/ctype.h
  232. LIB_H += util/include/linux/kernel.h
  233. LIB_H += util/include/linux/list.h
  234. LIB_H += util/include/linux/module.h
  235. LIB_H += util/include/linux/poison.h
  236. LIB_H += util/include/linux/prefetch.h
  237. LIB_H += util/include/linux/rbtree.h
  238. LIB_H += util/include/linux/string.h
  239. LIB_H += util/include/linux/types.h
  240. LIB_H += util/include/linux/linkage.h
  241. LIB_H += util/include/asm/asm-offsets.h
  242. LIB_H += util/include/asm/bug.h
  243. LIB_H += util/include/asm/byteorder.h
  244. LIB_H += util/include/asm/hweight.h
  245. LIB_H += util/include/asm/swab.h
  246. LIB_H += util/include/asm/system.h
  247. LIB_H += util/include/asm/uaccess.h
  248. LIB_H += util/include/dwarf-regs.h
  249. LIB_H += util/include/asm/dwarf2.h
  250. LIB_H += util/include/asm/cpufeature.h
  251. LIB_H += perf.h
  252. LIB_H += util/annotate.h
  253. LIB_H += util/cache.h
  254. LIB_H += util/callchain.h
  255. LIB_H += util/build-id.h
  256. LIB_H += util/debug.h
  257. LIB_H += util/debugfs.h
  258. LIB_H += util/event.h
  259. LIB_H += util/evsel.h
  260. LIB_H += util/evlist.h
  261. LIB_H += util/exec_cmd.h
  262. LIB_H += util/types.h
  263. LIB_H += util/levenshtein.h
  264. LIB_H += util/map.h
  265. LIB_H += util/parse-options.h
  266. LIB_H += util/parse-events.h
  267. LIB_H += util/quote.h
  268. LIB_H += util/util.h
  269. LIB_H += util/xyarray.h
  270. LIB_H += util/header.h
  271. LIB_H += util/help.h
  272. LIB_H += util/session.h
  273. LIB_H += util/strbuf.h
  274. LIB_H += util/strlist.h
  275. LIB_H += util/strfilter.h
  276. LIB_H += util/svghelper.h
  277. LIB_H += util/run-command.h
  278. LIB_H += util/sigchain.h
  279. LIB_H += util/symbol.h
  280. LIB_H += util/color.h
  281. LIB_H += util/values.h
  282. LIB_H += util/sort.h
  283. LIB_H += util/hist.h
  284. LIB_H += util/thread.h
  285. LIB_H += util/thread_map.h
  286. LIB_H += util/trace-event.h
  287. LIB_H += util/probe-finder.h
  288. LIB_H += util/probe-event.h
  289. LIB_H += util/pstack.h
  290. LIB_H += util/cpumap.h
  291. LIB_H += util/top.h
  292. LIB_H += $(ARCH_INCLUDE)
  293. LIB_H += util/cgroup.h
  294. LIB_OBJS += $(OUTPUT)util/abspath.o
  295. LIB_OBJS += $(OUTPUT)util/alias.o
  296. LIB_OBJS += $(OUTPUT)util/annotate.o
  297. LIB_OBJS += $(OUTPUT)util/build-id.o
  298. LIB_OBJS += $(OUTPUT)util/config.o
  299. LIB_OBJS += $(OUTPUT)util/ctype.o
  300. LIB_OBJS += $(OUTPUT)util/debugfs.o
  301. LIB_OBJS += $(OUTPUT)util/environment.o
  302. LIB_OBJS += $(OUTPUT)util/event.o
  303. LIB_OBJS += $(OUTPUT)util/evlist.o
  304. LIB_OBJS += $(OUTPUT)util/evsel.o
  305. LIB_OBJS += $(OUTPUT)util/exec_cmd.o
  306. LIB_OBJS += $(OUTPUT)util/help.o
  307. LIB_OBJS += $(OUTPUT)util/levenshtein.o
  308. LIB_OBJS += $(OUTPUT)util/parse-options.o
  309. LIB_OBJS += $(OUTPUT)util/parse-events.o
  310. LIB_OBJS += $(OUTPUT)util/path.o
  311. LIB_OBJS += $(OUTPUT)util/rbtree.o
  312. LIB_OBJS += $(OUTPUT)util/bitmap.o
  313. LIB_OBJS += $(OUTPUT)util/hweight.o
  314. LIB_OBJS += $(OUTPUT)util/run-command.o
  315. LIB_OBJS += $(OUTPUT)util/quote.o
  316. LIB_OBJS += $(OUTPUT)util/strbuf.o
  317. LIB_OBJS += $(OUTPUT)util/string.o
  318. LIB_OBJS += $(OUTPUT)util/strlist.o
  319. LIB_OBJS += $(OUTPUT)util/strfilter.o
  320. LIB_OBJS += $(OUTPUT)util/top.o
  321. LIB_OBJS += $(OUTPUT)util/usage.o
  322. LIB_OBJS += $(OUTPUT)util/wrapper.o
  323. LIB_OBJS += $(OUTPUT)util/sigchain.o
  324. LIB_OBJS += $(OUTPUT)util/symbol.o
  325. LIB_OBJS += $(OUTPUT)util/color.o
  326. LIB_OBJS += $(OUTPUT)util/pager.o
  327. LIB_OBJS += $(OUTPUT)util/header.o
  328. LIB_OBJS += $(OUTPUT)util/callchain.o
  329. LIB_OBJS += $(OUTPUT)util/values.o
  330. LIB_OBJS += $(OUTPUT)util/debug.o
  331. LIB_OBJS += $(OUTPUT)util/map.o
  332. LIB_OBJS += $(OUTPUT)util/pstack.o
  333. LIB_OBJS += $(OUTPUT)util/session.o
  334. LIB_OBJS += $(OUTPUT)util/thread.o
  335. LIB_OBJS += $(OUTPUT)util/thread_map.o
  336. LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
  337. LIB_OBJS += $(OUTPUT)util/trace-event-read.o
  338. LIB_OBJS += $(OUTPUT)util/trace-event-info.o
  339. LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
  340. LIB_OBJS += $(OUTPUT)util/svghelper.o
  341. LIB_OBJS += $(OUTPUT)util/sort.o
  342. LIB_OBJS += $(OUTPUT)util/hist.o
  343. LIB_OBJS += $(OUTPUT)util/probe-event.o
  344. LIB_OBJS += $(OUTPUT)util/util.o
  345. LIB_OBJS += $(OUTPUT)util/xyarray.o
  346. LIB_OBJS += $(OUTPUT)util/cpumap.o
  347. LIB_OBJS += $(OUTPUT)util/cgroup.o
  348. BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
  349. BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
  350. # Benchmark modules
  351. BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
  352. BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
  353. ifeq ($(RAW_ARCH),x86_64)
  354. BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
  355. endif
  356. BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
  357. BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
  358. BUILTIN_OBJS += $(OUTPUT)builtin-help.o
  359. BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
  360. BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
  361. BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
  362. BUILTIN_OBJS += $(OUTPUT)builtin-list.o
  363. BUILTIN_OBJS += $(OUTPUT)builtin-record.o
  364. BUILTIN_OBJS += $(OUTPUT)builtin-report.o
  365. BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
  366. BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
  367. BUILTIN_OBJS += $(OUTPUT)builtin-top.o
  368. BUILTIN_OBJS += $(OUTPUT)builtin-script.o
  369. BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
  370. BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
  371. BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
  372. BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
  373. BUILTIN_OBJS += $(OUTPUT)builtin-test.o
  374. BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
  375. PERFLIBS = $(LIB_FILE)
  376. # Files needed for the python binding, perf.so
  377. # pyrf is just an internal name needed for all those wrappers.
  378. # This has to be in sync with what is in the 'sources' variable in
  379. # tools/perf/util/setup.py
  380. PYRF_OBJS += $(OUTPUT)util/cpumap.o
  381. PYRF_OBJS += $(OUTPUT)util/ctype.o
  382. PYRF_OBJS += $(OUTPUT)util/evlist.o
  383. PYRF_OBJS += $(OUTPUT)util/evsel.o
  384. PYRF_OBJS += $(OUTPUT)util/python.o
  385. PYRF_OBJS += $(OUTPUT)util/thread_map.o
  386. PYRF_OBJS += $(OUTPUT)util/util.o
  387. PYRF_OBJS += $(OUTPUT)util/xyarray.o
  388. #
  389. # Platform specific tweaks
  390. #
  391. # We choose to avoid "if .. else if .. else .. endif endif"
  392. # because maintaining the nesting to match is a pain. If
  393. # we had "elif" things would have been much nicer...
  394. -include config.mak.autogen
  395. -include config.mak
  396. ifndef NO_DWARF
  397. FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
  398. ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y)
  399. 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);
  400. NO_DWARF := 1
  401. endif # Dwarf support
  402. endif # NO_DWARF
  403. -include arch/$(ARCH)/Makefile
  404. ifneq ($(OUTPUT),)
  405. BASIC_CFLAGS += -I$(OUTPUT)
  406. endif
  407. FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
  408. ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y)
  409. FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS)
  410. ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y)
  411. msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
  412. else
  413. msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel);
  414. endif
  415. endif
  416. ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y)
  417. BASIC_CFLAGS += -DLIBELF_NO_MMAP
  418. endif
  419. ifndef NO_DWARF
  420. ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
  421. msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
  422. else
  423. BASIC_CFLAGS += -DDWARF_SUPPORT
  424. EXTLIBS += -lelf -ldw
  425. LIB_OBJS += $(OUTPUT)util/probe-finder.o
  426. endif # PERF_HAVE_DWARF_REGS
  427. endif # NO_DWARF
  428. ifdef NO_NEWT
  429. BASIC_CFLAGS += -DNO_NEWT_SUPPORT
  430. else
  431. FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt
  432. ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y)
  433. msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev);
  434. BASIC_CFLAGS += -DNO_NEWT_SUPPORT
  435. else
  436. # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
  437. BASIC_CFLAGS += -I/usr/include/slang
  438. EXTLIBS += -lnewt -lslang
  439. LIB_OBJS += $(OUTPUT)util/ui/setup.o
  440. LIB_OBJS += $(OUTPUT)util/ui/browser.o
  441. LIB_OBJS += $(OUTPUT)util/ui/browsers/annotate.o
  442. LIB_OBJS += $(OUTPUT)util/ui/browsers/hists.o
  443. LIB_OBJS += $(OUTPUT)util/ui/browsers/map.o
  444. LIB_OBJS += $(OUTPUT)util/ui/browsers/top.o
  445. LIB_OBJS += $(OUTPUT)util/ui/helpline.o
  446. LIB_OBJS += $(OUTPUT)util/ui/progress.o
  447. LIB_OBJS += $(OUTPUT)util/ui/util.o
  448. LIB_H += util/ui/browser.h
  449. LIB_H += util/ui/browsers/map.h
  450. LIB_H += util/ui/helpline.h
  451. LIB_H += util/ui/libslang.h
  452. LIB_H += util/ui/progress.h
  453. LIB_H += util/ui/util.h
  454. LIB_H += util/ui/ui.h
  455. endif
  456. endif
  457. ifdef NO_LIBPERL
  458. BASIC_CFLAGS += -DNO_LIBPERL
  459. else
  460. PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
  461. PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
  462. PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
  463. PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
  464. FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
  465. ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y)
  466. BASIC_CFLAGS += -DNO_LIBPERL
  467. else
  468. ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS)
  469. EXTLIBS += $(PERL_EMBED_LIBADD)
  470. LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
  471. LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
  472. endif
  473. endif
  474. ifdef NO_LIBPYTHON
  475. BASIC_CFLAGS += -DNO_LIBPYTHON
  476. else
  477. PYTHON_EMBED_LDOPTS = $(shell python-config --ldflags 2>/dev/null)
  478. PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
  479. PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
  480. PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
  481. FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
  482. ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
  483. msg := $(warning No Python.h found, install python-dev[el] to have python support in 'perf script' and to build the python bindings)
  484. BASIC_CFLAGS += -DNO_LIBPYTHON
  485. else
  486. ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
  487. EXTLIBS += $(PYTHON_EMBED_LIBADD)
  488. LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
  489. LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
  490. LANG_BINDINGS += $(OUTPUT)python/perf.so
  491. endif
  492. endif
  493. ifdef NO_DEMANGLE
  494. BASIC_CFLAGS += -DNO_DEMANGLE
  495. else
  496. ifdef HAVE_CPLUS_DEMANGLE
  497. EXTLIBS += -liberty
  498. BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
  499. else
  500. FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd
  501. has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
  502. ifeq ($(has_bfd),y)
  503. EXTLIBS += -lbfd
  504. else
  505. FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
  506. has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY))
  507. ifeq ($(has_bfd_iberty),y)
  508. EXTLIBS += -lbfd -liberty
  509. else
  510. FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
  511. has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z))
  512. ifeq ($(has_bfd_iberty_z),y)
  513. EXTLIBS += -lbfd -liberty -lz
  514. else
  515. FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty
  516. has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE))
  517. ifeq ($(has_cplus_demangle),y)
  518. EXTLIBS += -liberty
  519. BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
  520. else
  521. msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
  522. BASIC_CFLAGS += -DNO_DEMANGLE
  523. endif
  524. endif
  525. endif
  526. endif
  527. endif
  528. endif
  529. ifdef NO_STRLCPY
  530. BASIC_CFLAGS += -DNO_STRLCPY
  531. else
  532. ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
  533. BASIC_CFLAGS += -DNO_STRLCPY
  534. endif
  535. endif
  536. ifndef CC_LD_DYNPATH
  537. ifdef NO_R_TO_GCC_LINKER
  538. # Some gcc does not accept and pass -R to the linker to specify
  539. # the runtime dynamic library path.
  540. CC_LD_DYNPATH = -Wl,-rpath,
  541. else
  542. CC_LD_DYNPATH = -R
  543. endif
  544. endif
  545. ifdef NO_C99_FORMAT
  546. BASIC_CFLAGS += -DNO_C99_FORMAT
  547. endif
  548. ifdef NO_DEFLATE_BOUND
  549. BASIC_CFLAGS += -DNO_DEFLATE_BOUND
  550. endif
  551. ifdef NO_PERL_MAKEMAKER
  552. export NO_PERL_MAKEMAKER
  553. endif
  554. ifdef INTERNAL_QSORT
  555. COMPAT_CFLAGS += -DINTERNAL_QSORT
  556. COMPAT_OBJS += $(OUTPUT)compat/qsort.o
  557. endif
  558. ifdef RUNTIME_PREFIX
  559. COMPAT_CFLAGS += -DRUNTIME_PREFIX
  560. endif
  561. ifdef NO_EXTERNAL_GREP
  562. BASIC_CFLAGS += -DNO_EXTERNAL_GREP
  563. endif
  564. ifeq ($(PERL_PATH),)
  565. NO_PERL=NoThanks
  566. endif
  567. QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
  568. QUIET_SUBDIR1 =
  569. ifneq ($(findstring $(MAKEFLAGS),w),w)
  570. PRINT_DIR = --no-print-directory
  571. else # "make -w"
  572. NO_SUBDIR = :
  573. endif
  574. ifneq ($(findstring $(MAKEFLAGS),s),s)
  575. ifndef V
  576. QUIET_CC = @echo ' ' CC $@;
  577. QUIET_AR = @echo ' ' AR $@;
  578. QUIET_LINK = @echo ' ' LINK $@;
  579. QUIET_MKDIR = @echo ' ' MKDIR $@;
  580. QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
  581. QUIET_GEN = @echo ' ' GEN $@;
  582. QUIET_SUBDIR0 = +@subdir=
  583. QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
  584. $(MAKE) $(PRINT_DIR) -C $$subdir
  585. export V
  586. export QUIET_GEN
  587. export QUIET_BUILT_IN
  588. endif
  589. endif
  590. ifdef ASCIIDOC8
  591. export ASCIIDOC8
  592. endif
  593. # Shell quote (do not use $(call) to accommodate ancient setups);
  594. ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
  595. DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  596. bindir_SQ = $(subst ','\'',$(bindir))
  597. bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
  598. mandir_SQ = $(subst ','\'',$(mandir))
  599. infodir_SQ = $(subst ','\'',$(infodir))
  600. perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
  601. template_dir_SQ = $(subst ','\'',$(template_dir))
  602. htmldir_SQ = $(subst ','\'',$(htmldir))
  603. prefix_SQ = $(subst ','\'',$(prefix))
  604. SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  605. PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
  606. LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive $(EXTLIBS)
  607. ALL_CFLAGS += $(BASIC_CFLAGS)
  608. ALL_CFLAGS += $(ARCH_CFLAGS)
  609. ALL_LDFLAGS += $(BASIC_LDFLAGS)
  610. export TAR INSTALL DESTDIR SHELL_PATH
  611. ### Build rules
  612. SHELL = $(SHELL_PATH)
  613. all:: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS
  614. all::
  615. please_set_SHELL_PATH_to_a_more_modern_shell:
  616. @$$(:)
  617. shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
  618. strip: $(PROGRAMS) $(OUTPUT)perf
  619. $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
  620. $(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  621. $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
  622. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  623. $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
  624. $(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
  625. $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
  626. $(BUILTIN_OBJS) $(LIBS) -o $@
  627. $(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  628. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  629. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  630. '-DPERF_MAN_PATH="$(mandir_SQ)"' \
  631. '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
  632. $(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
  633. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  634. '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
  635. '-DPERF_MAN_PATH="$(mandir_SQ)"' \
  636. '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
  637. $(BUILT_INS): $(OUTPUT)perf$X
  638. $(QUIET_BUILT_IN)$(RM) $@ && \
  639. ln perf$X $@ 2>/dev/null || \
  640. ln -s perf$X $@ 2>/dev/null || \
  641. cp perf$X $@
  642. $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
  643. $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
  644. $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
  645. $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
  646. $(QUIET_GEN)$(RM) $(OUTPUT)$@ $(OUTPUT)$@+ && \
  647. sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
  648. -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
  649. -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
  650. -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
  651. -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
  652. $@.sh > $(OUTPUT)$@+ && \
  653. chmod +x $(OUTPUT)$@+ && \
  654. mv $(OUTPUT)$@+ $(OUTPUT)$@
  655. configure: configure.ac
  656. $(QUIET_GEN)$(RM) $@ $<+ && \
  657. sed -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
  658. $< > $<+ && \
  659. autoconf -o $@ $<+ && \
  660. $(RM) $<+
  661. # These can record PERF_VERSION
  662. $(OUTPUT)perf.o perf.spec \
  663. $(patsubst %.sh,%,$(SCRIPT_SH)) \
  664. $(patsubst %.perl,%,$(SCRIPT_PERL)) \
  665. : $(OUTPUT)PERF-VERSION-FILE
  666. $(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
  667. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
  668. $(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
  669. $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
  670. $(OUTPUT)%.o: %.S
  671. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
  672. $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
  673. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
  674. '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
  675. '-DBINDIR="$(bindir_relative_SQ)"' \
  676. '-DPREFIX="$(prefix_SQ)"' \
  677. $<
  678. $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
  679. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  680. $(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS
  681. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
  682. $(OUTPUT)util/ui/browsers/annotate.o: util/ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
  683. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
  684. $(OUTPUT)util/ui/browsers/top.o: util/ui/browsers/top.c $(OUTPUT)PERF-CFLAGS
  685. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
  686. $(OUTPUT)util/ui/browsers/hists.o: util/ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
  687. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
  688. $(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
  689. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
  690. $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
  691. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
  692. $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
  693. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
  694. $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
  695. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
  696. $(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
  697. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
  698. $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
  699. $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
  700. $(OUTPUT)perf-%: %.o $(PERFLIBS)
  701. $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
  702. $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
  703. $(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
  704. # we compile into subdirectories. if the target directory is not the source directory, they might not exists. So
  705. # we depend the various files onto their directories.
  706. DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
  707. $(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
  708. # In the second step, we make a rule to actually create these directories
  709. $(sort $(dir $(DIRECTORY_DEPS))):
  710. $(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
  711. $(LIB_FILE): $(LIB_OBJS)
  712. $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
  713. help:
  714. @echo 'Perf make targets:'
  715. @echo ' doc - make *all* documentation (see below)'
  716. @echo ' man - make manpage documentation (access with man <foo>)'
  717. @echo ' html - make html documentation'
  718. @echo ' info - make GNU info documentation (access with info <foo>)'
  719. @echo ' pdf - make pdf documentation'
  720. @echo ' TAGS - use etags to make tag information for source browsing'
  721. @echo ' tags - use ctags to make tag information for source browsing'
  722. @echo ' cscope - use cscope to make interactive browsing database'
  723. @echo ''
  724. @echo 'Perf install targets:'
  725. @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
  726. @echo ' HINT: use "make prefix=<path> <install target>" to install to a particular'
  727. @echo ' path like make prefix=/usr/local install install-doc'
  728. @echo ' install - install compiled binaries'
  729. @echo ' install-doc - install *all* documentation'
  730. @echo ' install-man - install manpage documentation'
  731. @echo ' install-html - install html documentation'
  732. @echo ' install-info - install GNU info documentation'
  733. @echo ' install-pdf - install pdf documentation'
  734. @echo ''
  735. @echo ' quick-install-doc - alias for quick-install-man'
  736. @echo ' quick-install-man - install the documentation quickly'
  737. @echo ' quick-install-html - install the html documentation quickly'
  738. @echo ''
  739. @echo 'Perf maintainer targets:'
  740. @echo ' distclean - alias to clean'
  741. @echo ' clean - clean all binary objects and build output'
  742. doc:
  743. $(MAKE) -C Documentation all
  744. man:
  745. $(MAKE) -C Documentation man
  746. html:
  747. $(MAKE) -C Documentation html
  748. info:
  749. $(MAKE) -C Documentation info
  750. pdf:
  751. $(MAKE) -C Documentation pdf
  752. TAGS:
  753. $(RM) TAGS
  754. $(FIND) . -name '*.[hcS]' -print | xargs etags -a
  755. tags:
  756. $(RM) tags
  757. $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
  758. cscope:
  759. $(RM) cscope*
  760. $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
  761. ### Detect prefix changes
  762. TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
  763. $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
  764. $(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
  765. @FLAGS='$(TRACK_CFLAGS)'; \
  766. if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
  767. echo 1>&2 " * new build flags or prefix"; \
  768. echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
  769. fi
  770. # We need to apply sq twice, once to protect from the shell
  771. # that runs $(OUTPUT)PERF-BUILD-OPTIONS, and then again to protect it
  772. # and the first level quoting from the shell that runs "echo".
  773. $(OUTPUT)PERF-BUILD-OPTIONS: .FORCE-PERF-BUILD-OPTIONS
  774. @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
  775. @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
  776. @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
  777. @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
  778. ### Testing rules
  779. #
  780. # None right now:
  781. #
  782. # TEST_PROGRAMS += test-something$X
  783. all:: $(TEST_PROGRAMS)
  784. # GNU make supports exporting all variables by "export" without parameters.
  785. # However, the environment gets quite big, and some programs have problems
  786. # with that.
  787. check: $(OUTPUT)common-cmds.h
  788. if sparse; \
  789. then \
  790. for i in *.c */*.c; \
  791. do \
  792. sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
  793. done; \
  794. else \
  795. echo 2>&1 "Did you mean 'make test'?"; \
  796. exit 1; \
  797. fi
  798. remove-dashes:
  799. ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
  800. ### Installation rules
  801. ifneq ($(filter /%,$(firstword $(template_dir))),)
  802. template_instdir = $(template_dir)
  803. else
  804. template_instdir = $(prefix)/$(template_dir)
  805. endif
  806. export template_instdir
  807. ifneq ($(filter /%,$(firstword $(perfexecdir))),)
  808. perfexec_instdir = $(perfexecdir)
  809. else
  810. perfexec_instdir = $(prefix)/$(perfexecdir)
  811. endif
  812. perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
  813. export perfexec_instdir
  814. install: all
  815. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
  816. $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
  817. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
  818. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  819. $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  820. $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
  821. $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
  822. $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
  823. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
  824. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  825. $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
  826. $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
  827. $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
  828. ifdef BUILT_INS
  829. $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  830. $(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
  831. ifneq (,$X)
  832. $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) $(OUTPUT)perf$X)), $(RM) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$p';)
  833. endif
  834. endif
  835. install-doc:
  836. $(MAKE) -C Documentation install
  837. install-man:
  838. $(MAKE) -C Documentation install-man
  839. install-html:
  840. $(MAKE) -C Documentation install-html
  841. install-info:
  842. $(MAKE) -C Documentation install-info
  843. install-pdf:
  844. $(MAKE) -C Documentation install-pdf
  845. quick-install-doc:
  846. $(MAKE) -C Documentation quick-install
  847. quick-install-man:
  848. $(MAKE) -C Documentation quick-install-man
  849. quick-install-html:
  850. $(MAKE) -C Documentation quick-install-html
  851. ### Maintainer's dist rules
  852. #
  853. # None right now
  854. #
  855. #
  856. # perf.spec: perf.spec.in
  857. # sed -e 's/@@VERSION@@/$(PERF_VERSION)/g' < $< > $@+
  858. # mv $@+ $@
  859. #
  860. # PERF_TARNAME=perf-$(PERF_VERSION)
  861. # dist: perf.spec perf-archive$(X) configure
  862. # ./perf-archive --format=tar \
  863. # --prefix=$(PERF_TARNAME)/ HEAD^{tree} > $(PERF_TARNAME).tar
  864. # @mkdir -p $(PERF_TARNAME)
  865. # @cp perf.spec configure $(PERF_TARNAME)
  866. # @echo $(PERF_VERSION) > $(PERF_TARNAME)/version
  867. # $(TAR) rf $(PERF_TARNAME).tar \
  868. # $(PERF_TARNAME)/perf.spec \
  869. # $(PERF_TARNAME)/configure \
  870. # $(PERF_TARNAME)/version
  871. # @$(RM) -r $(PERF_TARNAME)
  872. # gzip -f -9 $(PERF_TARNAME).tar
  873. #
  874. # htmldocs = perf-htmldocs-$(PERF_VERSION)
  875. # manpages = perf-manpages-$(PERF_VERSION)
  876. # dist-doc:
  877. # $(RM) -r .doc-tmp-dir
  878. # mkdir .doc-tmp-dir
  879. # $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
  880. # cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
  881. # gzip -n -9 -f $(htmldocs).tar
  882. # :
  883. # $(RM) -r .doc-tmp-dir
  884. # mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
  885. # $(MAKE) -C Documentation DESTDIR=./ \
  886. # man1dir=../.doc-tmp-dir/man1 \
  887. # man5dir=../.doc-tmp-dir/man5 \
  888. # man7dir=../.doc-tmp-dir/man7 \
  889. # install
  890. # cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
  891. # gzip -n -9 -f $(manpages).tar
  892. # $(RM) -r .doc-tmp-dir
  893. #
  894. # rpm: dist
  895. # $(RPMBUILD) -ta $(PERF_TARNAME).tar.gz
  896. ### Cleaning rules
  897. distclean: clean
  898. # $(RM) configure
  899. clean:
  900. $(RM) $(OUTPUT){*.o,*/*.o,*/*/*.o,*/*/*/*.o,$(LIB_FILE),perf-archive}
  901. $(RM) $(ALL_PROGRAMS) $(BUILT_INS) perf
  902. $(RM) $(TEST_PROGRAMS)
  903. $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
  904. $(RM) -r $(PERF_TARNAME) .doc-tmp-dir
  905. $(RM) $(PERF_TARNAME).tar.gz perf-core_$(PERF_VERSION)-*.tar.gz
  906. $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
  907. $(MAKE) -C Documentation/ clean
  908. $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)PERF-BUILD-OPTIONS
  909. @python util/setup.py clean --build-lib='$(OUTPUT)python' \
  910. --build-temp='$(OUTPUT)python/temp'
  911. .PHONY: all install clean strip
  912. .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
  913. .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
  914. .PHONY: .FORCE-PERF-BUILD-OPTIONS
  915. ### Make sure built-ins do not have dups and listed in perf.c
  916. #
  917. check-builtins::
  918. ./check-builtins.sh
  919. ### Test suite coverage testing
  920. #
  921. # None right now
  922. #
  923. # .PHONY: coverage coverage-clean coverage-build coverage-report
  924. #
  925. # coverage:
  926. # $(MAKE) coverage-build
  927. # $(MAKE) coverage-report
  928. #
  929. # coverage-clean:
  930. # rm -f *.gcda *.gcno
  931. #
  932. # COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
  933. # COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov
  934. #
  935. # coverage-build: coverage-clean
  936. # $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
  937. # $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
  938. # -j1 test
  939. #
  940. # coverage-report:
  941. # gcov -b *.c */*.c
  942. # grep '^function.*called 0 ' *.c.gcov */*.c.gcov \
  943. # | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
  944. # | tee coverage-untested-functions