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