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@ 50AUTOCONF := @AUTOCONF@ 51_RPATH = @RPATH@ 52RPATH = $(if $(1),$(call _RPATH,$(1))) 53cfghdrs_in := $(addprefix $(srcroot),@cfghdrs_in@) 54cfghdrs_out := @cfghdrs_out@ 55cfgoutputs_in := $(addprefix $(srcroot),@cfgoutputs_in@) 56cfgoutputs_out := @cfgoutputs_out@ 57enable_autogen := @enable_autogen@ 58enable_prof := @enable_prof@ 59enable_zone_allocator := @enable_zone_allocator@ 60MALLOC_CONF := @JEMALLOC_CPREFIX@MALLOC_CONF 61link_whole_archive := @link_whole_archive@ 62DSO_LDFLAGS = @DSO_LDFLAGS@ 63SOREV = @SOREV@ 64PIC_CFLAGS = @PIC_CFLAGS@ 65CTARGET = @CTARGET@ 66LDTARGET = @LDTARGET@ 67TEST_LD_MODE = @TEST_LD_MODE@ 68MKLIB = @MKLIB@ 69AR = @AR@ 70ARFLAGS = @ARFLAGS@ 71DUMP_SYMS = @DUMP_SYMS@ 72AWK := @AWK@ 73CC_MM = @CC_MM@ 74LM := @LM@ 75INSTALL = @INSTALL@ 76 77ifeq (macho, $(ABI)) 78TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH="$(objroot)lib" 79else 80ifeq (pecoff, $(ABI)) 81TEST_LIBRARY_PATH := PATH="$(PATH):$(objroot)lib" 82else 83TEST_LIBRARY_PATH := 84endif 85endif 86 87LIBJEMALLOC := $(LIBPREFIX)jemalloc$(install_suffix) 88 89# Lists of files. 90BINS := $(objroot)bin/jemalloc-config $(objroot)bin/jemalloc.sh $(objroot)bin/jeprof 91C_HDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h 92C_SRCS := $(srcroot)src/jemalloc.c \ 93 $(srcroot)src/arena.c \ 94 $(srcroot)src/background_thread.c \ 95 $(srcroot)src/base.c \ 96 $(srcroot)src/bin.c \ 97 $(srcroot)src/bitmap.c \ 98 $(srcroot)src/ckh.c \ 99 $(srcroot)src/ctl.c \ 100 $(srcroot)src/div.c \ 101 $(srcroot)src/extent.c \ 102 $(srcroot)src/extent_dss.c \ 103 $(srcroot)src/extent_mmap.c \ 104 $(srcroot)src/hash.c \ 105 $(srcroot)src/hooks.c \ 106 $(srcroot)src/large.c \ 107 $(srcroot)src/log.c \ 108 $(srcroot)src/malloc_io.c \ 109 $(srcroot)src/mutex.c \ 110 $(srcroot)src/mutex_pool.c \ 111 $(srcroot)src/nstime.c \ 112 $(srcroot)src/pages.c \ 113 $(srcroot)src/prng.c \ 114 $(srcroot)src/prof.c \ 115 $(srcroot)src/rtree.c \ 116 $(srcroot)src/stats.c \ 117 $(srcroot)src/sz.c \ 118 $(srcroot)src/tcache.c \ 119 $(srcroot)src/ticker.c \ 120 $(srcroot)src/tsd.c \ 121 $(srcroot)src/witness.c 122ifeq ($(enable_zone_allocator), 1) 123C_SRCS += $(srcroot)src/zone.c 124endif 125ifeq ($(IMPORTLIB),$(SO)) 126STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A) 127endif 128ifdef PIC_CFLAGS 129STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) 130else 131STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_s.$(A) 132endif 133DSOS := $(objroot)lib/$(LIBJEMALLOC).$(SOREV) 134ifneq ($(SOREV),$(SO)) 135DSOS += $(objroot)lib/$(LIBJEMALLOC).$(SO) 136endif 137ifeq (1, $(link_whole_archive)) 138LJEMALLOC := -Wl,--whole-archive -L$(objroot)lib -l$(LIBJEMALLOC) -Wl,--no-whole-archive 139else 140LJEMALLOC := $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 141endif 142PC := $(objroot)jemalloc.pc 143MAN3 := $(objroot)doc/jemalloc$(install_suffix).3 144DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml 145DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(objroot)%.html) 146DOCS_MAN3 := $(DOCS_XML:$(objroot)%.xml=$(objroot)%.3) 147DOCS := $(DOCS_HTML) $(DOCS_MAN3) 148C_TESTLIB_SRCS := $(srcroot)test/src/btalloc.c $(srcroot)test/src/btalloc_0.c \ 149 $(srcroot)test/src/btalloc_1.c $(srcroot)test/src/math.c \ 150 $(srcroot)test/src/mtx.c $(srcroot)test/src/mq.c \ 151 $(srcroot)test/src/SFMT.c $(srcroot)test/src/test.c \ 152 $(srcroot)test/src/thd.c $(srcroot)test/src/timer.c 153ifeq (1, $(link_whole_archive)) 154C_UTIL_INTEGRATION_SRCS := 155C_UTIL_CPP_SRCS := 156else 157C_UTIL_INTEGRATION_SRCS := $(srcroot)src/nstime.c $(srcroot)src/malloc_io.c 158C_UTIL_CPP_SRCS := $(srcroot)src/nstime.c $(srcroot)src/malloc_io.c 159endif 160TESTS_UNIT := \ 161 $(srcroot)test/unit/a0.c \ 162 $(srcroot)test/unit/arena_reset.c \ 163 $(srcroot)test/unit/atomic.c \ 164 $(srcroot)test/unit/background_thread.c \ 165 $(srcroot)test/unit/background_thread_enable.c \ 166 $(srcroot)test/unit/base.c \ 167 $(srcroot)test/unit/bitmap.c \ 168 $(srcroot)test/unit/ckh.c \ 169 $(srcroot)test/unit/decay.c \ 170 $(srcroot)test/unit/div.c \ 171 $(srcroot)test/unit/emitter.c \ 172 $(srcroot)test/unit/extent_quantize.c \ 173 $(srcroot)test/unit/fork.c \ 174 $(srcroot)test/unit/hash.c \ 175 $(srcroot)test/unit/hooks.c \ 176 $(srcroot)test/unit/junk.c \ 177 $(srcroot)test/unit/junk_alloc.c \ 178 $(srcroot)test/unit/junk_free.c \ 179 $(srcroot)test/unit/log.c \ 180 $(srcroot)test/unit/mallctl.c \ 181 $(srcroot)test/unit/malloc_io.c \ 182 $(srcroot)test/unit/math.c \ 183 $(srcroot)test/unit/mq.c \ 184 $(srcroot)test/unit/mtx.c \ 185 $(srcroot)test/unit/pack.c \ 186 $(srcroot)test/unit/pages.c \ 187 $(srcroot)test/unit/ph.c \ 188 $(srcroot)test/unit/prng.c \ 189 $(srcroot)test/unit/prof_accum.c \ 190 $(srcroot)test/unit/prof_active.c \ 191 $(srcroot)test/unit/prof_gdump.c \ 192 $(srcroot)test/unit/prof_idump.c \ 193 $(srcroot)test/unit/prof_reset.c \ 194 $(srcroot)test/unit/prof_tctx.c \ 195 $(srcroot)test/unit/prof_thread_name.c \ 196 $(srcroot)test/unit/ql.c \ 197 $(srcroot)test/unit/qr.c \ 198 $(srcroot)test/unit/rb.c \ 199 $(srcroot)test/unit/retained.c \ 200 $(srcroot)test/unit/rtree.c \ 201 $(srcroot)test/unit/SFMT.c \ 202 $(srcroot)test/unit/size_classes.c \ 203 $(srcroot)test/unit/slab.c \ 204 $(srcroot)test/unit/smoothstep.c \ 205 $(srcroot)test/unit/spin.c \ 206 $(srcroot)test/unit/stats.c \ 207 $(srcroot)test/unit/stats_print.c \ 208 $(srcroot)test/unit/ticker.c \ 209 $(srcroot)test/unit/nstime.c \ 210 $(srcroot)test/unit/tsd.c \ 211 $(srcroot)test/unit/witness.c \ 212 $(srcroot)test/unit/zero.c 213ifeq (@enable_prof@, 1) 214TESTS_UNIT += \ 215 $(srcroot)test/unit/arena_reset_prof.c 216endif 217TESTS_INTEGRATION := $(srcroot)test/integration/aligned_alloc.c \ 218 $(srcroot)test/integration/allocated.c \ 219 $(srcroot)test/integration/extent.c \ 220 $(srcroot)test/integration/mallocx.c \ 221 $(srcroot)test/integration/MALLOCX_ARENA.c \ 222 $(srcroot)test/integration/overflow.c \ 223 $(srcroot)test/integration/posix_memalign.c \ 224 $(srcroot)test/integration/rallocx.c \ 225 $(srcroot)test/integration/sdallocx.c \ 226 $(srcroot)test/integration/thread_arena.c \ 227 $(srcroot)test/integration/thread_tcache_enabled.c \ 228 $(srcroot)test/integration/xallocx.c 229ifeq (@enable_cxx@, 1) 230CPP_SRCS := $(srcroot)src/jemalloc_cpp.cpp 231TESTS_INTEGRATION_CPP := $(srcroot)test/integration/cpp/basic.cpp 232else 233CPP_SRCS := 234TESTS_INTEGRATION_CPP := 235endif 236TESTS_STRESS := $(srcroot)test/stress/microbench.c 237 238TESTS := $(TESTS_UNIT) $(TESTS_INTEGRATION) $(TESTS_INTEGRATION_CPP) $(TESTS_STRESS) 239 240PRIVATE_NAMESPACE_HDRS := $(objroot)include/jemalloc/internal/private_namespace.h $(objroot)include/jemalloc/internal/private_namespace_jet.h 241PRIVATE_NAMESPACE_GEN_HDRS := $(PRIVATE_NAMESPACE_HDRS:%.h=%.gen.h) 242C_SYM_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.sym.$(O)) 243C_SYMS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.sym) 244C_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.$(O)) 245CPP_OBJS := $(CPP_SRCS:$(srcroot)%.cpp=$(objroot)%.$(O)) 246C_PIC_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.pic.$(O)) 247CPP_PIC_OBJS := $(CPP_SRCS:$(srcroot)%.cpp=$(objroot)%.pic.$(O)) 248C_JET_SYM_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.sym.$(O)) 249C_JET_SYMS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.sym) 250C_JET_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.$(O)) 251C_TESTLIB_UNIT_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.unit.$(O)) 252C_TESTLIB_INTEGRATION_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.integration.$(O)) 253C_UTIL_INTEGRATION_OBJS := $(C_UTIL_INTEGRATION_SRCS:$(srcroot)%.c=$(objroot)%.integration.$(O)) 254C_TESTLIB_STRESS_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.stress.$(O)) 255C_TESTLIB_OBJS := $(C_TESTLIB_UNIT_OBJS) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(C_TESTLIB_STRESS_OBJS) 256 257TESTS_UNIT_OBJS := $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%.$(O)) 258TESTS_INTEGRATION_OBJS := $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%.$(O)) 259TESTS_INTEGRATION_CPP_OBJS := $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%.$(O)) 260TESTS_STRESS_OBJS := $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%.$(O)) 261TESTS_OBJS := $(TESTS_UNIT_OBJS) $(TESTS_INTEGRATION_OBJS) $(TESTS_STRESS_OBJS) 262TESTS_CPP_OBJS := $(TESTS_INTEGRATION_CPP_OBJS) 263 264.PHONY: all dist build_doc_html build_doc_man build_doc 265.PHONY: install_bin install_include install_lib 266.PHONY: install_doc_html install_doc_man install_doc install 267.PHONY: tests check clean distclean relclean 268 269.SECONDARY : $(PRIVATE_NAMESPACE_GEN_HDRS) $(TESTS_OBJS) $(TESTS_CPP_OBJS) 270 271# Default target. 272all: build_lib 273 274dist: build_doc 275 276$(objroot)doc/%.html : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/html.xsl 277 $(XSLTPROC) -o $@ $(objroot)doc/html.xsl $< 278 279$(objroot)doc/%.3 : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/manpages.xsl 280 $(XSLTPROC) -o $@ $(objroot)doc/manpages.xsl $< 281 282build_doc_html: $(DOCS_HTML) 283build_doc_man: $(DOCS_MAN3) 284build_doc: $(DOCS) 285 286# 287# Include generated dependency files. 288# 289ifdef CC_MM 290-include $(C_SYM_OBJS:%.$(O)=%.d) 291-include $(C_OBJS:%.$(O)=%.d) 292-include $(CPP_OBJS:%.$(O)=%.d) 293-include $(C_PIC_OBJS:%.$(O)=%.d) 294-include $(CPP_PIC_OBJS:%.$(O)=%.d) 295-include $(C_JET_SYM_OBJS:%.$(O)=%.d) 296-include $(C_JET_OBJS:%.$(O)=%.d) 297-include $(C_TESTLIB_OBJS:%.$(O)=%.d) 298-include $(TESTS_OBJS:%.$(O)=%.d) 299-include $(TESTS_CPP_OBJS:%.$(O)=%.d) 300endif 301 302$(C_SYM_OBJS): $(objroot)src/%.sym.$(O): $(srcroot)src/%.c 303$(C_SYM_OBJS): CPPFLAGS += -DJEMALLOC_NO_PRIVATE_NAMESPACE 304$(C_SYMS): $(objroot)src/%.sym: $(objroot)src/%.sym.$(O) 305$(C_OBJS): $(objroot)src/%.$(O): $(srcroot)src/%.c 306$(CPP_OBJS): $(objroot)src/%.$(O): $(srcroot)src/%.cpp 307$(C_PIC_OBJS): $(objroot)src/%.pic.$(O): $(srcroot)src/%.c 308$(C_PIC_OBJS): CFLAGS += $(PIC_CFLAGS) 309$(CPP_PIC_OBJS): $(objroot)src/%.pic.$(O): $(srcroot)src/%.cpp 310$(CPP_PIC_OBJS): CXXFLAGS += $(PIC_CFLAGS) 311$(C_JET_SYM_OBJS): $(objroot)src/%.jet.sym.$(O): $(srcroot)src/%.c 312$(C_JET_SYM_OBJS): CPPFLAGS += -DJEMALLOC_JET -DJEMALLOC_NO_PRIVATE_NAMESPACE 313$(C_JET_SYMS): $(objroot)src/%.jet.sym: $(objroot)src/%.jet.sym.$(O) 314$(C_JET_OBJS): $(objroot)src/%.jet.$(O): $(srcroot)src/%.c 315$(C_JET_OBJS): CPPFLAGS += -DJEMALLOC_JET 316$(C_TESTLIB_UNIT_OBJS): $(objroot)test/src/%.unit.$(O): $(srcroot)test/src/%.c 317$(C_TESTLIB_UNIT_OBJS): CPPFLAGS += -DJEMALLOC_UNIT_TEST 318$(C_TESTLIB_INTEGRATION_OBJS): $(objroot)test/src/%.integration.$(O): $(srcroot)test/src/%.c 319$(C_TESTLIB_INTEGRATION_OBJS): CPPFLAGS += -DJEMALLOC_INTEGRATION_TEST 320$(C_UTIL_INTEGRATION_OBJS): $(objroot)src/%.integration.$(O): $(srcroot)src/%.c 321$(C_TESTLIB_STRESS_OBJS): $(objroot)test/src/%.stress.$(O): $(srcroot)test/src/%.c 322$(C_TESTLIB_STRESS_OBJS): CPPFLAGS += -DJEMALLOC_STRESS_TEST -DJEMALLOC_STRESS_TESTLIB 323$(C_TESTLIB_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include 324$(TESTS_UNIT_OBJS): CPPFLAGS += -DJEMALLOC_UNIT_TEST 325$(TESTS_INTEGRATION_OBJS): CPPFLAGS += -DJEMALLOC_INTEGRATION_TEST 326$(TESTS_INTEGRATION_CPP_OBJS): CPPFLAGS += -DJEMALLOC_INTEGRATION_CPP_TEST 327$(TESTS_STRESS_OBJS): CPPFLAGS += -DJEMALLOC_STRESS_TEST 328$(TESTS_OBJS): $(objroot)test/%.$(O): $(srcroot)test/%.c 329$(TESTS_CPP_OBJS): $(objroot)test/%.$(O): $(srcroot)test/%.cpp 330$(TESTS_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include 331$(TESTS_CPP_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include 332ifneq ($(IMPORTLIB),$(SO)) 333$(CPP_OBJS) $(C_SYM_OBJS) $(C_OBJS) $(C_JET_SYM_OBJS) $(C_JET_OBJS): CPPFLAGS += -DDLLEXPORT 334endif 335 336# Dependencies. 337ifndef CC_MM 338HEADER_DIRS = $(srcroot)include/jemalloc/internal \ 339 $(objroot)include/jemalloc $(objroot)include/jemalloc/internal 340HEADERS = $(filter-out $(PRIVATE_NAMESPACE_HDRS),$(wildcard $(foreach dir,$(HEADER_DIRS),$(dir)/*.h))) 341$(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) 342$(TESTS_OBJS) $(TESTS_CPP_OBJS): $(objroot)test/include/test/jemalloc_test.h 343endif 344 345$(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 346$(C_JET_OBJS) $(C_TESTLIB_UNIT_OBJS) $(C_TESTLIB_STRESS_OBJS) $(TESTS_UNIT_OBJS) $(TESTS_STRESS_OBJS): $(objroot)include/jemalloc/internal/private_namespace_jet.h 347 348$(C_SYM_OBJS) $(C_OBJS) $(C_PIC_OBJS) $(C_JET_SYM_OBJS) $(C_JET_OBJS) $(C_TESTLIB_OBJS) $(TESTS_OBJS): %.$(O): 349 @mkdir -p $(@D) 350 $(CC) $(CFLAGS) -c $(CPPFLAGS) $(CTARGET) $< 351ifdef CC_MM 352 @$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $< 353endif 354 355$(C_SYMS): %.sym: 356 @mkdir -p $(@D) 357 $(DUMP_SYMS) $< | $(AWK) -f $(objroot)include/jemalloc/internal/private_symbols.awk > $@ 358 359$(C_JET_SYMS): %.sym: 360 @mkdir -p $(@D) 361 $(DUMP_SYMS) $< | $(AWK) -f $(objroot)include/jemalloc/internal/private_symbols_jet.awk > $@ 362 363$(objroot)include/jemalloc/internal/private_namespace.gen.h: $(C_SYMS) 364 $(SHELL) $(srcroot)include/jemalloc/internal/private_namespace.sh $^ > $@ 365 366$(objroot)include/jemalloc/internal/private_namespace_jet.gen.h: $(C_JET_SYMS) 367 $(SHELL) $(srcroot)include/jemalloc/internal/private_namespace.sh $^ > $@ 368 369%.h: %.gen.h 370 @if ! `cmp -s $< $@` ; then echo "cp $< $<"; cp $< $@ ; fi 371 372$(CPP_OBJS) $(CPP_PIC_OBJS) $(TESTS_CPP_OBJS): %.$(O): 373 @mkdir -p $(@D) 374 $(CXX) $(CXXFLAGS) -c $(CPPFLAGS) $(CTARGET) $< 375ifdef CC_MM 376 @$(CXX) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $< 377endif 378 379ifneq ($(SOREV),$(SO)) 380%.$(SO) : %.$(SOREV) 381 @mkdir -p $(@D) 382 ln -sf $(<F) $@ 383endif 384 385$(objroot)lib/$(LIBJEMALLOC).$(SOREV) : $(if $(PIC_CFLAGS),$(C_PIC_OBJS),$(C_OBJS)) $(if $(PIC_CFLAGS),$(CPP_PIC_OBJS),$(CPP_OBJS)) 386 @mkdir -p $(@D) 387 $(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) $(LDTARGET) $+ $(LDFLAGS) $(LIBS) $(EXTRA_LDFLAGS) 388 389$(objroot)lib/$(LIBJEMALLOC)_pic.$(A) : $(C_PIC_OBJS) $(CPP_PIC_OBJS) 390$(objroot)lib/$(LIBJEMALLOC).$(A) : $(C_OBJS) $(CPP_OBJS) 391$(objroot)lib/$(LIBJEMALLOC)_s.$(A) : $(C_OBJS) $(CPP_OBJS) 392 393$(STATIC_LIBS): 394 @mkdir -p $(@D) 395 $(AR) $(ARFLAGS)@AROUT@ $+ 396 397$(objroot)test/unit/%$(EXE): $(objroot)test/unit/%.$(O) $(C_JET_OBJS) $(C_TESTLIB_UNIT_OBJS) 398 @mkdir -p $(@D) 399 $(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LDFLAGS) $(filter-out -lm,$(LIBS)) $(LM) $(EXTRA_LDFLAGS) 400 401$(objroot)test/integration/%$(EXE): $(objroot)test/integration/%.$(O) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 402 @mkdir -p $(@D) 403 $(CC) $(TEST_LD_MODE) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LJEMALLOC) $(LDFLAGS) $(filter-out -lm,$(filter -lrt -lpthread -lstdc++,$(LIBS))) $(LM) $(EXTRA_LDFLAGS) 404 405$(objroot)test/integration/cpp/%$(EXE): $(objroot)test/integration/cpp/%.$(O) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 406 @mkdir -p $(@D) 407 $(CXX) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(LIBS)) -lm $(EXTRA_LDFLAGS) 408 409$(objroot)test/stress/%$(EXE): $(objroot)test/stress/%.$(O) $(C_JET_OBJS) $(C_TESTLIB_STRESS_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) 410 @mkdir -p $(@D) 411 $(CC) $(TEST_LD_MODE) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(LIBS)) $(LM) $(EXTRA_LDFLAGS) 412 413build_lib_shared: $(DSOS) 414build_lib_static: $(STATIC_LIBS) 415build_lib: build_lib_shared build_lib_static 416 417install_bin: 418 $(INSTALL) -d $(BINDIR) 419 @for b in $(BINS); do \ 420 echo "$(INSTALL) -m 755 $$b $(BINDIR)"; \ 421 $(INSTALL) -m 755 $$b $(BINDIR); \ 422done 423 424install_include: 425 $(INSTALL) -d $(INCLUDEDIR)/jemalloc 426 @for h in $(C_HDRS); do \ 427 echo "$(INSTALL) -m 644 $$h $(INCLUDEDIR)/jemalloc"; \ 428 $(INSTALL) -m 644 $$h $(INCLUDEDIR)/jemalloc; \ 429done 430 431install_lib_shared: $(DSOS) 432 $(INSTALL) -d $(LIBDIR) 433 $(INSTALL) -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SOREV) $(LIBDIR) 434ifneq ($(SOREV),$(SO)) 435 ln -sf $(LIBJEMALLOC).$(SOREV) $(LIBDIR)/$(LIBJEMALLOC).$(SO) 436endif 437 438install_lib_static: $(STATIC_LIBS) 439 $(INSTALL) -d $(LIBDIR) 440 @for l in $(STATIC_LIBS); do \ 441 echo "$(INSTALL) -m 755 $$l $(LIBDIR)"; \ 442 $(INSTALL) -m 755 $$l $(LIBDIR); \ 443done 444 445install_lib_pc: $(PC) 446 $(INSTALL) -d $(LIBDIR)/pkgconfig 447 @for l in $(PC); do \ 448 echo "$(INSTALL) -m 644 $$l $(LIBDIR)/pkgconfig"; \ 449 $(INSTALL) -m 644 $$l $(LIBDIR)/pkgconfig; \ 450done 451 452install_lib: install_lib_shared install_lib_static install_lib_pc 453 454install_doc_html: 455 $(INSTALL) -d $(DATADIR)/doc/jemalloc$(install_suffix) 456 @for d in $(DOCS_HTML); do \ 457 echo "$(INSTALL) -m 644 $$d $(DATADIR)/doc/jemalloc$(install_suffix)"; \ 458 $(INSTALL) -m 644 $$d $(DATADIR)/doc/jemalloc$(install_suffix); \ 459done 460 461install_doc_man: 462 $(INSTALL) -d $(MANDIR)/man3 463 @for d in $(DOCS_MAN3); do \ 464 echo "$(INSTALL) -m 644 $$d $(MANDIR)/man3"; \ 465 $(INSTALL) -m 644 $$d $(MANDIR)/man3; \ 466done 467 468install_doc: install_doc_html install_doc_man 469 470install: install_bin install_include install_lib install_doc 471 472tests_unit: $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%$(EXE)) 473tests_integration: $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%$(EXE)) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%$(EXE)) 474tests_stress: $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%$(EXE)) 475tests: tests_unit tests_integration tests_stress 476 477check_unit_dir: 478 @mkdir -p $(objroot)test/unit 479check_integration_dir: 480 @mkdir -p $(objroot)test/integration 481stress_dir: 482 @mkdir -p $(objroot)test/stress 483check_dir: check_unit_dir check_integration_dir 484 485check_unit: tests_unit check_unit_dir 486 $(SHELL) $(objroot)test/test.sh $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%) 487check_integration_prof: tests_integration check_integration_dir 488ifeq ($(enable_prof), 1) 489 $(MALLOC_CONF)="prof:true" $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 490 $(MALLOC_CONF)="prof:true,prof_active:false" $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 491endif 492check_integration_decay: tests_integration check_integration_dir 493 $(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)%) 494 $(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)%) 495check_integration: tests_integration check_integration_dir 496 $(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%) 497stress: tests_stress stress_dir 498 $(SHELL) $(objroot)test/test.sh $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%) 499check: check_unit check_integration check_integration_decay check_integration_prof 500 501clean: 502 rm -f $(PRIVATE_NAMESPACE_HDRS) 503 rm -f $(PRIVATE_NAMESPACE_GEN_HDRS) 504 rm -f $(C_SYM_OBJS) 505 rm -f $(C_SYMS) 506 rm -f $(C_OBJS) 507 rm -f $(CPP_OBJS) 508 rm -f $(C_PIC_OBJS) 509 rm -f $(CPP_PIC_OBJS) 510 rm -f $(C_JET_SYM_OBJS) 511 rm -f $(C_JET_SYMS) 512 rm -f $(C_JET_OBJS) 513 rm -f $(C_TESTLIB_OBJS) 514 rm -f $(C_SYM_OBJS:%.$(O)=%.d) 515 rm -f $(C_OBJS:%.$(O)=%.d) 516 rm -f $(CPP_OBJS:%.$(O)=%.d) 517 rm -f $(C_PIC_OBJS:%.$(O)=%.d) 518 rm -f $(CPP_PIC_OBJS:%.$(O)=%.d) 519 rm -f $(C_JET_SYM_OBJS:%.$(O)=%.d) 520 rm -f $(C_JET_OBJS:%.$(O)=%.d) 521 rm -f $(C_TESTLIB_OBJS:%.$(O)=%.d) 522 rm -f $(TESTS_OBJS:%.$(O)=%$(EXE)) 523 rm -f $(TESTS_OBJS) 524 rm -f $(TESTS_OBJS:%.$(O)=%.d) 525 rm -f $(TESTS_OBJS:%.$(O)=%.out) 526 rm -f $(TESTS_CPP_OBJS:%.$(O)=%$(EXE)) 527 rm -f $(TESTS_CPP_OBJS) 528 rm -f $(TESTS_CPP_OBJS:%.$(O)=%.d) 529 rm -f $(TESTS_CPP_OBJS:%.$(O)=%.out) 530 rm -f $(DSOS) $(STATIC_LIBS) 531 532distclean: clean 533 rm -f $(objroot)bin/jemalloc-config 534 rm -f $(objroot)bin/jemalloc.sh 535 rm -f $(objroot)bin/jeprof 536 rm -f $(objroot)config.log 537 rm -f $(objroot)config.status 538 rm -f $(objroot)config.stamp 539 rm -f $(cfghdrs_out) 540 rm -f $(cfgoutputs_out) 541 542relclean: distclean 543 rm -f $(objroot)configure 544 rm -f $(objroot)VERSION 545 rm -f $(DOCS_HTML) 546 rm -f $(DOCS_MAN3) 547 548#=============================================================================== 549# Re-configuration rules. 550 551ifeq ($(enable_autogen), 1) 552$(srcroot)configure : $(srcroot)configure.ac 553 cd ./$(srcroot) && $(AUTOCONF) 554 555$(objroot)config.status : $(srcroot)configure 556 ./$(objroot)config.status --recheck 557 558$(srcroot)config.stamp.in : $(srcroot)configure.ac 559 echo stamp > $(srcroot)config.stamp.in 560 561$(objroot)config.stamp : $(cfgoutputs_in) $(cfghdrs_in) $(srcroot)configure 562 ./$(objroot)config.status 563 @touch $@ 564 565# There must be some action in order for make to re-read Makefile when it is 566# out of date. 567$(cfgoutputs_out) $(cfghdrs_out) : $(objroot)config.stamp 568 @true 569endif 570