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