1 # Clear out all vpaths, then set just one (default vpath) for the main build 2 # directory. 3 vpath 4 vpath % . 5 6 # Clear the default suffixes, so that built-in rules are not used. 7 .SUFFIXES : 8 9 SHELL := /bin/sh 10 11 CC := @CC@ 12 CXX := @CXX@ 13 14 # Configuration parameters. 15 DESTDIR = 16 BINDIR := $(DESTDIR)@BINDIR@ 17 INCLUDEDIR := $(DESTDIR)@INCLUDEDIR@ 18 LIBDIR := $(DESTDIR)@LIBDIR@ 19 DATADIR := $(DESTDIR)@DATADIR@ 20 MANDIR := $(DESTDIR)@MANDIR@ 21 srcroot := @srcroot@ 22 objroot := @objroot@ 23 abs_srcroot := @abs_srcroot@ 24 abs_objroot := @abs_objroot@ 25 26 # Build parameters. 27 CPPFLAGS := @CPPFLAGS@ -I$(objroot)include -I$(srcroot)include 28 CONFIGURE_CFLAGS := @CONFIGURE_CFLAGS@ 29 SPECIFIED_CFLAGS := @SPECIFIED_CFLAGS@ 30 EXTRA_CFLAGS := @EXTRA_CFLAGS@ 31 CFLAGS := $(strip $(CONFIGURE_CFLAGS) $(SPECIFIED_CFLAGS) $(EXTRA_CFLAGS)) 32 CONFIGURE_CXXFLAGS := @CONFIGURE_CXXFLAGS@ 33 SPECIFIED_CXXFLAGS := @SPECIFIED_CXXFLAGS@ 34 EXTRA_CXXFLAGS := @EXTRA_CXXFLAGS@ 35 CXXFLAGS := $(strip $(CONFIGURE_CXXFLAGS) $(SPECIFIED_CXXFLAGS) $(EXTRA_CXXFLAGS)) 36 LDFLAGS := @LDFLAGS@ 37 EXTRA_LDFLAGS := @EXTRA_LDFLAGS@ 38 LIBS := @LIBS@ 39 RPATH_EXTRA := @RPATH_EXTRA@ 40 SO := @so@ 41 IMPORTLIB := @importlib@ 42 O := @o@ 43 A := @a@ 44 EXE := @exe@ 45 LIBPREFIX := @libprefix@ 46 REV := @rev@ 47 install_suffix := @install_suffix@ 48 ABI := @abi@ 49 XSLTPROC := @XSLTPROC@ 50 XSLROOT := @XSLROOT@ 51 AUTOCONF := @AUTOCONF@ 52 _RPATH = @RPATH@ 53 RPATH = $(if $(1),$(call _RPATH,$(1))) 54 cfghdrs_in := $(addprefix $(srcroot),@cfghdrs_in@) 55 cfghdrs_out := @cfghdrs_out@ 56 cfgoutputs_in := $(addprefix $(srcroot),@cfgoutputs_in@) 57 cfgoutputs_out := @cfgoutputs_out@ 58 enable_autogen := @enable_autogen@ 59 enable_doc := @enable_doc@ 60 enable_shared := @enable_shared@ 61 enable_static := @enable_static@ 62 enable_prof := @enable_prof@ 63 enable_zone_allocator := @enable_zone_allocator@ 64 enable_experimental_smallocx := @enable_experimental_smallocx@ 65 MALLOC_CONF := @JEMALLOC_CPREFIX@MALLOC_CONF 66 link_whole_archive := @link_whole_archive@ 67 DSO_LDFLAGS = @DSO_LDFLAGS@ 68 SOREV = @SOREV@ 69 PIC_CFLAGS = @PIC_CFLAGS@ 70 CTARGET = @CTARGET@ 71 LDTARGET = @LDTARGET@ 72 TEST_LD_MODE = @TEST_LD_MODE@ 73 MKLIB = @MKLIB@ 74 AR = @AR@ 75 ARFLAGS = @ARFLAGS@ 76 DUMP_SYMS = @DUMP_SYMS@ 77 AWK := @AWK@ 78 CC_MM = @CC_MM@ 79 LM := @LM@ 80 INSTALL = @INSTALL@ 81 82 ifeq (macho, $(ABI)) 83 TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH="$(objroot)lib" 84 else 85 ifeq (pecoff, $(ABI)) 86 TEST_LIBRARY_PATH := PATH="$(PATH):$(objroot)lib" 87 else 88 TEST_LIBRARY_PATH := 89 endif 90 endif 91 92 LIBJEMALLOC := $(LIBPREFIX)jemalloc$(install_suffix) 93 94 # Lists of files. 95 BINS := $(objroot)bin/jemalloc-config $(objroot)bin/jemalloc.sh $(objroot)bin/jeprof 96 C_HDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h 97 C_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 159 ifeq ($(enable_zone_allocator), 1) 160 C_SRCS += $(srcroot)src/zone.c 161 endif 162 ifeq ($(IMPORTLIB),$(SO)) 163 STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A) 164 endif 165 ifdef PIC_CFLAGS 166 STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) 167 else 168 STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_s.$(A) 169 endif 170 DSOS := $(objroot)lib/$(LIBJEMALLOC).$(SOREV) 171 ifneq ($(SOREV),$(SO)) 172 DSOS += $(objroot)lib/$(LIBJEMALLOC).$(SO) 173 endif 174 ifeq (1, $(link_whole_archive)) 175 LJEMALLOC := -Wl,--whole-archive -L$(objroot)lib -l$(LIBJEMALLOC) -Wl,--no-whole-archive 176 else 177 LJEMALLOC := $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 178 endif 179 PC := $(objroot)jemalloc.pc 180 DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml 181 DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(objroot)%.html) 182 DOCS_MAN3 := $(DOCS_XML:$(objroot)%.xml=$(objroot)%.3) 183 DOCS := $(DOCS_HTML) $(DOCS_MAN3) 184 C_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 189 ifeq (1, $(link_whole_archive)) 190 C_UTIL_INTEGRATION_SRCS := 191 C_UTIL_CPP_SRCS := 192 else 193 C_UTIL_INTEGRATION_SRCS := $(srcroot)src/nstime.c $(srcroot)src/malloc_io.c \ 194 $(srcroot)src/ticker.c 195 C_UTIL_CPP_SRCS := $(srcroot)src/nstime.c $(srcroot)src/malloc_io.c 196 endif 197 TESTS_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 294 ifeq (@enable_prof@, 1) 295 TESTS_UNIT += \ 296 $(srcroot)test/unit/arena_reset_prof.c \ 297 $(srcroot)test/unit/batch_alloc_prof.c 298 endif 299 TESTS_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 313 ifeq (@enable_experimental_smallocx@, 1) 314 TESTS_INTEGRATION += \ 315 $(srcroot)test/integration/smallocx.c 316 endif 317 ifeq (@enable_cxx@, 1) 318 CPP_SRCS := $(srcroot)src/jemalloc_cpp.cpp 319 TESTS_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 322 else 323 CPP_SRCS := 324 TESTS_INTEGRATION_CPP := 325 endif 326 TESTS_ANALYZE := $(srcroot)test/analyze/prof_bias.c \ 327 $(srcroot)test/analyze/rand.c \ 328 $(srcroot)test/analyze/sizes.c 329 TESTS_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 337 TESTS := $(TESTS_UNIT) $(TESTS_INTEGRATION) $(TESTS_INTEGRATION_CPP) \ 338 $(TESTS_ANALYZE) $(TESTS_STRESS) 339 340 PRIVATE_NAMESPACE_HDRS := $(objroot)include/jemalloc/internal/private_namespace.h $(objroot)include/jemalloc/internal/private_namespace_jet.h 341 PRIVATE_NAMESPACE_GEN_HDRS := $(PRIVATE_NAMESPACE_HDRS:%.h=%.gen.h) 342 C_SYM_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.sym.$(O)) 343 C_SYMS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.sym) 344 C_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.$(O)) 345 CPP_OBJS := $(CPP_SRCS:$(srcroot)%.cpp=$(objroot)%.$(O)) 346 C_PIC_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.pic.$(O)) 347 CPP_PIC_OBJS := $(CPP_SRCS:$(srcroot)%.cpp=$(objroot)%.pic.$(O)) 348 C_JET_SYM_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.sym.$(O)) 349 C_JET_SYMS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.sym) 350 C_JET_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.$(O)) 351 C_TESTLIB_UNIT_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.unit.$(O)) 352 C_TESTLIB_INTEGRATION_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.integration.$(O)) 353 C_UTIL_INTEGRATION_OBJS := $(C_UTIL_INTEGRATION_SRCS:$(srcroot)%.c=$(objroot)%.integration.$(O)) 354 C_TESTLIB_ANALYZE_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.analyze.$(O)) 355 C_TESTLIB_STRESS_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.stress.$(O)) 356 C_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 360 TESTS_UNIT_OBJS := $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%.$(O)) 361 TESTS_INTEGRATION_OBJS := $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%.$(O)) 362 TESTS_INTEGRATION_CPP_OBJS := $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%.$(O)) 363 TESTS_ANALYZE_OBJS := $(TESTS_ANALYZE:$(srcroot)%.c=$(objroot)%.$(O)) 364 TESTS_STRESS_OBJS := $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%.$(O)) 365 TESTS_OBJS := $(TESTS_UNIT_OBJS) $(TESTS_INTEGRATION_OBJS) $(TESTS_ANALYZE_OBJS) \ 366 $(TESTS_STRESS_OBJS) 367 TESTS_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. 377 all: build_lib 378 379 dist: build_doc 380 381 $(objroot)doc/%$(install_suffix).html : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/html.xsl 382 ifneq ($(XSLROOT),) 383 $(XSLTPROC) -o $@ $(objroot)doc/html.xsl $< 384 else 385 ifeq ($(wildcard $(DOCS_HTML)),) 386 @echo "<p>Missing xsltproc. Doc not built.</p>" > $@ 387 endif 388 @echo "Missing xsltproc. "$@" not (re)built." 389 endif 390 391 $(objroot)doc/%$(install_suffix).3 : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/manpages.xsl 392 ifneq ($(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 401 else 402 ifeq ($(wildcard $(DOCS_MAN3)),) 403 @echo "Missing xsltproc. Doc not built." > $@ 404 endif 405 @echo "Missing xsltproc. "$@" not (re)built." 406 endif 407 408 build_doc_html: $(DOCS_HTML) 409 build_doc_man: $(DOCS_MAN3) 410 build_doc: $(DOCS) 411 412 # 413 # Include generated dependency files. 414 # 415 ifdef 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) 426 endif 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 461 ifneq ($(IMPORTLIB),$(SO)) 462 $(CPP_OBJS) $(C_SYM_OBJS) $(C_OBJS) $(C_JET_SYM_OBJS) $(C_JET_OBJS): CPPFLAGS += -DDLLEXPORT 463 endif 464 465 # Dependencies. 466 ifndef CC_MM 467 HEADER_DIRS = $(srcroot)include/jemalloc/internal \ 468 $(objroot)include/jemalloc $(objroot)include/jemalloc/internal 469 HEADERS = $(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 472 endif 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) $< 480 ifdef CC_MM 481 @$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $< 482 endif 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) $< 504 ifdef CC_MM 505 @$(CXX) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $< 506 endif 507 508 ifneq ($(SOREV),$(SO)) 509 %.$(SO) : %.$(SOREV) 510 @mkdir -p $(@D) 511 ln -sf $(<F) $@ 512 endif 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 546 build_lib_shared: $(DSOS) 547 build_lib_static: $(STATIC_LIBS) 548 ifeq ($(enable_shared), 1) 549 build_lib: build_lib_shared 550 endif 551 ifeq ($(enable_static), 1) 552 build_lib: build_lib_static 553 endif 554 555 install_bin: 556 $(INSTALL) -d $(BINDIR) 557 @for b in $(BINS); do \ 558 $(INSTALL) -v -m 755 $$b $(BINDIR); \ 559 done 560 561 install_include: 562 $(INSTALL) -d $(INCLUDEDIR)/jemalloc 563 @for h in $(C_HDRS); do \ 564 $(INSTALL) -v -m 644 $$h $(INCLUDEDIR)/jemalloc; \ 565 done 566 567 install_lib_shared: $(DSOS) 568 $(INSTALL) -d $(LIBDIR) 569 $(INSTALL) -v -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SOREV) $(LIBDIR) 570 ifneq ($(SOREV),$(SO)) 571 ln -sf $(LIBJEMALLOC).$(SOREV) $(LIBDIR)/$(LIBJEMALLOC).$(SO) 572 endif 573 574 install_lib_static: $(STATIC_LIBS) 575 $(INSTALL) -d $(LIBDIR) 576 @for l in $(STATIC_LIBS); do \ 577 $(INSTALL) -v -m 755 $$l $(LIBDIR); \ 578 done 579 580 install_lib_pc: $(PC) 581 $(INSTALL) -d $(LIBDIR)/pkgconfig 582 @for l in $(PC); do \ 583 $(INSTALL) -v -m 644 $$l $(LIBDIR)/pkgconfig; \ 584 done 585 586 ifeq ($(enable_shared), 1) 587 install_lib: install_lib_shared 588 endif 589 ifeq ($(enable_static), 1) 590 install_lib: install_lib_static 591 endif 592 install_lib: install_lib_pc 593 594 install_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); \ 598 done 599 600 install_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; \ 604 done 605 606 install_doc: install_doc_html install_doc_man 607 608 install: install_bin install_include install_lib 609 610 ifeq ($(enable_doc), 1) 611 install: install_doc 612 endif 613 614 uninstall_bin: 615 $(RM) -v $(foreach b,$(notdir $(BINS)),$(BINDIR)/$(b)) 616 617 uninstall_include: 618 $(RM) -v $(foreach h,$(notdir $(C_HDRS)),$(INCLUDEDIR)/jemalloc/$(h)) 619 rmdir -v $(INCLUDEDIR)/jemalloc 620 621 uninstall_lib_shared: 622 $(RM) -v $(LIBDIR)/$(LIBJEMALLOC).$(SOREV) 623 ifneq ($(SOREV),$(SO)) 624 $(RM) -v $(LIBDIR)/$(LIBJEMALLOC).$(SO) 625 endif 626 627 uninstall_lib_static: 628 $(RM) -v $(foreach l,$(notdir $(STATIC_LIBS)),$(LIBDIR)/$(l)) 629 630 uninstall_lib_pc: 631 $(RM) -v $(foreach p,$(notdir $(PC)),$(LIBDIR)/pkgconfig/$(p)) 632 633 ifeq ($(enable_shared), 1) 634 uninstall_lib: uninstall_lib_shared 635 endif 636 ifeq ($(enable_static), 1) 637 uninstall_lib: uninstall_lib_static 638 endif 639 uninstall_lib: uninstall_lib_pc 640 641 uninstall_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 645 uninstall_doc_man: 646 $(RM) -v $(foreach d,$(notdir $(DOCS_MAN3)),$(MANDIR)/man3/$(d)) 647 648 uninstall_doc: uninstall_doc_html uninstall_doc_man 649 650 uninstall: uninstall_bin uninstall_include uninstall_lib 651 652 ifeq ($(enable_doc), 1) 653 uninstall: uninstall_doc 654 endif 655 656 tests_unit: $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%$(EXE)) 657 tests_integration: $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%$(EXE)) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%$(EXE)) 658 tests_analyze: $(TESTS_ANALYZE:$(srcroot)%.c=$(objroot)%$(EXE)) 659 tests_stress: $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%$(EXE)) 660 tests: tests_unit tests_integration tests_analyze tests_stress 661 662 check_unit_dir: 663 @mkdir -p $(objroot)test/unit 664 check_integration_dir: 665 @mkdir -p $(objroot)test/integration 666 analyze_dir: 667 @mkdir -p $(objroot)test/analyze 668 stress_dir: 669 @mkdir -p $(objroot)test/stress 670 check_dir: check_unit_dir check_integration_dir 671 672 check_unit: tests_unit check_unit_dir 673 $(SHELL) $(objroot)test/test.sh $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%) 674 check_integration_prof: tests_integration check_integration_dir 675 ifeq ($(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)%) 678 endif 679 check_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)%) 682 check_integration: tests_integration check_integration_dir 683 $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 684 analyze: tests_analyze analyze_dir 685 ifeq ($(enable_prof), 1) 686 $(MALLOC_CONF)="prof:true" $(SHELL) $(objroot)test/test.sh $(TESTS_ANALYZE:$(srcroot)%.c=$(objroot)%) 687 else 688 $(SHELL) $(objroot)test/test.sh $(TESTS_ANALYZE:$(srcroot)%.c=$(objroot)%) 689 endif 690 stress: tests_stress stress_dir 691 $(SHELL) $(objroot)test/test.sh $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%) 692 check: check_unit check_integration check_integration_decay check_integration_prof 693 694 clean: 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 725 distclean: 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 735 relclean: 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 744 ifeq ($(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 762 endif 763