1# Clear out all vpaths, then set just one (default vpath) for the main build 2# directory. 3vpath 4vpath % . 5 6# Clear the default suffixes, so that built-in rules are not used. 7.SUFFIXES : 8 9SHELL := /bin/sh 10 11CC := @CC@ 12CXX := @CXX@ 13 14# Configuration parameters. 15DESTDIR = 16BINDIR := $(DESTDIR)@BINDIR@ 17INCLUDEDIR := $(DESTDIR)@INCLUDEDIR@ 18LIBDIR := $(DESTDIR)@LIBDIR@ 19DATADIR := $(DESTDIR)@DATADIR@ 20MANDIR := $(DESTDIR)@MANDIR@ 21srcroot := @srcroot@ 22objroot := @objroot@ 23abs_srcroot := @abs_srcroot@ 24abs_objroot := @abs_objroot@ 25 26# Build parameters. 27CPPFLAGS := @CPPFLAGS@ -I$(objroot)include -I$(srcroot)include 28CONFIGURE_CFLAGS := @CONFIGURE_CFLAGS@ 29SPECIFIED_CFLAGS := @SPECIFIED_CFLAGS@ 30EXTRA_CFLAGS := @EXTRA_CFLAGS@ 31CFLAGS := $(strip $(CONFIGURE_CFLAGS) $(SPECIFIED_CFLAGS) $(EXTRA_CFLAGS)) 32CONFIGURE_CXXFLAGS := @CONFIGURE_CXXFLAGS@ 33SPECIFIED_CXXFLAGS := @SPECIFIED_CXXFLAGS@ 34EXTRA_CXXFLAGS := @EXTRA_CXXFLAGS@ 35CXXFLAGS := $(strip $(CONFIGURE_CXXFLAGS) $(SPECIFIED_CXXFLAGS) $(EXTRA_CXXFLAGS)) 36LDFLAGS := @LDFLAGS@ 37EXTRA_LDFLAGS := @EXTRA_LDFLAGS@ 38LIBS := @LIBS@ 39RPATH_EXTRA := @RPATH_EXTRA@ 40SO := @so@ 41IMPORTLIB := @importlib@ 42O := @o@ 43A := @a@ 44EXE := @exe@ 45LIBPREFIX := @libprefix@ 46REV := @rev@ 47install_suffix := @install_suffix@ 48ABI := @abi@ 49XSLTPROC := @XSLTPROC@ 50XSLROOT := @XSLROOT@ 51AUTOCONF := @AUTOCONF@ 52_RPATH = @RPATH@ 53RPATH = $(if $(1),$(call _RPATH,$(1))) 54cfghdrs_in := $(addprefix $(srcroot),@cfghdrs_in@) 55cfghdrs_out := @cfghdrs_out@ 56cfgoutputs_in := $(addprefix $(srcroot),@cfgoutputs_in@) 57cfgoutputs_out := @cfgoutputs_out@ 58enable_autogen := @enable_autogen@ 59enable_doc := @enable_doc@ 60enable_shared := @enable_shared@ 61enable_static := @enable_static@ 62enable_prof := @enable_prof@ 63enable_zone_allocator := @enable_zone_allocator@ 64enable_experimental_smallocx := @enable_experimental_smallocx@ 65MALLOC_CONF := @JEMALLOC_CPREFIX@MALLOC_CONF 66link_whole_archive := @link_whole_archive@ 67DSO_LDFLAGS = @DSO_LDFLAGS@ 68SOREV = @SOREV@ 69PIC_CFLAGS = @PIC_CFLAGS@ 70CTARGET = @CTARGET@ 71LDTARGET = @LDTARGET@ 72TEST_LD_MODE = @TEST_LD_MODE@ 73MKLIB = @MKLIB@ 74AR = @AR@ 75ARFLAGS = @ARFLAGS@ 76DUMP_SYMS = @DUMP_SYMS@ 77AWK := @AWK@ 78CC_MM = @CC_MM@ 79LM := @LM@ 80INSTALL = @INSTALL@ 81 82ifeq (macho, $(ABI)) 83TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH="$(objroot)lib" 84else 85ifeq (pecoff, $(ABI)) 86TEST_LIBRARY_PATH := PATH="$(PATH):$(objroot)lib" 87else 88TEST_LIBRARY_PATH := 89endif 90endif 91 92LIBJEMALLOC := $(LIBPREFIX)jemalloc$(install_suffix) 93 94# Lists of files. 95BINS := $(objroot)bin/jemalloc-config $(objroot)bin/jemalloc.sh $(objroot)bin/jeprof 96C_HDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h 97C_SRCS := $(srcroot)src/jemalloc.c \ 98 $(srcroot)src/arena.c \ 99 $(srcroot)src/background_thread.c \ 100 $(srcroot)src/base.c \ 101 $(srcroot)src/bin.c \ 102 $(srcroot)src/bin_info.c \ 103 $(srcroot)src/bitmap.c \ 104 $(srcroot)src/buf_writer.c \ 105 $(srcroot)src/cache_bin.c \ 106 $(srcroot)src/ckh.c \ 107 $(srcroot)src/counter.c \ 108 $(srcroot)src/ctl.c \ 109 $(srcroot)src/decay.c \ 110 $(srcroot)src/div.c \ 111 $(srcroot)src/ecache.c \ 112 $(srcroot)src/edata.c \ 113 $(srcroot)src/edata_cache.c \ 114 $(srcroot)src/ehooks.c \ 115 $(srcroot)src/emap.c \ 116 $(srcroot)src/eset.c \ 117 $(srcroot)src/exp_grow.c \ 118 $(srcroot)src/extent.c \ 119 $(srcroot)src/extent_dss.c \ 120 $(srcroot)src/extent_mmap.c \ 121 $(srcroot)src/fxp.c \ 122 $(srcroot)src/san.c \ 123 $(srcroot)src/san_bump.c \ 124 $(srcroot)src/hook.c \ 125 $(srcroot)src/hpa.c \ 126 $(srcroot)src/hpa_hooks.c \ 127 $(srcroot)src/hpdata.c \ 128 $(srcroot)src/inspect.c \ 129 $(srcroot)src/large.c \ 130 $(srcroot)src/log.c \ 131 $(srcroot)src/malloc_io.c \ 132 $(srcroot)src/mutex.c \ 133 $(srcroot)src/nstime.c \ 134 $(srcroot)src/pa.c \ 135 $(srcroot)src/pa_extra.c \ 136 $(srcroot)src/pai.c \ 137 $(srcroot)src/pac.c \ 138 $(srcroot)src/pages.c \ 139 $(srcroot)src/peak_event.c \ 140 $(srcroot)src/prof.c \ 141 $(srcroot)src/prof_data.c \ 142 $(srcroot)src/prof_log.c \ 143 $(srcroot)src/prof_recent.c \ 144 $(srcroot)src/prof_stats.c \ 145 $(srcroot)src/prof_sys.c \ 146 $(srcroot)src/psset.c \ 147 $(srcroot)src/rtree.c \ 148 $(srcroot)src/safety_check.c \ 149 $(srcroot)src/sc.c \ 150 $(srcroot)src/sec.c \ 151 $(srcroot)src/stats.c \ 152 $(srcroot)src/sz.c \ 153 $(srcroot)src/tcache.c \ 154 $(srcroot)src/test_hooks.c \ 155 $(srcroot)src/thread_event.c \ 156 $(srcroot)src/ticker.c \ 157 $(srcroot)src/tsd.c \ 158 $(srcroot)src/witness.c 159ifeq ($(enable_zone_allocator), 1) 160C_SRCS += $(srcroot)src/zone.c 161endif 162ifeq ($(IMPORTLIB),$(SO)) 163STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A) 164endif 165ifdef PIC_CFLAGS 166STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) 167else 168STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_s.$(A) 169endif 170DSOS := $(objroot)lib/$(LIBJEMALLOC).$(SOREV) 171ifneq ($(SOREV),$(SO)) 172DSOS += $(objroot)lib/$(LIBJEMALLOC).$(SO) 173endif 174ifeq (1, $(link_whole_archive)) 175LJEMALLOC := -Wl,--whole-archive -L$(objroot)lib -l$(LIBJEMALLOC) -Wl,--no-whole-archive 176else 177LJEMALLOC := $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 178endif 179PC := $(objroot)jemalloc.pc 180DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml 181DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(objroot)%.html) 182DOCS_MAN3 := $(DOCS_XML:$(objroot)%.xml=$(objroot)%.3) 183DOCS := $(DOCS_HTML) $(DOCS_MAN3) 184C_TESTLIB_SRCS := $(srcroot)test/src/btalloc.c $(srcroot)test/src/btalloc_0.c \ 185 $(srcroot)test/src/btalloc_1.c $(srcroot)test/src/math.c \ 186 $(srcroot)test/src/mtx.c $(srcroot)test/src/sleep.c \ 187 $(srcroot)test/src/SFMT.c $(srcroot)test/src/test.c \ 188 $(srcroot)test/src/thd.c $(srcroot)test/src/timer.c 189ifeq (1, $(link_whole_archive)) 190C_UTIL_INTEGRATION_SRCS := 191C_UTIL_CPP_SRCS := 192else 193C_UTIL_INTEGRATION_SRCS := $(srcroot)src/nstime.c $(srcroot)src/malloc_io.c \ 194 $(srcroot)src/ticker.c 195C_UTIL_CPP_SRCS := $(srcroot)src/nstime.c $(srcroot)src/malloc_io.c 196endif 197TESTS_UNIT := \ 198 $(srcroot)test/unit/a0.c \ 199 $(srcroot)test/unit/arena_decay.c \ 200 $(srcroot)test/unit/arena_reset.c \ 201 $(srcroot)test/unit/atomic.c \ 202 $(srcroot)test/unit/background_thread.c \ 203 $(srcroot)test/unit/background_thread_enable.c \ 204 $(srcroot)test/unit/base.c \ 205 $(srcroot)test/unit/batch_alloc.c \ 206 $(srcroot)test/unit/binshard.c \ 207 $(srcroot)test/unit/bitmap.c \ 208 $(srcroot)test/unit/bit_util.c \ 209 $(srcroot)test/unit/buf_writer.c \ 210 $(srcroot)test/unit/cache_bin.c \ 211 $(srcroot)test/unit/ckh.c \ 212 $(srcroot)test/unit/counter.c \ 213 $(srcroot)test/unit/decay.c \ 214 $(srcroot)test/unit/div.c \ 215 $(srcroot)test/unit/double_free.c \ 216 $(srcroot)test/unit/edata_cache.c \ 217 $(srcroot)test/unit/emitter.c \ 218 $(srcroot)test/unit/extent_quantize.c \ 219 ${srcroot}test/unit/fb.c \ 220 $(srcroot)test/unit/fork.c \ 221 ${srcroot}test/unit/fxp.c \ 222 ${srcroot}test/unit/san.c \ 223 ${srcroot}test/unit/san_bump.c \ 224 $(srcroot)test/unit/hash.c \ 225 $(srcroot)test/unit/hook.c \ 226 $(srcroot)test/unit/hpa.c \ 227 $(srcroot)test/unit/hpa_background_thread.c \ 228 $(srcroot)test/unit/hpdata.c \ 229 $(srcroot)test/unit/huge.c \ 230 $(srcroot)test/unit/inspect.c \ 231 $(srcroot)test/unit/junk.c \ 232 $(srcroot)test/unit/junk_alloc.c \ 233 $(srcroot)test/unit/junk_free.c \ 234 $(srcroot)test/unit/log.c \ 235 $(srcroot)test/unit/mallctl.c \ 236 $(srcroot)test/unit/malloc_conf_2.c \ 237 $(srcroot)test/unit/malloc_io.c \ 238 $(srcroot)test/unit/math.c \ 239 $(srcroot)test/unit/mpsc_queue.c \ 240 $(srcroot)test/unit/mq.c \ 241 $(srcroot)test/unit/mtx.c \ 242 $(srcroot)test/unit/nstime.c \ 243 $(srcroot)test/unit/oversize_threshold.c \ 244 $(srcroot)test/unit/pa.c \ 245 $(srcroot)test/unit/pack.c \ 246 $(srcroot)test/unit/pages.c \ 247 $(srcroot)test/unit/peak.c \ 248 $(srcroot)test/unit/ph.c \ 249 $(srcroot)test/unit/prng.c \ 250 $(srcroot)test/unit/prof_accum.c \ 251 $(srcroot)test/unit/prof_active.c \ 252 $(srcroot)test/unit/prof_gdump.c \ 253 $(srcroot)test/unit/prof_hook.c \ 254 $(srcroot)test/unit/prof_idump.c \ 255 $(srcroot)test/unit/prof_log.c \ 256 $(srcroot)test/unit/prof_mdump.c \ 257 $(srcroot)test/unit/prof_recent.c \ 258 $(srcroot)test/unit/prof_reset.c \ 259 $(srcroot)test/unit/prof_stats.c \ 260 $(srcroot)test/unit/prof_tctx.c \ 261 $(srcroot)test/unit/prof_thread_name.c \ 262 $(srcroot)test/unit/prof_sys_thread_name.c \ 263 $(srcroot)test/unit/psset.c \ 264 $(srcroot)test/unit/ql.c \ 265 $(srcroot)test/unit/qr.c \ 266 $(srcroot)test/unit/rb.c \ 267 $(srcroot)test/unit/retained.c \ 268 $(srcroot)test/unit/rtree.c \ 269 $(srcroot)test/unit/safety_check.c \ 270 $(srcroot)test/unit/sc.c \ 271 $(srcroot)test/unit/sec.c \ 272 $(srcroot)test/unit/seq.c \ 273 $(srcroot)test/unit/SFMT.c \ 274 $(srcroot)test/unit/size_check.c \ 275 $(srcroot)test/unit/size_classes.c \ 276 $(srcroot)test/unit/slab.c \ 277 $(srcroot)test/unit/smoothstep.c \ 278 $(srcroot)test/unit/spin.c \ 279 $(srcroot)test/unit/stats.c \ 280 $(srcroot)test/unit/stats_print.c \ 281 $(srcroot)test/unit/sz.c \ 282 $(srcroot)test/unit/tcache_max.c \ 283 $(srcroot)test/unit/test_hooks.c \ 284 $(srcroot)test/unit/thread_event.c \ 285 $(srcroot)test/unit/ticker.c \ 286 $(srcroot)test/unit/tsd.c \ 287 $(srcroot)test/unit/uaf.c \ 288 $(srcroot)test/unit/witness.c \ 289 $(srcroot)test/unit/zero.c \ 290 $(srcroot)test/unit/zero_realloc_abort.c \ 291 $(srcroot)test/unit/zero_realloc_free.c \ 292 $(srcroot)test/unit/zero_realloc_alloc.c \ 293 $(srcroot)test/unit/zero_reallocs.c 294ifeq (@enable_prof@, 1) 295TESTS_UNIT += \ 296 $(srcroot)test/unit/arena_reset_prof.c \ 297 $(srcroot)test/unit/batch_alloc_prof.c 298endif 299TESTS_INTEGRATION := $(srcroot)test/integration/aligned_alloc.c \ 300 $(srcroot)test/integration/allocated.c \ 301 $(srcroot)test/integration/extent.c \ 302 $(srcroot)test/integration/malloc.c \ 303 $(srcroot)test/integration/mallocx.c \ 304 $(srcroot)test/integration/MALLOCX_ARENA.c \ 305 $(srcroot)test/integration/overflow.c \ 306 $(srcroot)test/integration/posix_memalign.c \ 307 $(srcroot)test/integration/rallocx.c \ 308 $(srcroot)test/integration/sdallocx.c \ 309 $(srcroot)test/integration/slab_sizes.c \ 310 $(srcroot)test/integration/thread_arena.c \ 311 $(srcroot)test/integration/thread_tcache_enabled.c \ 312 $(srcroot)test/integration/xallocx.c 313ifeq (@enable_experimental_smallocx@, 1) 314TESTS_INTEGRATION += \ 315 $(srcroot)test/integration/smallocx.c 316endif 317ifeq (@enable_cxx@, 1) 318CPP_SRCS := $(srcroot)src/jemalloc_cpp.cpp 319TESTS_INTEGRATION_CPP := $(srcroot)test/integration/cpp/basic.cpp \ 320 $(srcroot)test/integration/cpp/infallible_new_true.cpp \ 321 $(srcroot)test/integration/cpp/infallible_new_false.cpp 322else 323CPP_SRCS := 324TESTS_INTEGRATION_CPP := 325endif 326TESTS_ANALYZE := $(srcroot)test/analyze/prof_bias.c \ 327 $(srcroot)test/analyze/rand.c \ 328 $(srcroot)test/analyze/sizes.c 329TESTS_STRESS := $(srcroot)test/stress/batch_alloc.c \ 330 $(srcroot)test/stress/fill_flush.c \ 331 $(srcroot)test/stress/hookbench.c \ 332 $(srcroot)test/stress/large_microbench.c \ 333 $(srcroot)test/stress/mallctl.c \ 334 $(srcroot)test/stress/microbench.c 335 336 337TESTS := $(TESTS_UNIT) $(TESTS_INTEGRATION) $(TESTS_INTEGRATION_CPP) \ 338 $(TESTS_ANALYZE) $(TESTS_STRESS) 339 340PRIVATE_NAMESPACE_HDRS := $(objroot)include/jemalloc/internal/private_namespace.h $(objroot)include/jemalloc/internal/private_namespace_jet.h 341PRIVATE_NAMESPACE_GEN_HDRS := $(PRIVATE_NAMESPACE_HDRS:%.h=%.gen.h) 342C_SYM_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.sym.$(O)) 343C_SYMS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.sym) 344C_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.$(O)) 345CPP_OBJS := $(CPP_SRCS:$(srcroot)%.cpp=$(objroot)%.$(O)) 346C_PIC_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.pic.$(O)) 347CPP_PIC_OBJS := $(CPP_SRCS:$(srcroot)%.cpp=$(objroot)%.pic.$(O)) 348C_JET_SYM_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.sym.$(O)) 349C_JET_SYMS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.sym) 350C_JET_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.$(O)) 351C_TESTLIB_UNIT_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.unit.$(O)) 352C_TESTLIB_INTEGRATION_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.integration.$(O)) 353C_UTIL_INTEGRATION_OBJS := $(C_UTIL_INTEGRATION_SRCS:$(srcroot)%.c=$(objroot)%.integration.$(O)) 354C_TESTLIB_ANALYZE_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.analyze.$(O)) 355C_TESTLIB_STRESS_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.stress.$(O)) 356C_TESTLIB_OBJS := $(C_TESTLIB_UNIT_OBJS) $(C_TESTLIB_INTEGRATION_OBJS) \ 357 $(C_UTIL_INTEGRATION_OBJS) $(C_TESTLIB_ANALYZE_OBJS) \ 358 $(C_TESTLIB_STRESS_OBJS) 359 360TESTS_UNIT_OBJS := $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%.$(O)) 361TESTS_INTEGRATION_OBJS := $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%.$(O)) 362TESTS_INTEGRATION_CPP_OBJS := $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%.$(O)) 363TESTS_ANALYZE_OBJS := $(TESTS_ANALYZE:$(srcroot)%.c=$(objroot)%.$(O)) 364TESTS_STRESS_OBJS := $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%.$(O)) 365TESTS_OBJS := $(TESTS_UNIT_OBJS) $(TESTS_INTEGRATION_OBJS) $(TESTS_ANALYZE_OBJS) \ 366 $(TESTS_STRESS_OBJS) 367TESTS_CPP_OBJS := $(TESTS_INTEGRATION_CPP_OBJS) 368 369.PHONY: all dist build_doc_html build_doc_man build_doc 370.PHONY: install_bin install_include install_lib 371.PHONY: install_doc_html install_doc_man install_doc install 372.PHONY: tests check clean distclean relclean 373 374.SECONDARY : $(PRIVATE_NAMESPACE_GEN_HDRS) $(TESTS_OBJS) $(TESTS_CPP_OBJS) 375 376# Default target. 377all: build_lib 378 379dist: build_doc 380 381$(objroot)doc/%$(install_suffix).html : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/html.xsl 382ifneq ($(XSLROOT),) 383 $(XSLTPROC) -o $@ $(objroot)doc/html.xsl $< 384else 385ifeq ($(wildcard $(DOCS_HTML)),) 386 @echo "<p>Missing xsltproc. Doc not built.</p>" > $@ 387endif 388 @echo "Missing xsltproc. "$@" not (re)built." 389endif 390 391$(objroot)doc/%$(install_suffix).3 : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/manpages.xsl 392ifneq ($(XSLROOT),) 393 $(XSLTPROC) -o $@ $(objroot)doc/manpages.xsl $< 394# The -o option (output filename) of xsltproc may not work (it uses the 395# <refname> in the .xml file). Manually add the suffix if so. 396 ifneq ($(install_suffix),) 397 @if [ -f $(objroot)doc/jemalloc.3 ]; then \ 398 mv $(objroot)doc/jemalloc.3 $(objroot)doc/jemalloc$(install_suffix).3 ; \ 399 fi 400 endif 401else 402ifeq ($(wildcard $(DOCS_MAN3)),) 403 @echo "Missing xsltproc. Doc not built." > $@ 404endif 405 @echo "Missing xsltproc. "$@" not (re)built." 406endif 407 408build_doc_html: $(DOCS_HTML) 409build_doc_man: $(DOCS_MAN3) 410build_doc: $(DOCS) 411 412# 413# Include generated dependency files. 414# 415ifdef CC_MM 416-include $(C_SYM_OBJS:%.$(O)=%.d) 417-include $(C_OBJS:%.$(O)=%.d) 418-include $(CPP_OBJS:%.$(O)=%.d) 419-include $(C_PIC_OBJS:%.$(O)=%.d) 420-include $(CPP_PIC_OBJS:%.$(O)=%.d) 421-include $(C_JET_SYM_OBJS:%.$(O)=%.d) 422-include $(C_JET_OBJS:%.$(O)=%.d) 423-include $(C_TESTLIB_OBJS:%.$(O)=%.d) 424-include $(TESTS_OBJS:%.$(O)=%.d) 425-include $(TESTS_CPP_OBJS:%.$(O)=%.d) 426endif 427 428$(C_SYM_OBJS): $(objroot)src/%.sym.$(O): $(srcroot)src/%.c 429$(C_SYM_OBJS): CPPFLAGS += -DJEMALLOC_NO_PRIVATE_NAMESPACE 430$(C_SYMS): $(objroot)src/%.sym: $(objroot)src/%.sym.$(O) 431$(C_OBJS): $(objroot)src/%.$(O): $(srcroot)src/%.c 432$(CPP_OBJS): $(objroot)src/%.$(O): $(srcroot)src/%.cpp 433$(C_PIC_OBJS): $(objroot)src/%.pic.$(O): $(srcroot)src/%.c 434$(C_PIC_OBJS): CFLAGS += $(PIC_CFLAGS) 435$(CPP_PIC_OBJS): $(objroot)src/%.pic.$(O): $(srcroot)src/%.cpp 436$(CPP_PIC_OBJS): CXXFLAGS += $(PIC_CFLAGS) 437$(C_JET_SYM_OBJS): $(objroot)src/%.jet.sym.$(O): $(srcroot)src/%.c 438$(C_JET_SYM_OBJS): CPPFLAGS += -DJEMALLOC_JET -DJEMALLOC_NO_PRIVATE_NAMESPACE 439$(C_JET_SYMS): $(objroot)src/%.jet.sym: $(objroot)src/%.jet.sym.$(O) 440$(C_JET_OBJS): $(objroot)src/%.jet.$(O): $(srcroot)src/%.c 441$(C_JET_OBJS): CPPFLAGS += -DJEMALLOC_JET 442$(C_TESTLIB_UNIT_OBJS): $(objroot)test/src/%.unit.$(O): $(srcroot)test/src/%.c 443$(C_TESTLIB_UNIT_OBJS): CPPFLAGS += -DJEMALLOC_UNIT_TEST 444$(C_TESTLIB_INTEGRATION_OBJS): $(objroot)test/src/%.integration.$(O): $(srcroot)test/src/%.c 445$(C_TESTLIB_INTEGRATION_OBJS): CPPFLAGS += -DJEMALLOC_INTEGRATION_TEST 446$(C_UTIL_INTEGRATION_OBJS): $(objroot)src/%.integration.$(O): $(srcroot)src/%.c 447$(C_TESTLIB_ANALYZE_OBJS): $(objroot)test/src/%.analyze.$(O): $(srcroot)test/src/%.c 448$(C_TESTLIB_ANALYZE_OBJS): CPPFLAGS += -DJEMALLOC_ANALYZE_TEST 449$(C_TESTLIB_STRESS_OBJS): $(objroot)test/src/%.stress.$(O): $(srcroot)test/src/%.c 450$(C_TESTLIB_STRESS_OBJS): CPPFLAGS += -DJEMALLOC_STRESS_TEST -DJEMALLOC_STRESS_TESTLIB 451$(C_TESTLIB_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include 452$(TESTS_UNIT_OBJS): CPPFLAGS += -DJEMALLOC_UNIT_TEST 453$(TESTS_INTEGRATION_OBJS): CPPFLAGS += -DJEMALLOC_INTEGRATION_TEST 454$(TESTS_INTEGRATION_CPP_OBJS): CPPFLAGS += -DJEMALLOC_INTEGRATION_CPP_TEST 455$(TESTS_ANALYZE_OBJS): CPPFLAGS += -DJEMALLOC_ANALYZE_TEST 456$(TESTS_STRESS_OBJS): CPPFLAGS += -DJEMALLOC_STRESS_TEST 457$(TESTS_OBJS): $(objroot)test/%.$(O): $(srcroot)test/%.c 458$(TESTS_CPP_OBJS): $(objroot)test/%.$(O): $(srcroot)test/%.cpp 459$(TESTS_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include 460$(TESTS_CPP_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include 461ifneq ($(IMPORTLIB),$(SO)) 462$(CPP_OBJS) $(C_SYM_OBJS) $(C_OBJS) $(C_JET_SYM_OBJS) $(C_JET_OBJS): CPPFLAGS += -DDLLEXPORT 463endif 464 465# Dependencies. 466ifndef CC_MM 467HEADER_DIRS = $(srcroot)include/jemalloc/internal \ 468 $(objroot)include/jemalloc $(objroot)include/jemalloc/internal 469HEADERS = $(filter-out $(PRIVATE_NAMESPACE_HDRS),$(wildcard $(foreach dir,$(HEADER_DIRS),$(dir)/*.h))) 470$(C_SYM_OBJS) $(C_OBJS) $(CPP_OBJS) $(C_PIC_OBJS) $(CPP_PIC_OBJS) $(C_JET_SYM_OBJS) $(C_JET_OBJS) $(C_TESTLIB_OBJS) $(TESTS_OBJS) $(TESTS_CPP_OBJS): $(HEADERS) 471$(TESTS_OBJS) $(TESTS_CPP_OBJS): $(objroot)test/include/test/jemalloc_test.h 472endif 473 474$(C_OBJS) $(CPP_OBJS) $(C_PIC_OBJS) $(CPP_PIC_OBJS) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(TESTS_INTEGRATION_OBJS) $(TESTS_INTEGRATION_CPP_OBJS): $(objroot)include/jemalloc/internal/private_namespace.h 475$(C_JET_OBJS) $(C_TESTLIB_UNIT_OBJS) $(C_TESTLIB_ANALYZE_OBJS) $(C_TESTLIB_STRESS_OBJS) $(TESTS_UNIT_OBJS) $(TESTS_ANALYZE_OBJS) $(TESTS_STRESS_OBJS): $(objroot)include/jemalloc/internal/private_namespace_jet.h 476 477$(C_SYM_OBJS) $(C_OBJS) $(C_PIC_OBJS) $(C_JET_SYM_OBJS) $(C_JET_OBJS) $(C_TESTLIB_OBJS) $(TESTS_OBJS): %.$(O): 478 @mkdir -p $(@D) 479 $(CC) $(CFLAGS) -c $(CPPFLAGS) $(CTARGET) $< 480ifdef CC_MM 481 @$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $< 482endif 483 484$(C_SYMS): %.sym: 485 @mkdir -p $(@D) 486 $(DUMP_SYMS) $< | $(AWK) -f $(objroot)include/jemalloc/internal/private_symbols.awk > $@ 487 488$(C_JET_SYMS): %.sym: 489 @mkdir -p $(@D) 490 $(DUMP_SYMS) $< | $(AWK) -f $(objroot)include/jemalloc/internal/private_symbols_jet.awk > $@ 491 492$(objroot)include/jemalloc/internal/private_namespace.gen.h: $(C_SYMS) 493 $(SHELL) $(srcroot)include/jemalloc/internal/private_namespace.sh $^ > $@ 494 495$(objroot)include/jemalloc/internal/private_namespace_jet.gen.h: $(C_JET_SYMS) 496 $(SHELL) $(srcroot)include/jemalloc/internal/private_namespace.sh $^ > $@ 497 498%.h: %.gen.h 499 @if ! `cmp -s $< $@` ; then echo "cp $< $@"; cp $< $@ ; fi 500 501$(CPP_OBJS) $(CPP_PIC_OBJS) $(TESTS_CPP_OBJS): %.$(O): 502 @mkdir -p $(@D) 503 $(CXX) $(CXXFLAGS) -c $(CPPFLAGS) $(CTARGET) $< 504ifdef CC_MM 505 @$(CXX) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $< 506endif 507 508ifneq ($(SOREV),$(SO)) 509%.$(SO) : %.$(SOREV) 510 @mkdir -p $(@D) 511 ln -sf $(<F) $@ 512endif 513 514$(objroot)lib/$(LIBJEMALLOC).$(SOREV) : $(if $(PIC_CFLAGS),$(C_PIC_OBJS),$(C_OBJS)) $(if $(PIC_CFLAGS),$(CPP_PIC_OBJS),$(CPP_OBJS)) 515 @mkdir -p $(@D) 516 $(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) $(LDTARGET) $+ $(LDFLAGS) $(LIBS) $(EXTRA_LDFLAGS) 517 518$(objroot)lib/$(LIBJEMALLOC)_pic.$(A) : $(C_PIC_OBJS) $(CPP_PIC_OBJS) 519$(objroot)lib/$(LIBJEMALLOC).$(A) : $(C_OBJS) $(CPP_OBJS) 520$(objroot)lib/$(LIBJEMALLOC)_s.$(A) : $(C_OBJS) $(CPP_OBJS) 521 522$(STATIC_LIBS): 523 @mkdir -p $(@D) 524 $(AR) $(ARFLAGS)@AROUT@ $+ 525 526$(objroot)test/unit/%$(EXE): $(objroot)test/unit/%.$(O) $(C_JET_OBJS) $(C_TESTLIB_UNIT_OBJS) 527 @mkdir -p $(@D) 528 $(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LDFLAGS) $(filter-out -lm,$(LIBS)) $(LM) $(EXTRA_LDFLAGS) 529 530$(objroot)test/integration/%$(EXE): $(objroot)test/integration/%.$(O) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 531 @mkdir -p $(@D) 532 $(CC) $(TEST_LD_MODE) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LJEMALLOC) $(LDFLAGS) $(filter-out -lm,$(filter -lrt -pthread -lstdc++,$(LIBS))) $(LM) $(EXTRA_LDFLAGS) 533 534$(objroot)test/integration/cpp/%$(EXE): $(objroot)test/integration/cpp/%.$(O) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 535 @mkdir -p $(@D) 536 $(CXX) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(LIBS)) -lm $(EXTRA_LDFLAGS) 537 538$(objroot)test/analyze/%$(EXE): $(objroot)test/analyze/%.$(O) $(C_JET_OBJS) $(C_TESTLIB_ANALYZE_OBJS) 539 @mkdir -p $(@D) 540 $(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LDFLAGS) $(filter-out -lm,$(LIBS)) $(LM) $(EXTRA_LDFLAGS) 541 542$(objroot)test/stress/%$(EXE): $(objroot)test/stress/%.$(O) $(C_JET_OBJS) $(C_TESTLIB_STRESS_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 543 @mkdir -p $(@D) 544 $(CC) $(TEST_LD_MODE) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(LIBS)) $(LM) $(EXTRA_LDFLAGS) 545 546build_lib_shared: $(DSOS) 547build_lib_static: $(STATIC_LIBS) 548ifeq ($(enable_shared), 1) 549build_lib: build_lib_shared 550endif 551ifeq ($(enable_static), 1) 552build_lib: build_lib_static 553endif 554 555install_bin: 556 $(INSTALL) -d $(BINDIR) 557 @for b in $(BINS); do \ 558 $(INSTALL) -v -m 755 $$b $(BINDIR); \ 559done 560 561install_include: 562 $(INSTALL) -d $(INCLUDEDIR)/jemalloc 563 @for h in $(C_HDRS); do \ 564 $(INSTALL) -v -m 644 $$h $(INCLUDEDIR)/jemalloc; \ 565done 566 567install_lib_shared: $(DSOS) 568 $(INSTALL) -d $(LIBDIR) 569 $(INSTALL) -v -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SOREV) $(LIBDIR) 570ifneq ($(SOREV),$(SO)) 571 ln -sf $(LIBJEMALLOC).$(SOREV) $(LIBDIR)/$(LIBJEMALLOC).$(SO) 572endif 573 574install_lib_static: $(STATIC_LIBS) 575 $(INSTALL) -d $(LIBDIR) 576 @for l in $(STATIC_LIBS); do \ 577 $(INSTALL) -v -m 755 $$l $(LIBDIR); \ 578done 579 580install_lib_pc: $(PC) 581 $(INSTALL) -d $(LIBDIR)/pkgconfig 582 @for l in $(PC); do \ 583 $(INSTALL) -v -m 644 $$l $(LIBDIR)/pkgconfig; \ 584done 585 586ifeq ($(enable_shared), 1) 587install_lib: install_lib_shared 588endif 589ifeq ($(enable_static), 1) 590install_lib: install_lib_static 591endif 592install_lib: install_lib_pc 593 594install_doc_html: build_doc_html 595 $(INSTALL) -d $(DATADIR)/doc/jemalloc$(install_suffix) 596 @for d in $(DOCS_HTML); do \ 597 $(INSTALL) -v -m 644 $$d $(DATADIR)/doc/jemalloc$(install_suffix); \ 598done 599 600install_doc_man: build_doc_man 601 $(INSTALL) -d $(MANDIR)/man3 602 @for d in $(DOCS_MAN3); do \ 603 $(INSTALL) -v -m 644 $$d $(MANDIR)/man3; \ 604done 605 606install_doc: install_doc_html install_doc_man 607 608install: install_bin install_include install_lib 609 610ifeq ($(enable_doc), 1) 611install: install_doc 612endif 613 614uninstall_bin: 615 $(RM) -v $(foreach b,$(notdir $(BINS)),$(BINDIR)/$(b)) 616 617uninstall_include: 618 $(RM) -v $(foreach h,$(notdir $(C_HDRS)),$(INCLUDEDIR)/jemalloc/$(h)) 619 rmdir -v $(INCLUDEDIR)/jemalloc 620 621uninstall_lib_shared: 622 $(RM) -v $(LIBDIR)/$(LIBJEMALLOC).$(SOREV) 623ifneq ($(SOREV),$(SO)) 624 $(RM) -v $(LIBDIR)/$(LIBJEMALLOC).$(SO) 625endif 626 627uninstall_lib_static: 628 $(RM) -v $(foreach l,$(notdir $(STATIC_LIBS)),$(LIBDIR)/$(l)) 629 630uninstall_lib_pc: 631 $(RM) -v $(foreach p,$(notdir $(PC)),$(LIBDIR)/pkgconfig/$(p)) 632 633ifeq ($(enable_shared), 1) 634uninstall_lib: uninstall_lib_shared 635endif 636ifeq ($(enable_static), 1) 637uninstall_lib: uninstall_lib_static 638endif 639uninstall_lib: uninstall_lib_pc 640 641uninstall_doc_html: 642 $(RM) -v $(foreach d,$(notdir $(DOCS_HTML)),$(DATADIR)/doc/jemalloc$(install_suffix)/$(d)) 643 rmdir -v $(DATADIR)/doc/jemalloc$(install_suffix) 644 645uninstall_doc_man: 646 $(RM) -v $(foreach d,$(notdir $(DOCS_MAN3)),$(MANDIR)/man3/$(d)) 647 648uninstall_doc: uninstall_doc_html uninstall_doc_man 649 650uninstall: uninstall_bin uninstall_include uninstall_lib 651 652ifeq ($(enable_doc), 1) 653uninstall: uninstall_doc 654endif 655 656tests_unit: $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%$(EXE)) 657tests_integration: $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%$(EXE)) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%$(EXE)) 658tests_analyze: $(TESTS_ANALYZE:$(srcroot)%.c=$(objroot)%$(EXE)) 659tests_stress: $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%$(EXE)) 660tests: tests_unit tests_integration tests_analyze tests_stress 661 662check_unit_dir: 663 @mkdir -p $(objroot)test/unit 664check_integration_dir: 665 @mkdir -p $(objroot)test/integration 666analyze_dir: 667 @mkdir -p $(objroot)test/analyze 668stress_dir: 669 @mkdir -p $(objroot)test/stress 670check_dir: check_unit_dir check_integration_dir 671 672check_unit: tests_unit check_unit_dir 673 $(SHELL) $(objroot)test/test.sh $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%) 674check_integration_prof: tests_integration check_integration_dir 675ifeq ($(enable_prof), 1) 676 $(MALLOC_CONF)="prof:true" $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 677 $(MALLOC_CONF)="prof:true,prof_active:false" $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 678endif 679check_integration_decay: tests_integration check_integration_dir 680 $(MALLOC_CONF)="dirty_decay_ms:-1,muzzy_decay_ms:-1" $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 681 $(MALLOC_CONF)="dirty_decay_ms:0,muzzy_decay_ms:0" $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 682check_integration: tests_integration check_integration_dir 683 $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 684analyze: tests_analyze analyze_dir 685ifeq ($(enable_prof), 1) 686 $(MALLOC_CONF)="prof:true" $(SHELL) $(objroot)test/test.sh $(TESTS_ANALYZE:$(srcroot)%.c=$(objroot)%) 687else 688 $(SHELL) $(objroot)test/test.sh $(TESTS_ANALYZE:$(srcroot)%.c=$(objroot)%) 689endif 690stress: tests_stress stress_dir 691 $(SHELL) $(objroot)test/test.sh $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%) 692check: check_unit check_integration check_integration_decay check_integration_prof 693 694clean: 695 rm -f $(PRIVATE_NAMESPACE_HDRS) 696 rm -f $(PRIVATE_NAMESPACE_GEN_HDRS) 697 rm -f $(C_SYM_OBJS) 698 rm -f $(C_SYMS) 699 rm -f $(C_OBJS) 700 rm -f $(CPP_OBJS) 701 rm -f $(C_PIC_OBJS) 702 rm -f $(CPP_PIC_OBJS) 703 rm -f $(C_JET_SYM_OBJS) 704 rm -f $(C_JET_SYMS) 705 rm -f $(C_JET_OBJS) 706 rm -f $(C_TESTLIB_OBJS) 707 rm -f $(C_SYM_OBJS:%.$(O)=%.d) 708 rm -f $(C_OBJS:%.$(O)=%.d) 709 rm -f $(CPP_OBJS:%.$(O)=%.d) 710 rm -f $(C_PIC_OBJS:%.$(O)=%.d) 711 rm -f $(CPP_PIC_OBJS:%.$(O)=%.d) 712 rm -f $(C_JET_SYM_OBJS:%.$(O)=%.d) 713 rm -f $(C_JET_OBJS:%.$(O)=%.d) 714 rm -f $(C_TESTLIB_OBJS:%.$(O)=%.d) 715 rm -f $(TESTS_OBJS:%.$(O)=%$(EXE)) 716 rm -f $(TESTS_OBJS) 717 rm -f $(TESTS_OBJS:%.$(O)=%.d) 718 rm -f $(TESTS_OBJS:%.$(O)=%.out) 719 rm -f $(TESTS_CPP_OBJS:%.$(O)=%$(EXE)) 720 rm -f $(TESTS_CPP_OBJS) 721 rm -f $(TESTS_CPP_OBJS:%.$(O)=%.d) 722 rm -f $(TESTS_CPP_OBJS:%.$(O)=%.out) 723 rm -f $(DSOS) $(STATIC_LIBS) 724 725distclean: clean 726 rm -f $(objroot)bin/jemalloc-config 727 rm -f $(objroot)bin/jemalloc.sh 728 rm -f $(objroot)bin/jeprof 729 rm -f $(objroot)config.log 730 rm -f $(objroot)config.status 731 rm -f $(objroot)config.stamp 732 rm -f $(cfghdrs_out) 733 rm -f $(cfgoutputs_out) 734 735relclean: distclean 736 rm -f $(objroot)configure 737 rm -f $(objroot)VERSION 738 rm -f $(DOCS_HTML) 739 rm -f $(DOCS_MAN3) 740 741#=============================================================================== 742# Re-configuration rules. 743 744ifeq ($(enable_autogen), 1) 745$(srcroot)configure : $(srcroot)configure.ac 746 cd ./$(srcroot) && $(AUTOCONF) 747 748$(objroot)config.status : $(srcroot)configure 749 ./$(objroot)config.status --recheck 750 751$(srcroot)config.stamp.in : $(srcroot)configure.ac 752 echo stamp > $(srcroot)config.stamp.in 753 754$(objroot)config.stamp : $(cfgoutputs_in) $(cfghdrs_in) $(srcroot)configure 755 ./$(objroot)config.status 756 @touch $@ 757 758# There must be some action in order for make to re-read Makefile when it is 759# out of date. 760$(cfgoutputs_out) $(cfghdrs_out) : $(objroot)config.stamp 761 @true 762endif 763