Makefile 33 KB

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