Makefile.am 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473
  1. ## Process this file with automake to produce Makefile.in
  2. # Note: for every library we create, we're explicit about what symbols
  3. # we export. In order to avoid complications with C++ mangling, we always
  4. # use the regexp for of specifying symbols.
  5. # Make sure that when we re-make ./configure, we get the macros we need
  6. ACLOCAL_AMFLAGS = -I m4
  7. AUTOMAKE_OPTIONS = subdir-objects
  8. # This is so we can #include <gperftools/foo>
  9. AM_CPPFLAGS = -I$(top_srcdir)/src
  10. if !WITH_STACK_TRACE
  11. AM_CPPFLAGS += -DNO_TCMALLOC_SAMPLES
  12. endif !WITH_STACK_TRACE
  13. # This is mostly based on configure options
  14. AM_CXXFLAGS =
  15. NO_BUILTIN_CXXFLAGS =
  16. # These are good warnings to turn on by default. We also tell gcc
  17. # that malloc, free, realloc, mmap, etc. are not builtins (these flags
  18. # are supported since gcc 3.1.1). gcc doesn't think most of them are
  19. # builtins now in any case, but it's best to be explicit in case that
  20. # changes one day. gcc ignores functions it doesn't understand.
  21. if GCC
  22. AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual \
  23. -Wno-sign-compare \
  24. -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc \
  25. -fno-builtin-calloc -fno-builtin-cfree \
  26. -fno-builtin-memalign -fno-builtin-posix_memalign \
  27. -fno-builtin-valloc -fno-builtin-pvalloc
  28. NO_BUILTIN_CXXFLAGS += -fno-builtin
  29. # On i386, -mmmx is needed for the mmx-based instructions in
  30. # atomicops-internal-x86.h. Also as of gcc 4.6, -fomit-frame-pointer
  31. # is the default. Since we must always have frame pointers for I386
  32. # in order to generate backtraces we now specify -fno-omit-frame-pointer
  33. # by default.
  34. if I386
  35. AM_CXXFLAGS += -mmmx
  36. AM_CXXFLAGS += -fno-omit-frame-pointer
  37. endif I386
  38. endif GCC
  39. if HAVE_W_NO_UNUSED_RESULT
  40. AM_CXXFLAGS += -Wno-unused-result
  41. endif HAVE_W_NO_UNUSED_RESULT
  42. #if HAVE_SIZED_DEALLOCATION
  43. #AM_CXXFLAGS += -fsized-deallocation
  44. #endif HAVE_SIZED_DEALLOCATION
  45. # The -no-undefined flag allows libtool to generate shared libraries for
  46. # Cygwin and MinGW. LIBSTDCXX_LA_LINKER_FLAG is used to fix a Solaris bug.
  47. AM_LDFLAGS = -no-undefined $(LIBSTDCXX_LA_LINKER_FLAG)
  48. # We know our low-level code cannot trigger an exception. On some
  49. # systems, such as cygwin, it would be disastrous if they did, because
  50. # the exception handler might call malloc! If our low-level routines
  51. # raised an exception within the malloc, they'd deadlock. Luckily,
  52. # we control all this code, and do not need exceptions for it.
  53. if GCC
  54. NO_EXCEPTIONS = -fno-exceptions
  55. else !GCC
  56. NO_EXCEPTIONS =
  57. endif !GCC
  58. # These are x86-specific, having to do with frame-pointers. In
  59. # particular, some x86_64 systems do not insert frame pointers by
  60. # default (all i386 systems that I know of, do. I don't know about
  61. # non-x86 chips). We need to tell perftools what to do about that.
  62. if X86_64_AND_NO_FP_BY_DEFAULT
  63. if ENABLE_FRAME_POINTERS
  64. AM_CXXFLAGS += -fno-omit-frame-pointer
  65. else
  66. # TODO(csilvers): check if -fomit-frame-pointer might be in $(CXXFLAGS),
  67. # before setting this.
  68. AM_CXXFLAGS += -DNO_FRAME_POINTER
  69. endif !ENABLE_FRAME_POINTERS
  70. endif X86_64_AND_NO_FP_BY_DEFAULT
  71. # For windows systems (at least, mingw), we need to tell all our
  72. # tests to link in libtcmalloc using -u. This is because libtcmalloc
  73. # accomplishes its tasks via patching, leaving no work for the linker
  74. # to identify, so the linker will ignore libtcmalloc by default unless
  75. # we explicitly create a dependency via -u.
  76. TCMALLOC_FLAGS =
  77. if MINGW
  78. TCMALLOC_FLAGS += -Wl,-u__tcmalloc
  79. endif MINGW
  80. # If we have objcopy, make malloc/free/etc weak symbols. That way folks
  81. # can override our malloc if they want to (they can still use tc_malloc).
  82. # Note: the weird-looking symbols are the c++ memory functions:
  83. # (in order) new, new(nothrow), new[], new[](nothrow), delete, delete[]
  84. # In theory this will break if mangling changes, but that seems pretty
  85. # unlikely at this point. Just in case, I throw in versions with an
  86. # extra underscore as well, which may help on OS X.
  87. if HAVE_OBJCOPY_WEAKEN
  88. WEAKEN = $(OBJCOPY) -W malloc -W free -W realloc -W calloc -W cfree \
  89. -W memalign -W posix_memalign -W valloc -W pvalloc \
  90. -W malloc_stats -W mallopt -W mallinfo \
  91. -W _Znwm -W _ZnwmRKSt9nothrow_t -W _Znam -W _ZnamRKSt9nothrow_t \
  92. -W _ZdlPv -W _ZdaPv \
  93. -W __Znwm -W __ZnwmRKSt9nothrow_t -W __Znam -W __ZnamRKSt9nothrow_t \
  94. -W __ZdlPv -W __ZdaPv
  95. else
  96. WEAKEN = :
  97. endif !HAVE_OBJCOPY_WEAKEN
  98. LIBS_TO_WEAKEN =
  99. perftoolsincludedir = $(includedir)/gperftools
  100. # The .h files you want to install (that is, .h files that people
  101. # who install this package can include in their own applications.)
  102. # We'll add to this later, on a library-by-library basis
  103. perftoolsinclude_HEADERS =
  104. # tcmalloc.h is a special case, because it's a .h.in file
  105. nodist_perftoolsinclude_HEADERS = src/gperftools/tcmalloc.h
  106. noinst_HEADERS = src/gperftools/tcmalloc.h.in
  107. # This is provided for backwards compatibility. It is populated by
  108. # files that just forward to the canonical location in
  109. # perftoolsincludedir.
  110. googleincludedir = $(includedir)/google
  111. googleinclude_HEADERS = \
  112. src/google/heap-checker.h \
  113. src/google/heap-profiler.h \
  114. src/google/malloc_extension.h \
  115. src/google/malloc_extension_c.h \
  116. src/google/malloc_hook.h \
  117. src/google/malloc_hook_c.h \
  118. src/google/profiler.h \
  119. src/google/stacktrace.h \
  120. src/google/tcmalloc.h
  121. # This is for HTML and other documentation you want to install.
  122. # Add your documentation files (in doc/) in addition to these
  123. # top-level boilerplate files. Also add a TODO file if you have one.
  124. # We'll add to this later, on a library-by-library basis
  125. dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README_windows.txt \
  126. TODO
  127. # The libraries (.so's) you want to install
  128. # We'll add to this later, on a library-by-library basis
  129. lib_LTLIBRARIES =
  130. # This is for 'convenience libraries' -- basically just a container for sources
  131. noinst_LTLIBRARIES =
  132. ## The location of the windows project file for each binary we make
  133. WINDOWS_PROJECTS = gperftools.sln
  134. # unittests you want to run when people type 'make check'.
  135. # Note: tests cannot take any arguments!
  136. # In theory, unittests that are scripts should be added to check_SCRIPTS
  137. # instead. But check_SCRIPTS is definitely a second-class testing mechanims:
  138. # it don't get TESTS_ENVIRONMENT, and it doesn't get success/failure counting
  139. # (in fact, a script failure aborts all the rest of the tests, even with -k).
  140. # So, for scripts, we add the script to tests, and also put in an empty
  141. # rule so automake doesn't try to build the script as a C binary.
  142. TESTS =
  143. # TESTS_ENVIRONMENT sets environment variables for when you run unittest.
  144. # We always get "srcdir" set for free.
  145. # We'll add to this later, on a library-by-library basis.
  146. TESTS_ENVIRONMENT =
  147. # All script tests should be added here
  148. noinst_SCRIPTS =
  149. # If your test calls another program that, like the test itself, shouldn't
  150. # be installed, add it here. (Stuff in TESTS is automatically added later).
  151. noinst_PROGRAMS =
  152. # Binaries we might build that should be installed
  153. bin_PROGRAMS =
  154. # This is my own var, used for extra libraries I make that I need installed
  155. EXTRA_INSTALL =
  156. ## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
  157. dist_doc_DATA += doc/index.html doc/designstyle.css
  158. ### ------- library routines, in src/base
  159. # This is a 'convenience library' -- it's not actually installed or anything
  160. LOGGING_INCLUDES = src/base/logging.h \
  161. src/base/commandlineflags.h \
  162. src/base/basictypes.h \
  163. src/base/dynamic_annotations.h \
  164. src/third_party/valgrind.h
  165. noinst_LTLIBRARIES += liblogging.la
  166. liblogging_la_SOURCES = src/base/logging.cc \
  167. src/base/dynamic_annotations.c \
  168. $(LOGGING_INCLUDES)
  169. SYSINFO_INCLUDES = src/base/sysinfo.h \
  170. src/getenv_safe.h \
  171. src/base/logging.h \
  172. src/base/commandlineflags.h \
  173. src/base/arm_instruction_set_select.h \
  174. src/base/basictypes.h
  175. noinst_LTLIBRARIES += libsgx_utils.la
  176. libsgx_utils_la_SOURCES = src/base/sgx_utils.cc
  177. #libsysinfo_la_LIBADD = $(NANOSLEEP_LIBS)
  178. noinst_LTLIBRARIES += libmaybe_threads.la
  179. # .cc is conditionally added below
  180. libmaybe_threads_la_SOURCES = src/maybe_threads.h
  181. # For MinGW, we use also have to use libwindows Luckily, we need the
  182. # windows.a library in exactly the same place we need spinlock.a
  183. # (pretty much everywhere), so we can use the same variable name for
  184. # each. We can also optimize the MinGW rule a bit by leaving out
  185. # files we know aren't used on windows, such as
  186. # atomicops-internals-x86.cc. libwindows also obsoletes the need for
  187. # other files like system_alloc.cc.
  188. if MINGW
  189. WINDOWS_INCLUDES = src/windows/port.h \
  190. src/windows/mingw.h \
  191. src/windows/mini_disassembler.h \
  192. src/windows/mini_disassembler_types.h \
  193. src/windows/preamble_patcher.h
  194. noinst_LTLIBRARIES += libwindows.la
  195. libwindows_la_SOURCES = $(WINDOWS_INCLUDES) \
  196. src/windows/port.cc \
  197. src/windows/system-alloc.cc \
  198. src/windows/ia32_modrm_map.cc \
  199. src/windows/ia32_opcode_map.cc \
  200. src/windows/mini_disassembler.cc \
  201. src/windows/patch_functions.cc \
  202. src/windows/preamble_patcher.cc \
  203. src/windows/preamble_patcher_with_stub.cc
  204. # patch_functions.cc uses Psapi.lib. MSVC has a #pragma for that, but not us.
  205. libwindows_la_LIBADD = -lpsapi
  206. SPINLOCK_INCLUDES = src/base/spinlock.h \
  207. src/base/spinlock_internal.h \
  208. src/base/spinlock_win32-inl.h \
  209. src/base/spinlock_linux-inl.h \
  210. src/base/spinlock_posix-inl.h \
  211. src/base/atomicops-internals-macosx.h \
  212. src/base/atomicops-internals-linuxppc.h \
  213. src/base/atomicops-internals-arm-generic.h \
  214. src/base/atomicops-internals-arm-v6plus.h \
  215. src/base/atomicops-internals-mips.h \
  216. src/base/atomicops-internals-windows.h \
  217. src/base/atomicops-internals-gcc.h \
  218. src/base/atomicops-internals-x86.h
  219. noinst_LTLIBRARIES += libspinlock.la
  220. libspinlock_la_SOURCES = src/base/spinlock.cc \
  221. # src/base/spinlock_internal.cc \
  222. src/base/atomicops-internals-x86.cc \
  223. $(SPINLOCK_INCLUDES)
  224. LIBSPINLOCK = libwindows.la libspinlock.la libsgx_utils.la liblogging.la
  225. # We also need to tell mingw that sysinfo.cc needs shlwapi.lib.
  226. # (We do this via a #pragma for msvc, but need to do it here for mingw).
  227. libsysinfo_la_LIBADD += -lshlwapi
  228. # There's a windows-specific unittest we can run. Right now it's
  229. # win64-specific, and relies on masm, so we comment it out.
  230. ## TESTS += preamble_patcher_test
  231. ## preamble_patcher_test_SOURCES = src/windows/preamble_patcher_test.cc \
  232. ## src/windows/shortproc.asm \
  233. ## src/windows/auto_testing_hook.h \
  234. ## src/windows/preamble_patcher.h \
  235. ## src/base/basictypes.h \
  236. ## src/base/logging.h
  237. ## preamble_patcher_test_LDFLAGS = $(TCMALLOC_FLAGS)
  238. ## preamble_patcher_test_LDADD = $(LIBTCMALLOC_MINIMAL)
  239. # patch_functions.cc #includes tcmalloc.cc, so no need to link it in.
  240. TCMALLOC_CC =
  241. # windows has its own system for threads and system memory allocation.
  242. if HAVE_PTHREAD_DESPITE_ASKING_FOR
  243. libmaybe_threads_la_SOURCES += src/maybe_threads.cc
  244. endif
  245. SYSTEM_ALLOC_CC =
  246. else !MINGW
  247. # spinlock is the only code that uses atomicops.
  248. SPINLOCK_INCLUDES = src/base/spinlock.h \
  249. src/base/spinlock_internal.h \
  250. src/base/atomicops.h \
  251. src/base/atomicops-internals-macosx.h \
  252. src/base/atomicops-internals-linuxppc.h \
  253. src/base/atomicops-internals-windows.h \
  254. src/base/atomicops-internals-x86.h
  255. noinst_LTLIBRARIES += libspinlock.la
  256. libspinlock_la_SOURCES = src/base/spinlock.cc \
  257. # src/base/spinlock_internal.cc \
  258. src/base/atomicops-internals-x86.cc \
  259. $(SPINLOCK_INCLUDES)
  260. libspinlock_la_LIBADD = $(NANOSLEEP_LIBS)
  261. # spinlock also needs NumCPUs, from libsysinfo, which in turn needs liblogging
  262. LIBSPINLOCK = libspinlock.la libsgx_utils.la liblogging.la
  263. TCMALLOC_CC = src/tcmalloc.cc
  264. libmaybe_threads_la_SOURCES += src/maybe_threads.cc
  265. SYSTEM_ALLOC_CC = src/system-alloc.cc
  266. endif !MINGW
  267. # Add this whether or not we're under MinGW, to keep the tarball complete.
  268. WINDOWS_PROJECTS += vsprojects/preamble_patcher_test/preamble_patcher_test.vcproj
  269. # Because we've commented out the test, above, we have to explicitly add
  270. # the test files to the tarball or automake will leave them out.
  271. WINDOWS_PROJECTS += src/windows/preamble_patcher_test.cc \
  272. src/windows/shortproc.asm \
  273. src/windows/auto_testing_hook.h
  274. ### Unittests
  275. TESTS += low_level_alloc_unittest
  276. WINDOWS_PROJECTS += vsprojects/low_level_alloc_unittest/low_level_alloc_unittest.vcproj
  277. LOW_LEVEL_ALLOC_UNITTEST_INCLUDES = src/base/low_level_alloc.h \
  278. src/base/basictypes.h \
  279. src/gperftools/malloc_hook.h \
  280. src/gperftools/malloc_hook_c.h \
  281. src/malloc_hook-inl.h \
  282. src/malloc_hook_mmap_linux.h \
  283. src/malloc_hook_mmap_freebsd.h \
  284. $(SPINLOCK_INCLUDES) \
  285. $(LOGGING_INCLUDES)
  286. low_level_alloc_unittest_SOURCES = src/base/low_level_alloc.cc \
  287. src/malloc_hook.cc \
  288. src/tests/low_level_alloc_unittest.cc \
  289. $(LOW_LEVEL_ALLOC_UNITTEST_INCLUDES)
  290. # By default, MallocHook takes stack traces for use by the heap-checker.
  291. # We don't need that functionality here, so we turn it off to reduce deps.
  292. low_level_alloc_unittest_CXXFLAGS = -DNO_TCMALLOC_SAMPLES
  293. low_level_alloc_unittest_LDADD = $(LIBSPINLOCK) libmaybe_threads.la
  294. TESTS += atomicops_unittest
  295. ATOMICOPS_UNITTEST_INCLUDES = src/base/atomicops.h \
  296. src/base/atomicops-internals-macosx.h \
  297. src/base/atomicops-internals-windows.h \
  298. src/base/atomicops-internals-x86.h \
  299. $(LOGGING_INCLUDES)
  300. atomicops_unittest_SOURCES = src/tests/atomicops_unittest.cc \
  301. $(ATOMICOPS_UNITTEST_INCLUDES)
  302. atomicops_unittest_LDADD = $(LIBSPINLOCK)
  303. ### ------- stack trace
  304. if WITH_STACK_TRACE
  305. ### The header files we use. We divide into categories based on directory
  306. S_STACKTRACE_INCLUDES = src/stacktrace_impl_setup-inl.h \
  307. src/stacktrace_generic-inl.h \
  308. src/stacktrace_libgcc-inl.h \
  309. src/stacktrace_libunwind-inl.h \
  310. src/stacktrace_arm-inl.h \
  311. src/stacktrace_powerpc-inl.h \
  312. src/stacktrace_powerpc-darwin-inl.h \
  313. src/stacktrace_powerpc-linux-inl.h \
  314. src/stacktrace_x86-inl.h \
  315. src/stacktrace_win32-inl.h \
  316. src/stacktrace_instrument-inl.h \
  317. src/base/elf_mem_image.h \
  318. src/base/vdso_support.h
  319. SG_STACKTRACE_INCLUDES = src/gperftools/stacktrace.h
  320. STACKTRACE_INCLUDES = $(S_STACKTRACE_INCLUDES) $(SG_STACKTRACE_INCLUDES)
  321. perftoolsinclude_HEADERS += $(SG_STACKTRACE_INCLUDES)
  322. ### Making the library
  323. noinst_LTLIBRARIES += libstacktrace.la
  324. libstacktrace_la_SOURCES = src/stacktrace.cc \
  325. src/base/elf_mem_image.cc \
  326. src/base/vdso_support.cc \
  327. $(STACKTRACE_INCLUDES)
  328. libstacktrace_la_LIBADD = $(UNWIND_LIBS) $(LIBSPINLOCK)
  329. STACKTRACE_SYMBOLS = '(GetStackTrace|GetStackFrames|GetStackTraceWithContext|GetStackFramesWithContext)'
  330. libstacktrace_la_LDFLAGS = -export-symbols-regex $(STACKTRACE_SYMBOLS) $(AM_LDFLAGS)
  331. noinst_LTLIBRARIES += libfake_stacktrace_scope.la
  332. libfake_stacktrace_scope_la_SOURCES = src/fake_stacktrace_scope.cc
  333. ### Unittests
  334. TESTS += stacktrace_unittest
  335. STACKTRACE_UNITTEST_INCLUDES = src/config_for_unittests.h \
  336. src/base/commandlineflags.h \
  337. $(STACKTRACE_INCLUDES) \
  338. $(LOGGING_INCLUDES)
  339. stacktrace_unittest_SOURCES = src/tests/stacktrace_unittest.cc \
  340. $(STACKTRACE_UNITTEST_INCLUDES)
  341. stacktrace_unittest_LDADD = libstacktrace.la liblogging.la libfake_stacktrace_scope.la
  342. ### Documentation
  343. dist_doc_DATA +=
  344. endif WITH_STACK_TRACE
  345. ### ------- pprof
  346. # If we are not compiling with stacktrace support, pprof is worthless
  347. if WITH_STACK_TRACE
  348. bin_SCRIPTS = src/pprof
  349. ### Unittests
  350. check_SCRIPTS = pprof_unittest
  351. pprof_unittest: $(top_srcdir)/src/pprof
  352. $(top_srcdir)/src/pprof -test
  353. # Let unittests find pprof if they need to run it
  354. TESTS_ENVIRONMENT += PPROF_PATH=$(top_srcdir)/src/pprof
  355. ### Documentation
  356. dist_man_MANS = doc/pprof.1
  357. dist_doc_DATA += doc/pprof_remote_servers.html
  358. # On MSVC, we need our own versions of addr2line and nm to work with pprof.
  359. WINDOWS_PROJECTS += vsprojects/nm-pdb/nm-pdb.vcproj
  360. WINDOWS_PROJECTS += vsprojects/addr2line-pdb/addr2line-pdb.vcproj
  361. # This is a slight abuse of WINDOWS_PROJECTS, but not much
  362. WINDOWS_PROJECTS += src/windows/nm-pdb.c \
  363. src/windows/addr2line-pdb.c
  364. endif WITH_STACK_TRACE
  365. ### ------- tcmalloc_minimal (thread-caching malloc)
  366. ### The header files we use. We divide into categories based on directory
  367. S_TCMALLOC_MINIMAL_INCLUDES = src/common.h \
  368. src/internal_logging.h \
  369. src/system-alloc.h \
  370. src/packed-cache-inl.h \
  371. $(SPINLOCK_INCLUDES) \
  372. src/tcmalloc_guard.h \
  373. src/base/commandlineflags.h \
  374. src/base/basictypes.h \
  375. src/pagemap.h \
  376. src/sampler.h \
  377. src/central_freelist.h \
  378. src/linked_list.h \
  379. src/libc_override.h \
  380. src/libc_override_gcc_and_weak.h \
  381. src/libc_override_glibc.h \
  382. src/libc_override_osx.h \
  383. src/libc_override_redefine.h \
  384. src/page_heap.h \
  385. src/page_heap_allocator.h \
  386. src/span.h \
  387. src/static_vars.h \
  388. src/symbolize.h \
  389. src/thread_cache.h \
  390. src/stack_trace_table.h \
  391. src/base/thread_annotations.h \
  392. src/malloc_hook-inl.h \
  393. src/malloc_hook_mmap_linux.h \
  394. src/malloc_hook_mmap_freebsd.h
  395. SG_TCMALLOC_MINIMAL_INCLUDES = src/gperftools/malloc_hook.h \
  396. src/gperftools/malloc_hook_c.h \
  397. src/gperftools/malloc_extension.h \
  398. src/gperftools/malloc_extension_c.h
  399. TCMALLOC_MINIMAL_INCLUDES = $(S_TCMALLOC_MINIMAL_INCLUDES) $(SG_TCMALLOC_MINIMAL_INCLUDES) $(SG_STACKTRACE_INCLUDES)
  400. perftoolsinclude_HEADERS += $(SG_TCMALLOC_MINIMAL_INCLUDES)
  401. ### Making the library
  402. # As we describe at the top of this file, we want to turn off exceptions
  403. # for all files in this library -- except tcmalloc.cc which needs them
  404. # to fulfill its API. Automake doesn't allow per-file CXXFLAGS, so we need
  405. # to separate into two libraries.
  406. noinst_LTLIBRARIES += libtcmalloc_minimal_internal.la
  407. libtcmalloc_minimal_internal_la_SOURCES = src/common.cc \
  408. src/internal_logging.cc \
  409. $(SYSTEM_ALLOC_CC) \
  410. src/central_freelist.cc \
  411. src/page_heap.cc \
  412. src/sampler.cc \
  413. src/span.cc \
  414. src/stack_trace_table.cc \
  415. src/static_vars.cc \
  416. src/symbolize.cc \
  417. src/thread_cache.cc \
  418. src/malloc_hook.cc \
  419. src/malloc_extension.cc \
  420. $(TCMALLOC_MINIMAL_INCLUDES)
  421. # We #define NO_TCMALLOC_SAMPLES, since sampling is turned off for _minimal.
  422. libtcmalloc_minimal_internal_la_CXXFLAGS = -DNO_TCMALLOC_SAMPLES \
  423. -DNO_HEAP_CHECK \
  424. -DNDEBUG \
  425. $(AM_CXXFLAGS) $(NO_EXCEPTIONS)
  426. libtcmalloc_minimal_internal_la_LDFLAGS = $(AM_LDFLAGS)
  427. libtcmalloc_minimal_internal_la_LIBADD = $(LIBSPINLOCK) libmaybe_threads.la
  428. lib_LTLIBRARIES += libtcmalloc_minimal.la
  429. WINDOWS_PROJECTS += vsprojects/libtcmalloc_minimal/libtcmalloc_minimal.vcproj
  430. libtcmalloc_minimal_la_SOURCES = $(TCMALLOC_CC) $(TCMALLOC_MINIMAL_INCLUDES)
  431. libtcmalloc_minimal_la_CXXFLAGS = -DNO_TCMALLOC_SAMPLES \
  432. $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS)
  433. # -version-info gets passed to libtool
  434. libtcmalloc_minimal_la_LDFLAGS = -version-info @TCMALLOC_SO_VERSION@ $(AM_LDFLAGS)
  435. libtcmalloc_minimal_la_LIBADD = libtcmalloc_minimal_internal.la
  436. # For windows, we're playing around with trying to do some stacktrace
  437. # support even with libtcmalloc_minimal. For everyone else, though,
  438. # we turn off all stack-trace activity for libtcmalloc_minimal.
  439. # TODO(csilvers): when we're done experimenting, do something principled here
  440. if MINGW
  441. LIBTCMALLOC_MINIMAL = libtcmalloc_minimal.la libstacktrace.la
  442. else !MINGW
  443. LIBTCMALLOC_MINIMAL = libtcmalloc_minimal.la
  444. endif !MINGW
  445. LIBS_TO_WEAKEN += libtcmalloc_minimal.la
  446. ### Unittests
  447. # Commented out for the moment because malloc(very_big_num) is broken in
  448. # standard libc! At least, in some situations, some of the time.
  449. ## TESTS += malloc_unittest
  450. ## MALLOC_UNITEST_INCLUDES = src/gperftools/malloc_extension.h \
  451. ## src/gperftools/malloc_hook.h \
  452. ## src/gperftools/malloc_hook_c.h \
  453. ## src/malloc_hook-inl.h \
  454. ## src/malloc_hook_mmap_linux.h \
  455. ## src/malloc_hook_mmap_freebsd.h \
  456. ## src/base/basictypes.h \
  457. ## src/maybe_threads.h
  458. ## malloc_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  459. ## src/malloc_hook.cc \
  460. ## src/malloc_extension.cc \
  461. ## $(MAYBE_THREADS_CC) \
  462. ## $(MALLOC_UNITTEST_INCLUDES)
  463. ## malloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  464. ## malloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  465. ## malloc_unittest_LDADD = $(PTHREAD_LIBS)
  466. TESTS += tcmalloc_minimal_unittest
  467. WINDOWS_PROJECTS += vsprojects/tcmalloc_minimal_unittest/tcmalloc_minimal_unittest.vcproj
  468. WINDOWS_PROJECTS += vsprojects/tmu-static/tmu-static.vcproj
  469. tcmalloc_minimal_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  470. src/tests/testutil.h src/tests/testutil.cc \
  471. $(TCMALLOC_UNITTEST_INCLUDES)
  472. tcmalloc_minimal_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  473. tcmalloc_minimal_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  474. # We want libtcmalloc last on the link line, but due to a bug in
  475. # libtool involving convenience libs, they need to come last on the
  476. # link line in order to get dependency ordering right. This is ok:
  477. # convenience libraries are .a's, so tcmalloc is still the last .so.
  478. # We also put pthreads after tcmalloc, because some pthread
  479. # implementations define their own malloc, and we need to go on the
  480. # first linkline to make sure our malloc 'wins'.
  481. tcmalloc_minimal_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) \
  482. liblogging.la $(PTHREAD_LIBS)
  483. TESTS += tcmalloc_minimal_large_unittest
  484. WINDOWS_PROJECTS += vsprojects/tcmalloc_minimal_large/tcmalloc_minimal_large_unittest.vcproj
  485. tcmalloc_minimal_large_unittest_SOURCES = src/tests/tcmalloc_large_unittest.cc
  486. tcmalloc_minimal_large_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  487. tcmalloc_minimal_large_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  488. tcmalloc_minimal_large_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  489. TESTS += tcmalloc_minimal_large_heap_fragmentation_unittest
  490. tcmalloc_minimal_large_heap_fragmentation_unittest_SOURCES = src/tests/large_heap_fragmentation_unittest.cc
  491. tcmalloc_minimal_large_heap_fragmentation_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  492. tcmalloc_minimal_large_heap_fragmentation_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  493. tcmalloc_minimal_large_heap_fragmentation_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  494. # This tests it works to LD_PRELOAD libtcmalloc (tests maybe_threads.cc)
  495. # In theory this should work under mingw, but mingw has trouble running
  496. # shell scripts that end in .exe. And it doesn't seem to build shared
  497. # libraries anyway (so can't be LD_PRELOADed) -- in fact, anybody who
  498. # chooses not to build shared libraries won't be able to run this test.
  499. # TODO(csilvers): figure out how to nix ".exe" or otherwise work under mingw
  500. if !MINGW
  501. if !ENABLE_STATIC
  502. TESTS += maybe_threads_unittest.sh$(EXEEXT)
  503. maybe_threads_unittest_sh_SOURCES = src/tests/maybe_threads_unittest.sh
  504. noinst_SCRIPTS += $(maybe_threads_unittest_sh_SOURCES)
  505. # This script preloads libtcmalloc, and calls two other binaries as well
  506. # TODO(csilvers): replace by 'if ! cmp $^ $@ >/dev/null 2>&; then ...; fi'
  507. maybe_threads_unittest.sh$(EXEEXT): $(top_srcdir)/$(maybe_threads_unittest_sh_SOURCES) \
  508. $(LIBTCMALLOC_MINIMAL) \
  509. low_level_alloc_unittest
  510. rm -f $@
  511. cp -p $(top_srcdir)/$(maybe_threads_unittest_sh_SOURCES) $@
  512. endif !ENABLE_STATIC
  513. endif !MINGW
  514. # These all tests components of tcmalloc_minimal
  515. TESTS += addressmap_unittest
  516. WINDOWS_PROJECTS += vsprojects/addressmap_unittest/addressmap_unittest.vcproj
  517. ADDRESSMAP_UNITTEST_INCLUDES = src/addressmap-inl.h \
  518. src/base/commandlineflags.h \
  519. $(LOGGING_INCLUDES)
  520. addressmap_unittest_SOURCES = src/tests/addressmap_unittest.cc \
  521. $(ADDRESSMAP_UNITTEST_INCLUDES)
  522. if MINGW
  523. addressmap_unittest_SOURCES += src/windows/port.h src/windows/port.cc
  524. endif MINGW
  525. addressmap_unittest_CXXFLAGS = -g $(AM_CXXFLAGS)
  526. addressmap_unittest_LDADD = liblogging.la
  527. WINDOWS_PROJECTS += vsprojects/system-alloc_unittest/system-alloc_unittest.vcproj
  528. if !MINGW
  529. TESTS += system_alloc_unittest
  530. system_alloc_unittest_SOURCES = src/config_for_unittests.h \
  531. src/tests/system-alloc_unittest.cc
  532. system_alloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  533. system_alloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  534. system_alloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  535. endif !MINGW
  536. TESTS += packed_cache_test
  537. WINDOWS_PROJECTS += vsprojects/packed-cache_test/packed-cache_test.vcproj
  538. packed_cache_test_SOURCES = src/tests/packed-cache_test.cc
  539. packed_cache_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  540. packed_cache_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  541. packed_cache_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  542. TESTS += frag_unittest
  543. WINDOWS_PROJECTS += vsprojects/frag_unittest/frag_unittest.vcproj
  544. frag_unittest_SOURCES = src/tests/frag_unittest.cc src/config_for_unittests.h
  545. frag_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  546. frag_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  547. frag_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  548. TESTS += markidle_unittest
  549. WINDOWS_PROJECTS += vsprojects/markidle_unittest/markidle_unittest.vcproj
  550. markidle_unittest_SOURCES = src/tests/markidle_unittest.cc \
  551. src/config_for_unittests.h \
  552. src/tests/testutil.h src/tests/testutil.cc
  553. markidle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  554. markidle_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  555. markidle_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  556. TESTS += current_allocated_bytes_test
  557. WINDOWS_PROJECTS += vsprojects/current_allocated_bytes_test/current_allocated_bytes_test.vcproj
  558. current_allocated_bytes_test_SOURCES = src/tests/current_allocated_bytes_test.cc \
  559. src/config_for_unittests.h
  560. current_allocated_bytes_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  561. current_allocated_bytes_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  562. current_allocated_bytes_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  563. TESTS += malloc_hook_test
  564. WINDOWS_PROJECTS += vsprojects/malloc_hook_test/malloc_hook_test.vcproj
  565. malloc_hook_test_SOURCES = src/tests/malloc_hook_test.cc \
  566. src/config_for_unittests.h \
  567. src/base/logging.h \
  568. src/gperftools/malloc_hook.h \
  569. src/tests/testutil.h src/tests/testutil.cc
  570. malloc_hook_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  571. malloc_hook_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  572. malloc_hook_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  573. TESTS += malloc_extension_test
  574. WINDOWS_PROJECTS += vsprojects/malloc_extension_test/malloc_extension_test.vcproj
  575. malloc_extension_test_SOURCES = src/tests/malloc_extension_test.cc \
  576. src/config_for_unittests.h \
  577. src/base/logging.h \
  578. src/gperftools/malloc_extension.h \
  579. src/gperftools/malloc_extension_c.h
  580. malloc_extension_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  581. malloc_extension_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  582. malloc_extension_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  583. # This doesn't work with mingw, which links foo.a even though it
  584. # doesn't set ENABLE_STATIC. TODO(csilvers): set enable_static=true
  585. # in configure.ac:36?
  586. if !MINGW
  587. TESTS += malloc_extension_c_test
  588. malloc_extension_c_test_SOURCES = src/tests/malloc_extension_c_test.c \
  589. src/gperftools/malloc_extension.h \
  590. src/gperftools/malloc_extension_c.h
  591. malloc_extension_c_test_CFLAGS = $(PTHREAD_CFLAGS) $(AM_CFLAGS)
  592. # -ansi here is just to help ensure the code is bog-standard C.
  593. if GCC
  594. malloc_extension_c_test_CFLAGS += -ansi
  595. endif GCC
  596. malloc_extension_c_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  597. malloc_extension_c_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS) -lstdc++ -lm
  598. endif !MINGW
  599. if !MINGW
  600. if !OSX
  601. TESTS += memalign_unittest
  602. memalign_unittest_SOURCES = src/tests/memalign_unittest.cc \
  603. src/tcmalloc.h \
  604. src/config_for_unittests.h \
  605. src/tests/testutil.h src/tests/testutil.cc
  606. memalign_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  607. memalign_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  608. memalign_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  609. endif !OSX
  610. endif !MINGW
  611. TESTS += page_heap_test
  612. WINDOWS_PROJECTS += vsprojects/page_heap_test/page_heap_test.vcproj
  613. page_heap_test_SOURCES = src/tests/page_heap_test.cc \
  614. src/config_for_unittests.h \
  615. src/base/logging.h \
  616. src/common.h \
  617. src/page_heap.h
  618. page_heap_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  619. page_heap_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  620. page_heap_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  621. TESTS += pagemap_unittest
  622. WINDOWS_PROJECTS += vsprojects/pagemap_unittest/pagemap_unittest.vcproj
  623. pagemap_unittest_SOURCES = src/tests/pagemap_unittest.cc \
  624. src/config_for_unittests.h \
  625. src/base/logging.h \
  626. src/pagemap.h
  627. pagemap_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  628. pagemap_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  629. pagemap_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  630. TESTS += realloc_unittest
  631. WINDOWS_PROJECTS += vsprojects/realloc_unittest/realloc_unittest.vcproj
  632. realloc_unittest_SOURCES = src/tests/realloc_unittest.cc \
  633. src/config_for_unittests.h \
  634. src/base/logging.h
  635. realloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  636. realloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  637. realloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  638. TESTS += stack_trace_table_test
  639. WINDOWS_PROJECTS += vsprojects/stack_trace_table_test/stack_trace_table_test.vcproj
  640. stack_trace_table_test_SOURCES = src/tests/stack_trace_table_test.cc \
  641. src/config_for_unittests.h
  642. stack_trace_table_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  643. stack_trace_table_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  644. stack_trace_table_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  645. TESTS += thread_dealloc_unittest
  646. WINDOWS_PROJECTS += vsprojects/thread_dealloc_unittest/thread_dealloc_unittest.vcproj
  647. thread_dealloc_unittest_SOURCES = src/tests/thread_dealloc_unittest.cc \
  648. src/config_for_unittests.h \
  649. src/tests/testutil.h src/tests/testutil.cc
  650. thread_dealloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  651. thread_dealloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  652. thread_dealloc_unittest_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
  653. ### Documentation
  654. dist_doc_DATA += doc/tcmalloc.html \
  655. doc/overview.gif \
  656. doc/pageheap.gif \
  657. doc/spanmap.gif \
  658. doc/threadheap.gif \
  659. doc/t-test1.times.txt \
  660. doc/tcmalloc-opspercpusec.vs.threads.1024.bytes.png \
  661. doc/tcmalloc-opspercpusec.vs.threads.128.bytes.png \
  662. doc/tcmalloc-opspercpusec.vs.threads.131072.bytes.png \
  663. doc/tcmalloc-opspercpusec.vs.threads.16384.bytes.png \
  664. doc/tcmalloc-opspercpusec.vs.threads.2048.bytes.png \
  665. doc/tcmalloc-opspercpusec.vs.threads.256.bytes.png \
  666. doc/tcmalloc-opspercpusec.vs.threads.32768.bytes.png \
  667. doc/tcmalloc-opspercpusec.vs.threads.4096.bytes.png \
  668. doc/tcmalloc-opspercpusec.vs.threads.512.bytes.png \
  669. doc/tcmalloc-opspercpusec.vs.threads.64.bytes.png \
  670. doc/tcmalloc-opspercpusec.vs.threads.65536.bytes.png \
  671. doc/tcmalloc-opspercpusec.vs.threads.8192.bytes.png \
  672. doc/tcmalloc-opspersec.vs.size.1.threads.png \
  673. doc/tcmalloc-opspersec.vs.size.12.threads.png \
  674. doc/tcmalloc-opspersec.vs.size.16.threads.png \
  675. doc/tcmalloc-opspersec.vs.size.2.threads.png \
  676. doc/tcmalloc-opspersec.vs.size.20.threads.png \
  677. doc/tcmalloc-opspersec.vs.size.3.threads.png \
  678. doc/tcmalloc-opspersec.vs.size.4.threads.png \
  679. doc/tcmalloc-opspersec.vs.size.5.threads.png \
  680. doc/tcmalloc-opspersec.vs.size.8.threads.png
  681. # I don't know how to say "distribute the .dot files but don't install them";
  682. # noinst doesn't seem to work with data. I separate them out anyway, in case
  683. # one day we figure it out. Regardless, installing the dot files isn't the
  684. # end of the world.
  685. dist_doc_DATA += doc/overview.dot \
  686. doc/pageheap.dot \
  687. doc/spanmap.dot \
  688. doc/threadheap.dot
  689. ### ------- tcmalloc_minimal_debug (thread-caching malloc with debugallocation)
  690. # Like tcmalloc.cc, debugallocation.cc needs exceptions to fulfill its
  691. # API. Luckily, we can reuse everything else from tcmalloc_minimal.
  692. if WITH_DEBUGALLOC
  693. lib_LTLIBRARIES += libtcmalloc_minimal_debug.la
  694. libtcmalloc_minimal_debug_la_SOURCES = src/debugallocation.cc \
  695. $(TCMALLOC_MINIMAL_INCLUDES)
  696. libtcmalloc_minimal_debug_la_CXXFLAGS = $(libtcmalloc_minimal_la_CXXFLAGS) \
  697. -DTCMALLOC_FOR_DEBUGALLOCATION
  698. # version_info gets passed to libtool
  699. libtcmalloc_minimal_debug_la_LDFLAGS = $(libtcmalloc_minimal_la_LDFLAGS) \
  700. -version-info @TCMALLOC_SO_VERSION@
  701. libtcmalloc_minimal_debug_la_LIBADD = $(libtcmalloc_minimal_la_LIBADD)
  702. LIBS_TO_WEAKEN += libtcmalloc_minimal_debug.la
  703. ### Unittests
  704. TESTS += tcmalloc_minimal_debug_unittest
  705. tcmalloc_minimal_debug_unittest_SOURCES = $(tcmalloc_minimal_unittest_SOURCES)
  706. tcmalloc_minimal_debug_unittest_CXXFLAGS = $(tcmalloc_minimal_unittest_CXXFLAGS) \
  707. -DDEBUGALLOCATION
  708. tcmalloc_minimal_debug_unittest_LDFLAGS = $(tcmalloc_minimal_unittest_LDFLAGS)
  709. tcmalloc_minimal_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  710. TESTS += malloc_extension_debug_test
  711. malloc_extension_debug_test_SOURCES = $(malloc_extension_test_SOURCES)
  712. malloc_extension_debug_test_CXXFLAGS = $(malloc_extension_test_CXXFLAGS)
  713. malloc_extension_debug_test_LDFLAGS = $(malloc_extension_test_LDFLAGS)
  714. malloc_extension_debug_test_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  715. if !MINGW
  716. if !OSX
  717. TESTS += memalign_debug_unittest
  718. memalign_debug_unittest_SOURCES = $(memalign_unittest_SOURCES)
  719. memalign_debug_unittest_CXXFLAGS = $(memalign_unittest_CXXFLAGS)
  720. memalign_debug_unittest_LDFLAGS = $(memalign_unittest_LDFLAGS)
  721. memalign_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  722. endif !OSX
  723. endif !MINGW
  724. TESTS += realloc_debug_unittest
  725. realloc_debug_unittest_SOURCES = $(realloc_unittest_SOURCES)
  726. realloc_debug_unittest_CXXFLAGS = $(realloc_unittest_CXXFLAGS)
  727. realloc_debug_unittest_LDFLAGS = $(realloc_unittest_LDFLAGS)
  728. realloc_debug_unittest_LDADD = libtcmalloc_minimal_debug.la $(PTHREAD_LIBS)
  729. # debugallocation_test checks that we print a proper stacktrace when
  730. # debug-allocs fail, so we can't run it if we don't have stacktrace info.
  731. if WITH_STACK_TRACE
  732. TESTS += debugallocation_test.sh$(EXEEXT)
  733. debugallocation_test_sh_SOURCES = src/tests/debugallocation_test.sh
  734. noinst_SCRIPTS += $(debugallocation_test_sh_SOURCES)
  735. debugallocation_test.sh$(EXEEXT): $(top_srcdir)/$(debugallocation_test_sh_SOURCES) \
  736. debugallocation_test
  737. rm -f $@
  738. cp -p $(top_srcdir)/$(debugallocation_test_sh_SOURCES) $@
  739. # This is the sub-program used by debugallocation_test.sh
  740. noinst_PROGRAMS += debugallocation_test
  741. debugallocation_test_SOURCES = src/tests/debugallocation_test.cc
  742. debugallocation_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  743. debugallocation_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  744. debugallocation_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  745. endif WITH_STACK_TRACE
  746. endif WITH_DEBUGALLOC
  747. if !MINGW
  748. noinst_LTLIBRARIES += librun_benchmark.la
  749. librun_benchmark_la_SOURCES = \
  750. benchmark/run_benchmark.c benchmark/run_benchmark.h
  751. noinst_PROGRAMS += malloc_bench malloc_bench_shared \
  752. malloc_bench_shared_full \
  753. binary_trees binary_trees_shared
  754. malloc_bench_SOURCES = benchmark/malloc_bench.cc
  755. malloc_bench_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  756. malloc_bench_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS) -static
  757. malloc_bench_LDADD = librun_benchmark.la libtcmalloc_minimal.la $(PTHREAD_LIBS)
  758. malloc_bench_shared_SOURCES = benchmark/malloc_bench.cc
  759. malloc_bench_shared_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  760. malloc_bench_shared_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  761. malloc_bench_shared_LDADD = librun_benchmark.la libtcmalloc_minimal.la $(PTHREAD_LIBS)
  762. malloc_bench_shared_full_SOURCES = benchmark/malloc_bench.cc
  763. malloc_bench_shared_full_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  764. malloc_bench_shared_full_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  765. malloc_bench_shared_full_LDADD = librun_benchmark.la libtcmalloc.la $(PTHREAD_LIBS)
  766. binary_trees_SOURCES = benchmark/binary_trees.cc
  767. binary_trees_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  768. binary_trees_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS) -static
  769. binary_trees_LDADD = libtcmalloc_minimal.la $(PTHREAD_LIBS)
  770. binary_trees_shared_SOURCES = benchmark/binary_trees.cc
  771. binary_trees_shared_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  772. binary_trees_shared_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  773. binary_trees_shared_LDADD = libtcmalloc_minimal.la $(PTHREAD_LIBS)
  774. endif !MINGW
  775. ### ------- tcmalloc (thread-caching malloc + heap profiler + heap checker)
  776. if WITH_HEAP_PROFILER_OR_CHECKER
  777. ### The header files we use. We divide into categories based on directory
  778. S_TCMALLOC_INCLUDES = $(S_TCMALLOC_MINIMAL_INCLUDES) \
  779. $(LOGGING_INCLUDES) \
  780. src/addressmap-inl.h \
  781. src/raw_printer.h \
  782. src/base/elfcore.h \
  783. src/base/googleinit.h \
  784. src/base/linux_syscall_support.h \
  785. src/base/linuxthreads.h \
  786. src/base/stl_allocator.h \
  787. src/base/sysinfo.h \
  788. src/base/thread_lister.h \
  789. src/heap-profile-table.h \
  790. src/heap-profile-stats.h \
  791. src/maybe_emergency_malloc.h \
  792. src/emergency_malloc.h
  793. SG_TCMALLOC_INCLUDES = src/gperftools/heap-profiler.h \
  794. src/gperftools/heap-checker.h
  795. TCMALLOC_INCLUDES = $(S_TCMALLOC_INCLUDES) $(SG_TCMALLOC_MINIMAL_INCLUDES) \
  796. $(SG_TCMALLOC_INCLUDES) $(SG_STACKTRACE_INCLUDES)
  797. perftoolsinclude_HEADERS += $(SG_TCMALLOC_INCLUDES)
  798. if BUILD_EMERGENCY_MALLOC
  799. EMERGENCY_MALLOC_CC = src/emergency_malloc.cc src/emergency_malloc_for_stacktrace.cc
  800. EMERGENCY_MALLOC_DEFINE = -DENABLE_EMERGENCY_MALLOC
  801. else !BUILD_EMERGENCY_MALLOC
  802. EMERGENCY_MALLOC_CC = src/fake_stacktrace_scope.cc
  803. EMERGENCY_MALLOC_DEFINE =
  804. endif !BUILD_EMERGENCY_MALLOC
  805. ### Making the library
  806. # As we describe at the top of this file, we want to turn off exceptions
  807. # for all files in this library -- except tcmalloc.cc which needs them
  808. # to fulfill its API. Automake doesn't allow per-file CXXFLAGS, so we need
  809. # to separate into two libraries.
  810. noinst_LTLIBRARIES += libtcmalloc_internal.la
  811. libtcmalloc_internal_la_SOURCES = $(libtcmalloc_minimal_internal_la_SOURCES) \
  812. $(TCMALLOC_INCLUDES) \
  813. src/base/low_level_alloc.cc \
  814. src/heap-profile-table.cc \
  815. src/heap-profiler.cc \
  816. src/raw_printer.cc \
  817. $(EMERGENCY_MALLOC_CC) \
  818. src/memory_region_map.cc
  819. libtcmalloc_internal_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG \
  820. $(AM_CXXFLAGS) $(NO_EXCEPTIONS) $(EMERGENCY_MALLOC_DEFINE)
  821. libtcmalloc_internal_la_LDFLAGS = $(PTHREAD_CFLAGS)
  822. libtcmalloc_internal_la_LIBADD = libstacktrace.la $(PTHREAD_LIBS)
  823. lib_LTLIBRARIES += libtcmalloc.la
  824. libtcmalloc_la_SOURCES = $(TCMALLOC_CC) $(TCMALLOC_INCLUDES)
  825. libtcmalloc_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS) $(EMERGENCY_MALLOC_DEFINE)
  826. libtcmalloc_la_LDFLAGS = $(PTHREAD_CFLAGS) -version-info @TCMALLOC_SO_VERSION@
  827. libtcmalloc_la_LIBADD = libtcmalloc_internal.la libmaybe_threads.la $(PTHREAD_LIBS)
  828. if WITH_HEAP_CHECKER
  829. # heap-checker-bcad is last, in hopes its global ctor will run first.
  830. # (Note this is added to libtcmalloc.la, not libtcmalloc_internal.la,
  831. # but that's ok; the internal/external distinction is only useful for
  832. # cygwin, and cygwin doesn't use HEAP_CHECKER anyway.)
  833. HEAP_CHECKER_SOURCES = src/base/thread_lister.c \
  834. src/base/linuxthreads.cc \
  835. src/heap-checker.cc \
  836. src/heap-checker-bcad.cc
  837. libtcmalloc_la_SOURCES += $(HEAP_CHECKER_SOURCES)
  838. else !WITH_HEAP_CHECKER
  839. HEAP_CHECKER_SOURCES =
  840. libtcmalloc_internal_la_CXXFLAGS += -DNO_HEAP_CHECK
  841. libtcmalloc_la_CXXFLAGS += -DNO_HEAP_CHECK
  842. endif !WITH_HEAP_CHECKER
  843. LIBTCMALLOC = libtcmalloc.la
  844. LIBS_TO_WEAKEN += libtcmalloc.la
  845. ### Unittests
  846. TESTS += tcmalloc_unittest.sh$(EXEEXT)
  847. tcmalloc_unittest_sh_SOURCES = src/tests/tcmalloc_unittest.sh
  848. noinst_SCRIPTS += $(tcmalloc_unittest_sh_SOURCES)
  849. tcmalloc_unittest.sh$(EXEEXT): $(top_srcdir)/$(tcmalloc_unittest_sh_SOURCES) \
  850. tcmalloc_unittest
  851. rm -f $@
  852. cp -p $(top_srcdir)/$(tcmalloc_unittest_sh_SOURCES) $@
  853. noinst_PROGRAMS += tcmalloc_unittest
  854. tcmalloc_unittest_INCLUDES = src/config_for_unittests.h \
  855. src/gperftools/malloc_extension.h
  856. tcmalloc_unittest_SOURCES = src/tests/tcmalloc_unittest.cc \
  857. src/tcmalloc.h \
  858. src/tests/testutil.h src/tests/testutil.cc \
  859. $(TCMALLOC_UNITTEST_INCLUDES)
  860. tcmalloc_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  861. tcmalloc_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  862. # We want libtcmalloc last on the link line, but due to a bug in
  863. # libtool involving convenience libs, they need to come last on the
  864. # link line in order to get dependency ordering right. This is ok:
  865. # convenience libraries are .a's, so tcmalloc is still the last .so.
  866. # We also put pthreads after tcmalloc, because some pthread
  867. # implementations define their own malloc, and we need to go on the
  868. # first linkline to make sure our malloc 'wins'.
  869. tcmalloc_unittest_LDADD = $(LIBTCMALLOC) liblogging.la $(PTHREAD_LIBS)
  870. # This makes sure it's safe to link in both tcmalloc and
  871. # tcmalloc_minimal. (One would never do this on purpose, but perhaps
  872. # by accident...) When we can compile libprofiler, we also link it in
  873. # to make sure that works too. NOTE: On OS X, it's *not* safe to
  874. # link both in (we end up with two copies of every global var, and
  875. # the code tends to pick one arbitrarily), so don't run the test there.
  876. # (We define these outside the 'if' because they're reused below.)
  877. tcmalloc_both_unittest_srcs = src/tests/tcmalloc_unittest.cc \
  878. src/tests/testutil.h src/tests/testutil.cc \
  879. $(TCMALLOC_UNITTEST_INCLUDES)
  880. tcmalloc_both_unittest_cflags = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  881. tcmalloc_both_unittest_lflags = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  882. if WITH_CPU_PROFILER
  883. # We want libtcmalloc last on the link line, but due to a bug in
  884. # libtool involving convenience libs, they need to come last on the
  885. # link line in order to get dependency ordering right. This is ok:
  886. # convenience libraries are .a's, so tcmalloc is still the last .so.
  887. # We also put pthreads after tcmalloc, because some pthread
  888. # implementations define their own malloc, and we need to go on the
  889. # first linkline to make sure our malloc 'wins'.
  890. tcmalloc_both_unittest_ladd = $(LIBTCMALLOC) $(LIBTCMALLOC_MINIMAL) \
  891. libprofiler.la liblogging.la $(PTHREAD_LIBS)
  892. else
  893. tcmalloc_both_unittest_ladd = $(LIBTCMALLOC) $(LIBTCMALLOC_MINIMAL) \
  894. liblogging.la $(PTHREAD_LIBS)
  895. endif !WITH_CPU_PROFILER
  896. if !OSX
  897. TESTS += tcmalloc_both_unittest
  898. tcmalloc_both_unittest_SOURCES = $(tcmalloc_both_unittest_srcs)
  899. tcmalloc_both_unittest_CXXFLAGS = $(tcmalloc_both_unittest_cflags)
  900. tcmalloc_both_unittest_LDFLAGS = $(tcmalloc_both_unittest_lflags)
  901. tcmalloc_both_unittest_LDADD = $(tcmalloc_both_unittest_ladd)
  902. endif !OSX
  903. TESTS += tcmalloc_large_unittest
  904. tcmalloc_large_unittest_SOURCES = src/tests/tcmalloc_large_unittest.cc
  905. tcmalloc_large_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  906. tcmalloc_large_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  907. tcmalloc_large_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  908. TESTS += tcmalloc_large_heap_fragmentation_unittest
  909. tcmalloc_large_heap_fragmentation_unittest_SOURCES = src/tests/large_heap_fragmentation_unittest.cc
  910. tcmalloc_large_heap_fragmentation_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  911. tcmalloc_large_heap_fragmentation_unittest_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  912. tcmalloc_large_heap_fragmentation_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  913. TESTS += raw_printer_test
  914. raw_printer_test_SOURCES = src/tests/raw_printer_test.cc
  915. raw_printer_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  916. raw_printer_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  917. raw_printer_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  918. # sampler_test and sampling_test both require sampling to be turned
  919. # on, which it's not by default. Use the "standard" value of 2^19.
  920. TESTS_ENVIRONMENT += TCMALLOC_SAMPLE_PARAMETER=524288
  921. TESTS += sampler_test
  922. WINDOWS_PROJECTS += vsprojects/sampler_test/sampler_test.vcproj
  923. sampler_test_SOURCES = src/tests/sampler_test.cc \
  924. src/config_for_unittests.h
  925. sampler_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  926. sampler_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  927. sampler_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS) -lm
  928. # These unittests often need to run binaries. They're in the current dir
  929. TESTS_ENVIRONMENT += BINDIR=.
  930. TESTS_ENVIRONMENT += TMPDIR=/tmp/perftools
  931. TESTS += sampling_test.sh$(EXEEXT)
  932. sampling_test_sh_SOURCES = src/tests/sampling_test.sh
  933. noinst_SCRIPTS += $(sampling_test_sh_SOURCES)
  934. sampling_test.sh$(EXEEXT): $(top_srcdir)/$(sampling_test_sh_SOURCES) \
  935. sampling_test
  936. rm -f $@
  937. cp -p $(top_srcdir)/$(sampling_test_sh_SOURCES) $@
  938. # This is the sub-program used by sampling_test.sh
  939. # The -g is so pprof can get symbol information.
  940. noinst_PROGRAMS += sampling_test
  941. SAMPLING_TEST_INCLUDES = src/config_for_unittests.h \
  942. src/base/logging.h \
  943. src/gperftools/malloc_extension.h
  944. sampling_test_SOURCES = src/tests/sampling_test.cc \
  945. $(SAMPLING_TEST_INCLUDES)
  946. sampling_test_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  947. sampling_test_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  948. sampling_test_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  949. endif WITH_HEAP_PROFILER_OR_CHECKER
  950. if WITH_HEAP_PROFILER
  951. TESTS += heap-profiler_unittest.sh$(EXEEXT)
  952. heap_profiler_unittest_sh_SOURCES = src/tests/heap-profiler_unittest.sh
  953. noinst_SCRIPTS += $(heap_profiler_unittest_sh_SOURCES)
  954. heap-profiler_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) \
  955. heap-profiler_unittest
  956. rm -f $@
  957. cp -p $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) $@
  958. # These are sub-programs used by heap-profiler_unittest.sh
  959. noinst_PROGRAMS += heap-profiler_unittest
  960. HEAP_PROFILER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  961. src/gperftools/heap-profiler.h
  962. heap_profiler_unittest_SOURCES = src/tests/heap-profiler_unittest.cc \
  963. $(HEAP_PROFILER_UNITTEST_INCLUDES)
  964. heap_profiler_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  965. heap_profiler_unittest_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  966. heap_profiler_unittest_LDADD = $(LIBTCMALLOC) $(PTHREAD_LIBS)
  967. # Tests the compatibility include-headers in google/. Requires a function
  968. # defined in the heap-profiler, which is why the test lives here.
  969. TESTS += simple_compat_test
  970. simple_compat_test_SOURCES = src/tests/simple_compat_test.cc \
  971. $(googleinclude_HEADERS)
  972. simple_compat_test_LDFLAGS = $(TCMALLOC_FLAGS)
  973. simple_compat_test_LDADD = $(LIBTCMALLOC)
  974. endif WITH_HEAP_PROFILER
  975. if WITH_HEAP_CHECKER
  976. TESTS += heap-checker_unittest.sh$(EXEEXT)
  977. heap_checker_unittest_sh_SOURCES = src/tests/heap-checker_unittest.sh
  978. noinst_SCRIPTS += $(heap_checker_unittest_sh_SOURCES)
  979. heap-checker_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) \
  980. heap-checker_unittest
  981. rm -f $@
  982. cp -p $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) $@
  983. TESTS += heap-checker-death_unittest.sh$(EXEEXT)
  984. heap_checker_death_unittest_sh_SOURCES = src/tests/heap-checker-death_unittest.sh
  985. noinst_SCRIPTS += $(top_srcdir)/$(heap_checker_death_unittest_sh_SOURCES)
  986. heap-checker-death_unittest.sh$(EXEEXT): $(heap_checker_death_unittest_sh_SOURCES) \
  987. heap-checker_unittest
  988. rm -f $@
  989. cp -p $(top_srcdir)/$(heap_checker_death_unittest_sh_SOURCES) $@
  990. # These are sub-programs used by heap-checker_unittest.sh
  991. noinst_PROGRAMS += heap-checker_unittest
  992. HEAP_CHECKER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  993. src/memory_region_map.h \
  994. src/base/commandlineflags.h \
  995. src/base/googleinit.h \
  996. src/gperftools/heap-checker.h \
  997. $(LOGGING_INCLUDES)
  998. heap_checker_unittest_SOURCES = src/tests/heap-checker_unittest.cc \
  999. $(HEAP_CHECKER_UNITTEST_INCLUDES)
  1000. heap_checker_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS) $(NO_BUILTIN_CXXFLAGS)
  1001. heap_checker_unittest_LDFLAGS = -g $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
  1002. # We want libtcmalloc last on the link line, but due to a bug in
  1003. # libtool involving convenience libs, they need to come last on the
  1004. # link line in order to get dependency ordering right. This is ok:
  1005. # convenience libraries are .a's, so tcmalloc is still the last .so.
  1006. # We also put pthreads after tcmalloc, because some pthread
  1007. # implementations define their own malloc, and we need to go on the
  1008. # first linkline to make sure our malloc 'wins'.
  1009. heap_checker_unittest_LDADD = $(LIBTCMALLOC) liblogging.la $(PTHREAD_LIBS)
  1010. endif WITH_HEAP_CHECKER
  1011. ### Documentation (above and beyond tcmalloc_minimal documentation)
  1012. if WITH_HEAP_PROFILER
  1013. dist_doc_DATA += doc/heapprofile.html doc/heap-example1.png
  1014. endif WITH_HEAP_PROFILER
  1015. if WITH_HEAP_CHECKER
  1016. dist_doc_DATA += doc/heap_checker.html
  1017. endif WITH_HEAP_CHECKER
  1018. ### ------- tcmalloc with debugallocation
  1019. if WITH_DEBUGALLOC
  1020. if WITH_HEAP_PROFILER_OR_CHECKER
  1021. lib_LTLIBRARIES += libtcmalloc_debug.la
  1022. libtcmalloc_debug_la_SOURCES = src/debugallocation.cc $(HEAP_CHECKER_SOURCES) \
  1023. $(TCMALLOC_INCLUDES)
  1024. libtcmalloc_debug_la_CXXFLAGS = $(libtcmalloc_la_CXXFLAGS) \
  1025. -DTCMALLOC_FOR_DEBUGALLOCATION
  1026. libtcmalloc_debug_la_LDFLAGS = $(libtcmalloc_la_LDFLAGS) \
  1027. -version-info @TCMALLOC_SO_VERSION@
  1028. libtcmalloc_debug_la_LIBADD = $(libtcmalloc_la_LIBADD)
  1029. LIBS_TO_WEAKEN += libtcmalloc_debug.la
  1030. ### Unittests
  1031. TESTS += tcmalloc_debug_unittest
  1032. tcmalloc_debug_unittest_SOURCES = $(tcmalloc_unittest_SOURCES)
  1033. tcmalloc_debug_unittest_CXXFLAGS = $(tcmalloc_unittest_CXXFLAGS) \
  1034. -DDEBUGALLOCATION
  1035. tcmalloc_debug_unittest_LDFLAGS = $(tcmalloc_unittest_LDFLAGS)
  1036. tcmalloc_debug_unittest_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1037. TESTS += sampler_debug_test
  1038. sampler_debug_test_SOURCES = $(sampler_test_SOURCES)
  1039. sampler_debug_test_CXXFLAGS = $(samples_test_CXXFLAGS)
  1040. sampler_debug_test_LDFLAGS = $(sampler_test_LDFLAGS)
  1041. sampler_debug_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS) -lm
  1042. TESTS += sampling_debug_test.sh$(EXEEXT)
  1043. sampling_debug_test_sh_SOURCES = src/tests/sampling_test.sh
  1044. sampling_debug_test.sh$(EXEEXT): $(top_srcdir)/$(sampling_test_sh_SOURCES) \
  1045. sampling_debug_test
  1046. rm -f $@
  1047. cp -p $(top_srcdir)/$(sampling_test_sh_SOURCES) $@
  1048. # This is the sub-program using by sampling_debug_test.sh
  1049. # The -g is so pprof can get symbol information.
  1050. noinst_PROGRAMS += sampling_debug_test
  1051. sampling_debug_test_SOURCES = $(sampling_test_SOURCES)
  1052. sampling_debug_test_CXXFLAGS = $(sampling_test_CXXFLAGS)
  1053. sampling_debug_test_LDFLAGS = $(sampling_test_LDFLAGS)
  1054. sampling_debug_test_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1055. endif WITH_HEAP_PROFILER_OR_CHECKER
  1056. if WITH_HEAP_PROFILER
  1057. TESTS += heap-profiler_debug_unittest.sh$(EXEEXT)
  1058. heap_profiler_debug_unittest_sh_SOURCES = src/tests/heap-profiler_unittest.sh
  1059. heap-profiler_debug_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) \
  1060. heap-profiler_debug_unittest
  1061. rm -f $@
  1062. cp -p $(top_srcdir)/$(heap_profiler_unittest_sh_SOURCES) $@
  1063. # These are sub-programs used by heap-profiler_debug_unittest.sh
  1064. noinst_PROGRAMS += heap-profiler_debug_unittest
  1065. heap_profiler_debug_unittest_SOURCES = $(heap_profiler_unittest_SOURCES)
  1066. heap_profiler_debug_unittest_CXXFLAGS = $(heap_profiler_unittest_CXXFLAGS)
  1067. heap_profiler_debug_unittest_LDFLAGS = $(heap_profiler_unittest_LDFLAGS)
  1068. heap_profiler_debug_unittest_LDADD = libtcmalloc_debug.la $(PTHREAD_LIBS)
  1069. endif WITH_HEAP_PROFILER
  1070. if WITH_HEAP_CHECKER
  1071. TESTS += heap-checker_debug_unittest.sh$(EXEEXT)
  1072. heap_checker_debug_unittest_sh_SOURCES = src/tests/heap-checker_unittest.sh
  1073. heap-checker_debug_unittest.sh$(EXEEXT): $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) \
  1074. heap-checker_debug_unittest
  1075. rm -f $@
  1076. cp -p $(top_srcdir)/$(heap_checker_unittest_sh_SOURCES) $@
  1077. # These are sub-programs used by heap-checker_debug_unittest.sh
  1078. noinst_PROGRAMS += heap-checker_debug_unittest
  1079. heap_checker_debug_unittest_SOURCES = $(heap_checker_unittest_SOURCES)
  1080. heap_checker_debug_unittest_CXXFLAGS = $(heap_checker_unittest_CXXFLAGS)
  1081. heap_checker_debug_unittest_LDFLAGS = $(heap_checker_unittest_LDFLAGS)
  1082. # We want libtcmalloc last on the link line, but due to a bug in
  1083. # libtool involving convenience libs, they need to come last on the
  1084. # link line in order to get dependency ordering right. This is ok:
  1085. # convenience libraries are .a's, so tcmalloc is still the last .so.
  1086. heap_checker_debug_unittest_LDADD = libtcmalloc_debug.la liblogging.la \
  1087. $(PTHREAD_LIBS)
  1088. endif WITH_HEAP_CHECKER
  1089. endif WITH_DEBUGALLOC
  1090. ### ------- CPU profiler
  1091. if WITH_CPU_PROFILER
  1092. ### The header files we use. We divide into categories based on directory
  1093. S_CPU_PROFILER_INCLUDES = src/profiledata.h \
  1094. src/profile-handler.h \
  1095. src/getpc.h \
  1096. src/base/basictypes.h \
  1097. src/base/commandlineflags.h \
  1098. src/base/googleinit.h \
  1099. src/base/logging.h \
  1100. src/base/simple_mutex.h \
  1101. src/base/sysinfo.h \
  1102. $(SPINLOCK_INCLUDES) \
  1103. $(LOGGING_INCLUDES)
  1104. SG_CPU_PROFILER_INCLUDES = src/gperftools/profiler.h
  1105. CPU_PROFILER_INCLUDES = $(S_CPU_PROFILER_INCLUDES) $(SG_CPU_PROFILER_INCLUDES) \
  1106. $(SG_STACKTRACE_INCLUDES)
  1107. perftoolsinclude_HEADERS += $(SG_CPU_PROFILER_INCLUDES)
  1108. ### Making the library
  1109. lib_LTLIBRARIES += libprofiler.la
  1110. libprofiler_la_SOURCES = src/profiler.cc \
  1111. src/profile-handler.cc \
  1112. src/profiledata.cc \
  1113. $(CPU_PROFILER_INCLUDES)
  1114. libprofiler_la_LIBADD = libstacktrace.la libmaybe_threads.la libfake_stacktrace_scope.la
  1115. # We have to include ProfileData for profiledata_unittest
  1116. CPU_PROFILER_SYMBOLS = '(ProfilerStart|ProfilerStartWithOptions|ProfilerStop|ProfilerFlush|ProfilerEnable|ProfilerDisable|ProfilingIsEnabledForAllThreads|ProfilerRegisterThread|ProfilerGetCurrentState|ProfilerState|ProfileData|ProfileHandler)'
  1117. libprofiler_la_LDFLAGS = -export-symbols-regex $(CPU_PROFILER_SYMBOLS) \
  1118. -version-info @PROFILER_SO_VERSION@
  1119. # See discussion above (under LIBTCMALLOC_MINIMAL) for why we do this.
  1120. # Basically it's to work around systems where --rpath doesn't work right.
  1121. LIBPROFILER = libstacktrace.la libprofiler.la
  1122. ### Unittests
  1123. TESTS += getpc_test
  1124. #WINDOWS_PROJECTS += vsprojects/getpc_test/getpc_test.vcproj
  1125. getpc_test_SOURCES = src/tests/getpc_test.cc src/getpc.h
  1126. TESTS += profiledata_unittest
  1127. #WINDOWS_PROJECTS += vsprojects/profiledata_unittest/profiledata_unittest.vcproj
  1128. profiledata_unittest_SOURCES = src/tests/profiledata_unittest.cc \
  1129. src/profiledata.h \
  1130. src/base/commandlineflags.h \
  1131. src/base/logging.h \
  1132. src/base/basictypes.h
  1133. profiledata_unittest_LDADD = $(LIBPROFILER)
  1134. TESTS += profile_handler_unittest
  1135. profile_handler_unittest_SOURCES = src/tests/profile-handler_unittest.cc \
  1136. src/profile-handler.h
  1137. profile_handler_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
  1138. profile_handler_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1139. profile_handler_unittest_LDADD = $(LIBPROFILER) $(PTHREAD_LIBS)
  1140. TESTS += profiler_unittest.sh$(EXEEXT)
  1141. profiler_unittest_sh_SOURCES = src/tests/profiler_unittest.sh
  1142. noinst_SCRIPTS += $(profiler_unittest_sh_SOURCES)
  1143. profiler_unittest.sh$(EXEEXT): $(top_srcdir)/$(profiler_unittest_sh_SOURCES) \
  1144. profiler1_unittest profiler2_unittest \
  1145. profiler3_unittest profiler4_unittest
  1146. rm -f $@
  1147. cp -p $(top_srcdir)/$(profiler_unittest_sh_SOURCES) $@
  1148. # These are sub-programs used by profiler_unittest.sh
  1149. noinst_PROGRAMS += profiler1_unittest profiler2_unittest profiler3_unittest \
  1150. profiler4_unittest
  1151. PROFILER_UNITTEST_INCLUDES = src/config_for_unittests.h \
  1152. src/gperftools/profiler.h
  1153. PROFILER_UNITTEST_SRCS = src/tests/profiler_unittest.cc \
  1154. src/tests/testutil.h src/tests/testutil.cc \
  1155. $(PROFILER_UNITTEST_INCLUDES)
  1156. profiler1_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1157. profiler1_unittest_CXXFLAGS = -g -DNO_THREADS $(AM_CXXFLAGS)
  1158. profiler1_unittest_LDADD = $(LIBPROFILER)
  1159. profiler2_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1160. profiler2_unittest_CXXFLAGS = -g -DNO_THREADS $(AM_CXXFLAGS)
  1161. profiler2_unittest_LDADD = -lstacktrace -lprofiler
  1162. # We depend on -lprofiler but haven't yet said how to build it. Do so now.
  1163. profiler2_unittest_DEPENDENCIES = $(LIBPROFILER)
  1164. profiler3_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1165. profiler3_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  1166. profiler3_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1167. profiler3_unittest_LDADD = $(LIBPROFILER) $(PTHREAD_LIBS)
  1168. profiler4_unittest_SOURCES = $(PROFILER_UNITTEST_SRCS)
  1169. profiler4_unittest_CXXFLAGS = -g $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
  1170. profiler4_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
  1171. profiler4_unittest_LDADD = -lstacktrace -lprofiler $(PTHREAD_LIBS)
  1172. # We depend on -lprofiler but haven't yet said how to build it. Do so now.
  1173. profiler4_unittest_DEPENDENCIES = $(LIBPROFILER)
  1174. ### Documentation
  1175. dist_doc_DATA += doc/cpuprofile.html \
  1176. doc/cpuprofile-fileformat.html \
  1177. doc/pprof-test-big.gif \
  1178. doc/pprof-test.gif \
  1179. doc/pprof-vsnprintf-big.gif \
  1180. doc/pprof-vsnprintf.gif
  1181. endif WITH_CPU_PROFILER
  1182. ### ------- CPU profiler and heap checker, in one!
  1183. # Ideally, folks who wanted to use both tcmalloc and libprofiler,
  1184. # could just link them both into their application. But while this
  1185. # works fine for .so files, it does not for .a files. The easiest way
  1186. # around this -- and I've tried a bunch of the hard ways -- is to just
  1187. # to create another set of libraries that has both functionality in it.
  1188. if WITH_HEAP_PROFILER_OR_CHECKER
  1189. if WITH_CPU_PROFILER
  1190. lib_LTLIBRARIES += libtcmalloc_and_profiler.la
  1191. libtcmalloc_and_profiler_la_SOURCES = $(libtcmalloc_la_SOURCES) $(libprofiler_la_SOURCES)
  1192. libtcmalloc_and_profiler_la_CXXFLAGS = $(libtcmalloc_la_CXXFLAGS) $(libprofiler_la_CXXFLAGS)
  1193. # Since this library is meant to be used as a .a, I don't worry as much
  1194. # about .so versioning. I just give the libtcmalloc version number.
  1195. # TODO(csilvers): use -export-symbols-regex?
  1196. libtcmalloc_and_profiler_la_LDFLAGS = $(PTHREAD_CFLAGS) \
  1197. -version-info @TCMALLOC_SO_VERSION@
  1198. # We don't include libprofiler_la_LIBADD here because all it adds is
  1199. # libstacktrace.la, which we already get via libtcmalloc. Trying to
  1200. # specify it twice causes link-time duplicate-definition errors. :-(
  1201. libtcmalloc_and_profiler_la_LIBADD = $(libtcmalloc_la_LIBADD)
  1202. TESTS += tcmalloc_and_profiler_unittest
  1203. tcmalloc_and_profiler_unittest_SOURCES = $(tcmalloc_both_unittest_srcs)
  1204. tcmalloc_and_profiler_unittest_CXXFLAGS = $(tcmalloc_both_unittest_cflags)
  1205. tcmalloc_and_profiler_unittest_LDFLAGS = $(tcmalloc_both_unittest_lflags)
  1206. tcmalloc_and_profiler_unittest_LDADD = libtcmalloc_and_profiler.la
  1207. LIBS_TO_WEAKEN += libtcmalloc_and_profiler.la
  1208. endif WITH_CPU_PROFILER
  1209. endif WITH_HEAP_PROFILER_OR_CHECKER
  1210. ## ^^^^ END OF RULES TO MAKE YOUR LIBRARIES, BINARIES, AND UNITTESTS
  1211. # Do the weakening on some exported libtcmalloc symbols.
  1212. install-exec-local: all-local
  1213. all-local: $(LIBS_TO_WEAKEN)
  1214. for la in $(LIBS_TO_WEAKEN); do lib=".libs/`basename $$la .la`.a"; [ ! -f "$$lib" ] || $(WEAKEN) "$$lib"; done
  1215. # This should always include $(TESTS), but may also include other
  1216. # binaries that you compile but don't want automatically installed.
  1217. # We'll add to this later, on a library-by-library basis
  1218. noinst_PROGRAMS += $(TESTS)
  1219. rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
  1220. @cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
  1221. deb: dist-gzip packages/deb.sh packages/deb/*
  1222. @cd packages && ./deb.sh ${PACKAGE} ${VERSION}
  1223. # http://linux.die.net/man/1/pkg-config, http://pkg-config.freedesktop.org/wiki
  1224. pkgconfigdir = $(libdir)/pkgconfig
  1225. pkgconfig_DATA = libtcmalloc.pc libtcmalloc_minimal.pc \
  1226. libtcmalloc_debug.pc libtcmalloc_minimal_debug.pc \
  1227. libprofiler.pc
  1228. CLEANFILES = $(pkgconfig_DATA)
  1229. # I get the description and URL lines from the rpm spec. I use sed to
  1230. # try to rewrite exec_prefix, libdir, and includedir in terms of
  1231. # prefix, if possible.
  1232. libtcmalloc.pc: Makefile packages/rpm/rpm.spec
  1233. echo 'prefix=$(prefix)' > "$@".tmp
  1234. echo 'exec_prefix='`echo '$(exec_prefix)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
  1235. echo 'libdir='`echo '$(libdir)' | sed 's@^$(exec_prefix)@$${exec_prefix}@'` >> "$@".tmp
  1236. echo 'includedir='`echo '$(includedir)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
  1237. echo '' >> "$@".tmp
  1238. echo 'Name: $(PACKAGE)' >> "$@".tmp
  1239. echo 'Version: $(VERSION)' >> "$@".tmp
  1240. -grep '^Summary:' $(top_srcdir)/packages/rpm/rpm.spec | sed s/^Summary:/Description:/ | head -n1 >> "$@".tmp
  1241. -grep '^URL: ' $(top_srcdir)/packages/rpm/rpm.spec >> "$@".tmp
  1242. echo 'Requires:' >> "$@".tmp
  1243. echo 'Libs: -L$${libdir} -ltcmalloc' >> "$@".tmp
  1244. echo 'Libs.private: $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)' >> "$@".tmp
  1245. echo 'Cflags: -I$${includedir}' >> "$@".tmp
  1246. mv -f "$@".tmp "$@"
  1247. # The other versions are mostly the same.
  1248. libtcmalloc_minimal.pc: libtcmalloc.pc
  1249. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_minimal/ > "$@"
  1250. libtcmalloc_debug.pc: libtcmalloc.pc
  1251. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_debug/ > "$@"
  1252. libtcmalloc_minimal_debug.pc: libtcmalloc.pc
  1253. cat libtcmalloc.pc | sed s/-ltcmalloc/-ltcmalloc_minimal_debug/ > "$@"
  1254. libprofiler.pc: libtcmalloc.pc
  1255. cat libtcmalloc.pc | sed s/-ltcmalloc/-lprofiler/ > "$@"
  1256. libtool: $(LIBTOOL_DEPS)
  1257. $(SHELL) ./config.status --recheck
  1258. # Windows wants write permission to .vcproj files and maybe even sln files.
  1259. dist-hook:
  1260. test -e "$(distdir)/vsprojects" \
  1261. && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
  1262. EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
  1263. $(SCRIPTS) libtool \
  1264. src/windows/get_mangled_names.cc src/windows/override_functions.cc \
  1265. src/windows/config.h src/windows/gperftools/tcmalloc.h \
  1266. doc/pprof.see_also src/windows/TODO \
  1267. $(WINDOWS_PROJECTS) \
  1268. src/solaris/libstdc++.la