Makefile.am 64 KB

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