2009-06-24 10:01:18 +08:00
|
|
|
# Clear out all vpaths, then set just one (default vpath) for the main build
|
|
|
|
# directory.
|
|
|
|
vpath
|
|
|
|
vpath % .
|
|
|
|
|
|
|
|
# Clear the default suffixes, so that built-in rules are not used.
|
|
|
|
.SUFFIXES :
|
|
|
|
|
|
|
|
SHELL := /bin/sh
|
|
|
|
|
|
|
|
CC := @CC@
|
|
|
|
|
|
|
|
# Configuration parameters.
|
2010-03-04 07:48:20 +08:00
|
|
|
DESTDIR =
|
2010-04-03 04:50:53 +08:00
|
|
|
BINDIR := $(DESTDIR)@BINDIR@
|
2010-03-04 07:48:20 +08:00
|
|
|
INCLUDEDIR := $(DESTDIR)@INCLUDEDIR@
|
|
|
|
LIBDIR := $(DESTDIR)@LIBDIR@
|
2010-11-25 14:00:02 +08:00
|
|
|
DATADIR := $(DESTDIR)@DATADIR@
|
2010-03-04 07:48:20 +08:00
|
|
|
MANDIR := $(DESTDIR)@MANDIR@
|
2009-06-24 10:01:18 +08:00
|
|
|
|
|
|
|
# Build parameters.
|
2010-02-12 06:45:59 +08:00
|
|
|
CPPFLAGS := @CPPFLAGS@ -I@srcroot@include -I@objroot@include
|
2011-02-16 06:13:38 +08:00
|
|
|
CFLAGS := @CFLAGS@
|
2009-06-24 10:01:18 +08:00
|
|
|
ifeq (macho, @abi@)
|
|
|
|
CFLAGS += -dynamic
|
|
|
|
endif
|
|
|
|
LDFLAGS := @LDFLAGS@
|
|
|
|
LIBS := @LIBS@
|
|
|
|
RPATH_EXTRA := @RPATH_EXTRA@
|
2011-11-02 13:27:41 +08:00
|
|
|
SO := @so@
|
2009-06-24 10:01:18 +08:00
|
|
|
ifeq (macho, @abi@)
|
2010-09-06 01:35:13 +08:00
|
|
|
WL_SONAME := dylib_install_name
|
2009-06-24 10:01:18 +08:00
|
|
|
else
|
2010-09-06 01:35:13 +08:00
|
|
|
WL_SONAME := soname
|
2009-06-24 10:01:18 +08:00
|
|
|
endif
|
2011-11-02 13:27:41 +08:00
|
|
|
REV := @rev@
|
2010-09-06 01:35:13 +08:00
|
|
|
ifeq (macho, @abi@)
|
|
|
|
TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=@objroot@lib
|
|
|
|
else
|
|
|
|
TEST_LIBRARY_PATH :=
|
|
|
|
endif
|
2009-06-24 10:01:18 +08:00
|
|
|
|
2010-01-17 17:49:20 +08:00
|
|
|
# Lists of files.
|
2011-10-13 13:33:33 +08:00
|
|
|
BINS := @srcroot@bin/pprof @objroot@bin/jemalloc.sh
|
2010-03-04 07:48:20 +08:00
|
|
|
CHDRS := @objroot@include/jemalloc/jemalloc@install_suffix@.h \
|
|
|
|
@objroot@include/jemalloc/jemalloc_defs@install_suffix@.h
|
2011-03-19 08:56:14 +08:00
|
|
|
CSRCS := @srcroot@src/jemalloc.c @srcroot@src/arena.c @srcroot@src/atomic.c \
|
|
|
|
@srcroot@src/base.c @srcroot@src/bitmap.c @srcroot@src/chunk.c \
|
|
|
|
@srcroot@src/chunk_dss.c @srcroot@src/chunk_mmap.c \
|
2012-02-14 02:56:17 +08:00
|
|
|
@srcroot@src/ckh.c @srcroot@src/ctl.c @srcroot@src/extent.c \
|
|
|
|
@srcroot@src/hash.c @srcroot@src/huge.c @srcroot@src/mb.c \
|
|
|
|
@srcroot@src/mutex.c @srcroot@src/prof.c @srcroot@src/rtree.c \
|
2012-03-07 06:57:45 +08:00
|
|
|
@srcroot@src/stats.c @srcroot@src/tcache.c @srcroot@src/util.c
|
2010-09-06 01:35:13 +08:00
|
|
|
ifeq (macho, @abi@)
|
|
|
|
CSRCS += @srcroot@src/zone.c
|
|
|
|
endif
|
2012-02-14 02:56:17 +08:00
|
|
|
STATIC_LIBS := @objroot@lib/libjemalloc@install_suffix@.a
|
2010-09-06 01:35:13 +08:00
|
|
|
DSOS := @objroot@lib/libjemalloc@install_suffix@.$(SO).$(REV) \
|
|
|
|
@objroot@lib/libjemalloc@install_suffix@.$(SO) \
|
2010-01-17 17:49:20 +08:00
|
|
|
@objroot@lib/libjemalloc@install_suffix@_pic.a
|
|
|
|
MAN3 := @objroot@doc/jemalloc@install_suffix@.3
|
2010-11-25 14:00:02 +08:00
|
|
|
DOCS_XML := @objroot@doc/jemalloc@install_suffix@.xml
|
|
|
|
DOCS_HTML := $(DOCS_XML:@objroot@%.xml=@srcroot@%.html)
|
|
|
|
DOCS_MAN3 := $(DOCS_XML:@objroot@%.xml=@srcroot@%.3)
|
|
|
|
DOCS := $(DOCS_HTML) $(DOCS_MAN3)
|
2012-03-14 03:55:21 +08:00
|
|
|
CTESTS := @srcroot@test/aligned_alloc.c @srcroot@test/allocated.c \
|
|
|
|
@srcroot@test/bitmap.c @srcroot@test/mremap.c \
|
|
|
|
@srcroot@test/posix_memalign.c @srcroot@test/thread_arena.c
|
2012-03-03 09:47:37 +08:00
|
|
|
ifeq (@enable_experimental@, 1)
|
|
|
|
CTESTS += @srcroot@test/allocm.c @srcroot@test/rallocm.c
|
|
|
|
endif
|
2009-06-24 10:01:18 +08:00
|
|
|
|
2010-11-25 14:00:02 +08:00
|
|
|
.PHONY: all dist doc_html doc_man doc
|
|
|
|
.PHONY: install_bin install_include install_lib
|
|
|
|
.PHONY: install_html install_man install_doc install
|
|
|
|
.PHONY: tests check clean distclean relclean
|
2009-06-24 10:01:18 +08:00
|
|
|
|
2011-02-14 10:11:54 +08:00
|
|
|
.SECONDARY : $(CTESTS:@srcroot@%.c=@objroot@%.o)
|
|
|
|
|
2009-06-24 10:01:18 +08:00
|
|
|
# Default target.
|
2012-03-03 08:38:37 +08:00
|
|
|
all: build
|
2009-06-24 10:01:18 +08:00
|
|
|
|
2012-03-03 08:38:37 +08:00
|
|
|
dist: build_doc
|
2010-11-25 14:00:02 +08:00
|
|
|
|
|
|
|
@srcroot@doc/%.html : @objroot@doc/%.xml @srcroot@doc/stylesheet.xsl @objroot@doc/html.xsl
|
|
|
|
@XSLTPROC@ -o $@ @objroot@doc/html.xsl $<
|
|
|
|
|
|
|
|
@srcroot@doc/%.3 : @objroot@doc/%.xml @srcroot@doc/stylesheet.xsl @objroot@doc/manpages.xsl
|
|
|
|
@XSLTPROC@ -o $@ @objroot@doc/manpages.xsl $<
|
|
|
|
|
2012-03-03 08:38:37 +08:00
|
|
|
build_doc_html: $(DOCS_HTML)
|
|
|
|
build_doc_man: $(DOCS_MAN3)
|
|
|
|
build_doc: $(DOCS)
|
2010-11-25 14:00:02 +08:00
|
|
|
|
2010-01-17 01:53:50 +08:00
|
|
|
#
|
|
|
|
# Include generated dependency files.
|
|
|
|
#
|
|
|
|
-include $(CSRCS:@srcroot@%.c=@objroot@%.d)
|
2011-03-16 00:40:07 +08:00
|
|
|
-include $(CSRCS:@srcroot@%.c=@objroot@%.pic.d)
|
2011-03-19 08:56:14 +08:00
|
|
|
-include $(CTESTS:@srcroot@%.c=@objroot@%.d)
|
2010-01-17 01:53:50 +08:00
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
@objroot@src/%.o: @srcroot@src/%.c
|
2010-02-12 06:45:59 +08:00
|
|
|
@mkdir -p $(@D)
|
2010-01-04 08:17:55 +08:00
|
|
|
$(CC) $(CFLAGS) -c $(CPPFLAGS) -o $@ $<
|
|
|
|
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"
|
2009-06-24 10:01:18 +08:00
|
|
|
|
2011-02-16 06:13:38 +08:00
|
|
|
@objroot@src/%.pic.o: @srcroot@src/%.c
|
|
|
|
@mkdir -p $(@D)
|
|
|
|
$(CC) $(CFLAGS) -fPIC -DPIC -c $(CPPFLAGS) -o $@ $<
|
2011-03-16 00:40:07 +08:00
|
|
|
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $(basename $@))))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.pic.o \2/g\" > $(@:%.o=%.d)"
|
2011-02-16 06:13:38 +08:00
|
|
|
|
2010-09-06 01:35:13 +08:00
|
|
|
%.$(SO) : %.$(SO).$(REV)
|
2009-06-24 10:01:18 +08:00
|
|
|
@mkdir -p $(@D)
|
2010-04-08 14:37:35 +08:00
|
|
|
ln -sf $(<F) $@
|
|
|
|
|
2011-02-16 06:13:38 +08:00
|
|
|
@objroot@lib/libjemalloc@install_suffix@.$(SO).$(REV) : $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
|
2010-04-08 14:37:35 +08:00
|
|
|
@mkdir -p $(@D)
|
2010-09-06 01:35:13 +08:00
|
|
|
$(CC) -shared -Wl,-$(WL_SONAME),$(@F) $(RPATH_EXTRA:%=@RPATH@%) -o $@ $+ $(LDFLAGS) $(LIBS)
|
2010-04-08 14:37:35 +08:00
|
|
|
|
2011-02-16 06:13:38 +08:00
|
|
|
@objroot@lib/libjemalloc@install_suffix@_pic.a : $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
|
|
|
|
@mkdir -p $(@D)
|
|
|
|
ar crus $@ $+
|
|
|
|
|
|
|
|
@objroot@lib/libjemalloc@install_suffix@.a : $(CSRCS:@srcroot@%.c=@objroot@%.o)
|
2010-04-08 14:37:35 +08:00
|
|
|
@mkdir -p $(@D)
|
|
|
|
ar crus $@ $+
|
2009-06-24 10:01:18 +08:00
|
|
|
|
2010-08-14 06:42:29 +08:00
|
|
|
@objroot@test/%.o: @srcroot@test/%.c
|
|
|
|
@mkdir -p $(@D)
|
2010-10-08 00:53:26 +08:00
|
|
|
$(CC) $(CFLAGS) -c $(CPPFLAGS) -I@objroot@test -o $@ $<
|
|
|
|
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) -I@objroot@test $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"
|
2010-08-14 06:42:29 +08:00
|
|
|
|
Use bitmaps to track small regions.
The previous free list implementation, which embedded singly linked
lists in available regions, had the unfortunate side effect of causing
many cache misses during thread cache fills. Fix this in two places:
- arena_run_t: Use a new bitmap implementation to track which regions
are available. Furthermore, revert to preferring the
lowest available region (as jemalloc did with its old
bitmap-based approach).
- tcache_t: Move read-only tcache_bin_t metadata into
tcache_bin_info_t, and add a contiguous array of pointers
to tcache_t in order to track cached objects. This
substantially increases the size of tcache_t, but results
in much higher data locality for common tcache operations.
As a side benefit, it is again possible to efficiently
flush the least recently used cached objects, so this
change changes flushing from MRU to LRU.
The new bitmap implementation uses a multi-level summary approach to
make finding the lowest available region very fast. In practice,
bitmaps only have one or two levels, though the implementation is
general enough to handle extremely large bitmaps, mainly so that large
page sizes can still be entertained.
Fix tcache_bin_flush_large() to always flush statistics, in the same way
that tcache_bin_flush_small() was recently fixed.
Use JEMALLOC_DEBUG rather than NDEBUG.
Add dassert(), and use it for debug-only asserts.
2011-03-17 01:30:13 +08:00
|
|
|
# Automatic dependency generation misses #include "*.c".
|
|
|
|
@objroot@test/bitmap.o : @objroot@src/bitmap.o
|
|
|
|
|
2010-08-14 06:42:29 +08:00
|
|
|
@objroot@test/%: @objroot@test/%.o \
|
2010-09-06 01:35:13 +08:00
|
|
|
@objroot@lib/libjemalloc@install_suffix@.$(SO)
|
2010-08-14 06:42:29 +08:00
|
|
|
@mkdir -p $(@D)
|
2010-09-06 01:35:13 +08:00
|
|
|
ifneq (@RPATH@, )
|
2011-04-29 03:43:06 +08:00
|
|
|
$(CC) -o $@ $< @RPATH@@objroot@lib -L@objroot@lib -ljemalloc@install_suffix@ -lpthread
|
2010-09-06 01:35:13 +08:00
|
|
|
else
|
2011-04-29 03:43:06 +08:00
|
|
|
$(CC) -o $@ $< -L@objroot@lib -ljemalloc@install_suffix@ -lpthread
|
2010-09-06 01:35:13 +08:00
|
|
|
endif
|
2010-08-14 06:42:29 +08:00
|
|
|
|
2012-03-03 08:38:37 +08:00
|
|
|
build_lib_shared: $(DSOS)
|
|
|
|
build_lib_static: $(STATIC_LIBS)
|
|
|
|
build: build_lib_shared build_lib_static
|
|
|
|
|
2010-04-03 04:50:53 +08:00
|
|
|
install_bin:
|
|
|
|
install -d $(BINDIR)
|
|
|
|
@for b in $(BINS); do \
|
|
|
|
echo "install -m 755 $$b $(BINDIR)"; \
|
|
|
|
install -m 755 $$b $(BINDIR); \
|
|
|
|
done
|
|
|
|
|
2010-03-04 07:48:20 +08:00
|
|
|
install_include:
|
2010-02-12 06:45:59 +08:00
|
|
|
install -d $(INCLUDEDIR)/jemalloc
|
2009-06-24 10:01:18 +08:00
|
|
|
@for h in $(CHDRS); do \
|
2010-02-12 06:45:59 +08:00
|
|
|
echo "install -m 644 $$h $(INCLUDEDIR)/jemalloc"; \
|
|
|
|
install -m 644 $$h $(INCLUDEDIR)/jemalloc; \
|
2009-06-24 10:01:18 +08:00
|
|
|
done
|
2010-03-04 07:48:20 +08:00
|
|
|
|
2012-03-03 08:38:37 +08:00
|
|
|
install_lib_shared: $(DSOS)
|
2009-06-24 10:01:18 +08:00
|
|
|
install -d $(LIBDIR)
|
2010-09-06 01:35:13 +08:00
|
|
|
install -m 755 @objroot@lib/libjemalloc@install_suffix@.$(SO).$(REV) $(LIBDIR)
|
|
|
|
ln -sf libjemalloc@install_suffix@.$(SO).$(REV) $(LIBDIR)/libjemalloc@install_suffix@.$(SO)
|
2012-03-03 08:38:37 +08:00
|
|
|
|
|
|
|
install_lib_static: $(DSOS) $(STATIC_LIBS)
|
|
|
|
install -d $(LIBDIR)
|
2010-01-17 17:49:20 +08:00
|
|
|
install -m 755 @objroot@lib/libjemalloc@install_suffix@_pic.a $(LIBDIR)
|
2011-02-16 06:13:38 +08:00
|
|
|
install -m 755 @objroot@lib/libjemalloc@install_suffix@.a $(LIBDIR)
|
2010-03-04 07:48:20 +08:00
|
|
|
|
2012-03-03 08:38:37 +08:00
|
|
|
install_lib: install_lib_shared install_lib_static
|
|
|
|
|
|
|
|
install_doc_html:
|
2010-11-25 14:00:02 +08:00
|
|
|
install -d $(DATADIR)/doc/jemalloc@install_suffix@
|
|
|
|
@for d in $(DOCS_HTML); do \
|
|
|
|
echo "install -m 644 $$d $(DATADIR)/doc/jemalloc@install_suffix@"; \
|
|
|
|
install -m 644 $$d $(DATADIR)/doc/jemalloc@install_suffix@; \
|
|
|
|
done
|
|
|
|
|
2012-03-03 08:38:37 +08:00
|
|
|
install_doc_man:
|
2010-01-17 17:49:20 +08:00
|
|
|
install -d $(MANDIR)/man3
|
2010-11-25 14:00:02 +08:00
|
|
|
@for d in $(DOCS_MAN3); do \
|
|
|
|
echo "install -m 644 $$d $(MANDIR)/man3"; \
|
|
|
|
install -m 644 $$d $(MANDIR)/man3; \
|
2009-06-24 10:01:18 +08:00
|
|
|
done
|
|
|
|
|
2012-03-03 08:38:37 +08:00
|
|
|
install_doc: install_doc_html install_doc_man
|
2010-11-25 14:00:02 +08:00
|
|
|
|
|
|
|
install: install_bin install_include install_lib install_doc
|
2010-03-04 07:48:20 +08:00
|
|
|
|
2010-08-14 06:42:29 +08:00
|
|
|
tests: $(CTESTS:@srcroot@%.c=@objroot@%)
|
|
|
|
|
|
|
|
check: tests
|
|
|
|
@mkdir -p @objroot@test
|
|
|
|
@$(SHELL) -c 'total=0; \
|
|
|
|
failures=0; \
|
|
|
|
echo "========================================="; \
|
|
|
|
for t in $(CTESTS:@srcroot@%.c=@objroot@%); do \
|
|
|
|
total=`expr $$total + 1`; \
|
|
|
|
/bin/echo -n "$${t} ... "; \
|
2010-09-06 01:35:13 +08:00
|
|
|
$(TEST_LIBRARY_PATH) $${t} @abs_srcroot@ @abs_objroot@ \
|
2010-08-14 06:42:29 +08:00
|
|
|
> @objroot@$${t}.out 2>&1; \
|
|
|
|
if test -e "@srcroot@$${t}.exp"; then \
|
|
|
|
diff -u @srcroot@$${t}.exp \
|
|
|
|
@objroot@$${t}.out >/dev/null 2>&1; \
|
|
|
|
fail=$$?; \
|
|
|
|
if test "$${fail}" -eq "1" ; then \
|
|
|
|
failures=`expr $${failures} + 1`; \
|
|
|
|
echo "*** FAIL ***"; \
|
|
|
|
else \
|
|
|
|
echo "pass"; \
|
|
|
|
fi; \
|
|
|
|
else \
|
|
|
|
echo "*** FAIL *** (.exp file is missing)"; \
|
|
|
|
failures=`expr $${failures} + 1`; \
|
|
|
|
fi; \
|
|
|
|
done; \
|
|
|
|
echo "========================================="; \
|
|
|
|
echo "Failures: $${failures}/$${total}"'
|
2009-06-24 10:01:18 +08:00
|
|
|
|
|
|
|
clean:
|
2010-01-04 08:17:55 +08:00
|
|
|
rm -f $(CSRCS:@srcroot@%.c=@objroot@%.o)
|
2011-02-16 06:13:38 +08:00
|
|
|
rm -f $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
|
2010-01-04 08:17:55 +08:00
|
|
|
rm -f $(CSRCS:@srcroot@%.c=@objroot@%.d)
|
2011-02-16 06:13:38 +08:00
|
|
|
rm -f $(CSRCS:@srcroot@%.c=@objroot@%.pic.d)
|
2010-08-14 06:42:29 +08:00
|
|
|
rm -f $(CTESTS:@srcroot@%.c=@objroot@%)
|
|
|
|
rm -f $(CTESTS:@srcroot@%.c=@objroot@%.o)
|
|
|
|
rm -f $(CTESTS:@srcroot@%.c=@objroot@%.d)
|
|
|
|
rm -f $(CTESTS:@srcroot@%.c=@objroot@%.out)
|
2011-02-16 06:13:38 +08:00
|
|
|
rm -f $(DSOS) $(STATIC_LIBS)
|
2009-06-24 10:01:18 +08:00
|
|
|
|
|
|
|
distclean: clean
|
2010-04-14 13:01:55 +08:00
|
|
|
rm -rf @objroot@autom4te.cache
|
2009-06-24 10:01:18 +08:00
|
|
|
rm -f @objroot@config.log
|
|
|
|
rm -f @objroot@config.status
|
2010-09-06 01:35:13 +08:00
|
|
|
rm -f @objroot@config.stamp
|
2010-01-17 17:49:20 +08:00
|
|
|
rm -f @cfghdrs_out@
|
|
|
|
rm -f @cfgoutputs_out@
|
2009-06-24 10:01:18 +08:00
|
|
|
|
|
|
|
relclean: distclean
|
|
|
|
rm -f @objroot@configure
|
2010-03-03 05:01:16 +08:00
|
|
|
rm -f @srcroot@VERSION
|
2010-11-25 14:00:02 +08:00
|
|
|
rm -f $(DOCS_HTML)
|
|
|
|
rm -f $(DOCS_MAN3)
|
2009-06-24 10:01:18 +08:00
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Re-configuration rules.
|
|
|
|
|
|
|
|
ifeq (@enable_autogen@, 1)
|
|
|
|
@srcroot@configure : @srcroot@configure.ac
|
|
|
|
cd ./@srcroot@ && @AUTOCONF@
|
|
|
|
|
|
|
|
@objroot@config.status : @srcroot@configure
|
|
|
|
./@objroot@config.status --recheck
|
|
|
|
|
2010-04-08 14:37:35 +08:00
|
|
|
@srcroot@config.stamp.in : @srcroot@configure.ac
|
|
|
|
echo stamp > @srcroot@config.stamp.in
|
2009-06-24 10:01:18 +08:00
|
|
|
|
2010-04-08 14:37:35 +08:00
|
|
|
@objroot@config.stamp : @cfgoutputs_in@ @cfghdrs_in@ @srcroot@configure
|
2009-06-24 10:01:18 +08:00
|
|
|
./@objroot@config.status
|
|
|
|
@touch $@
|
|
|
|
|
|
|
|
# There must be some action in order for make to re-read Makefile when it is
|
|
|
|
# out of date.
|
2010-04-08 14:37:35 +08:00
|
|
|
@cfgoutputs_out@ @cfghdrs_out@ : @objroot@config.stamp
|
2009-06-24 10:01:18 +08:00
|
|
|
@true
|
|
|
|
endif
|