1 # Clear out all vpaths, then set just one (default vpath) for the main build
6 # Clear the default suffixes, so that built-in rules are not used.
13 # Configuration parameters.
15 BINDIR := $(DESTDIR)@BINDIR@
16 INCLUDEDIR := $(DESTDIR)@INCLUDEDIR@
17 LIBDIR := $(DESTDIR)@LIBDIR@
18 DATADIR := $(DESTDIR)@DATADIR@
19 MANDIR := $(DESTDIR)@MANDIR@
22 CPPFLAGS := @CPPFLAGS@ -I@srcroot@include -I@objroot@include
29 RPATH_EXTRA := @RPATH_EXTRA@
32 WL_SONAME := dylib_install_name
39 TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=@objroot@lib
45 BINS := @srcroot@bin/pprof
46 CHDRS := @objroot@include/jemalloc/jemalloc@install_suffix@.h \
47 @objroot@include/jemalloc/jemalloc_defs@install_suffix@.h
48 CSRCS := @srcroot@src/jemalloc.c @srcroot@src/arena.c @srcroot@src/atomic.c \
49 @srcroot@src/base.c @srcroot@src/bitmap.c @srcroot@src/chunk.c \
50 @srcroot@src/chunk_dss.c @srcroot@src/chunk_mmap.c \
51 @srcroot@src/chunk_swap.c @srcroot@src/ckh.c @srcroot@src/ctl.c \
52 @srcroot@src/extent.c @srcroot@src/hash.c @srcroot@src/huge.c \
53 @srcroot@src/mb.c @srcroot@src/mutex.c @srcroot@src/prof.c \
54 @srcroot@src/rtree.c @srcroot@src/stats.c @srcroot@src/tcache.c
56 CSRCS += @srcroot@src/zone.c
58 STATIC_LIBS := @objroot@lib/libjemalloc@install_suffix@.a
59 DSOS := @objroot@lib/libjemalloc@install_suffix@.$(SO).$(REV) \
60 @objroot@lib/libjemalloc@install_suffix@.$(SO) \
61 @objroot@lib/libjemalloc@install_suffix@_pic.a
62 MAN3 := @objroot@doc/jemalloc@install_suffix@.3
63 DOCS_XML := @objroot@doc/jemalloc@install_suffix@.xml
64 DOCS_HTML := $(DOCS_XML:@objroot@%.xml=@srcroot@%.html)
65 DOCS_MAN3 := $(DOCS_XML:@objroot@%.xml=@srcroot@%.3)
66 DOCS := $(DOCS_HTML) $(DOCS_MAN3)
67 CTESTS := @srcroot@test/allocated.c @srcroot@test/allocm.c \
68 @srcroot@test/bitmap.c @srcroot@test/mremap.c \
69 @srcroot@test/posix_memalign.c @srcroot@test/rallocm.c \
70 @srcroot@test/thread_arena.c
72 .PHONY: all dist doc_html doc_man doc
73 .PHONY: install_bin install_include install_lib
74 .PHONY: install_html install_man install_doc install
75 .PHONY: tests check clean distclean relclean
77 .SECONDARY : $(CTESTS:@srcroot@%.c=@objroot@%.o)
80 all: $(DSOS) $(STATIC_LIBS)
84 @srcroot@doc/%.html : @objroot@doc/%.xml @srcroot@doc/stylesheet.xsl @objroot@doc/html.xsl
85 @XSLTPROC@ -o $@ @objroot@doc/html.xsl $<
87 @srcroot@doc/%.3 : @objroot@doc/%.xml @srcroot@doc/stylesheet.xsl @objroot@doc/manpages.xsl
88 @XSLTPROC@ -o $@ @objroot@doc/manpages.xsl $<
90 doc_html: $(DOCS_HTML)
95 # Include generated dependency files.
97 -include $(CSRCS:@srcroot@%.c=@objroot@%.d)
98 -include $(CSRCS:@srcroot@%.c=@objroot@%.pic.d)
99 -include $(CTESTS:@srcroot@%.c=@objroot@%.d)
101 @objroot@src/%.o: @srcroot@src/%.c
103 $(CC) $(CFLAGS) -c $(CPPFLAGS) -o $@ $<
104 @$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"
106 @objroot@src/%.pic.o: @srcroot@src/%.c
108 $(CC) $(CFLAGS) -fPIC -DPIC -c $(CPPFLAGS) -o $@ $<
109 @$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $(basename $@))))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.pic.o \2/g\" > $(@:%.o=%.d)"
111 %.$(SO) : %.$(SO).$(REV)
115 @objroot@lib/libjemalloc@install_suffix@.$(SO).$(REV) : $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
117 $(CC) -shared -Wl,-$(WL_SONAME),$(@F) $(RPATH_EXTRA:%=@RPATH@%) -o $@ $+ $(LDFLAGS) $(LIBS)
119 @objroot@lib/libjemalloc@install_suffix@_pic.a : $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
123 @objroot@lib/libjemalloc@install_suffix@.a : $(CSRCS:@srcroot@%.c=@objroot@%.o)
127 @objroot@test/%.o: @srcroot@test/%.c
129 $(CC) $(CFLAGS) -c $(CPPFLAGS) -I@objroot@test -o $@ $<
130 @$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) -I@objroot@test $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"
132 # Automatic dependency generation misses #include "*.c".
133 @objroot@test/bitmap.o : @objroot@src/bitmap.o
135 @objroot@test/%: @objroot@test/%.o \
136 @objroot@lib/libjemalloc@install_suffix@.$(SO)
139 $(CC) -o $@ $< @RPATH@@objroot@lib -L@objroot@lib -ljemalloc@install_suffix@ -lpthread
141 $(CC) -o $@ $< -L@objroot@lib -ljemalloc@install_suffix@ -lpthread
146 @for b in $(BINS); do \
147 echo "install -m 755 $$b $(BINDIR)"; \
148 install -m 755 $$b $(BINDIR); \
152 install -d $(INCLUDEDIR)/jemalloc
153 @for h in $(CHDRS); do \
154 echo "install -m 644 $$h $(INCLUDEDIR)/jemalloc"; \
155 install -m 644 $$h $(INCLUDEDIR)/jemalloc; \
158 install_lib: $(DSOS) $(STATIC_LIBS)
160 install -m 755 @objroot@lib/libjemalloc@install_suffix@.$(SO).$(REV) $(LIBDIR)
161 ln -sf libjemalloc@install_suffix@.$(SO).$(REV) $(LIBDIR)/libjemalloc@install_suffix@.$(SO)
162 install -m 755 @objroot@lib/libjemalloc@install_suffix@_pic.a $(LIBDIR)
163 install -m 755 @objroot@lib/libjemalloc@install_suffix@.a $(LIBDIR)
166 install -d $(DATADIR)/doc/jemalloc@install_suffix@
167 @for d in $(DOCS_HTML); do \
168 echo "install -m 644 $$d $(DATADIR)/doc/jemalloc@install_suffix@"; \
169 install -m 644 $$d $(DATADIR)/doc/jemalloc@install_suffix@; \
173 install -d $(MANDIR)/man3
174 @for d in $(DOCS_MAN3); do \
175 echo "install -m 644 $$d $(MANDIR)/man3"; \
176 install -m 644 $$d $(MANDIR)/man3; \
179 install_doc: install_html install_man
181 install: install_bin install_include install_lib install_doc
183 tests: $(CTESTS:@srcroot@%.c=@objroot@%)
186 @mkdir -p @objroot@test
187 @$(SHELL) -c 'total=0; \
189 echo "========================================="; \
190 for t in $(CTESTS:@srcroot@%.c=@objroot@%); do \
191 total=`expr $$total + 1`; \
192 /bin/echo -n "$${t} ... "; \
193 $(TEST_LIBRARY_PATH) $${t} @abs_srcroot@ @abs_objroot@ \
194 > @objroot@$${t}.out 2>&1; \
195 if test -e "@srcroot@$${t}.exp"; then \
196 diff -u @srcroot@$${t}.exp \
197 @objroot@$${t}.out >/dev/null 2>&1; \
199 if test "$${fail}" -eq "1" ; then \
200 failures=`expr $${failures} + 1`; \
201 echo "*** FAIL ***"; \
206 echo "*** FAIL *** (.exp file is missing)"; \
207 failures=`expr $${failures} + 1`; \
210 echo "========================================="; \
211 echo "Failures: $${failures}/$${total}"'
214 rm -f $(CSRCS:@srcroot@%.c=@objroot@%.o)
215 rm -f $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
216 rm -f $(CSRCS:@srcroot@%.c=@objroot@%.d)
217 rm -f $(CSRCS:@srcroot@%.c=@objroot@%.pic.d)
218 rm -f $(CTESTS:@srcroot@%.c=@objroot@%)
219 rm -f $(CTESTS:@srcroot@%.c=@objroot@%.o)
220 rm -f $(CTESTS:@srcroot@%.c=@objroot@%.d)
221 rm -f $(CTESTS:@srcroot@%.c=@objroot@%.out)
222 rm -f $(DSOS) $(STATIC_LIBS)
225 rm -rf @objroot@autom4te.cache
226 rm -f @objroot@config.log
227 rm -f @objroot@config.status
228 rm -f @objroot@config.stamp
230 rm -f @cfgoutputs_out@
233 rm -f @objroot@configure
234 rm -f @srcroot@VERSION
238 #===============================================================================
239 # Re-configuration rules.
241 ifeq (@enable_autogen@, 1)
242 @srcroot@configure : @srcroot@configure.ac
243 cd ./@srcroot@ && @AUTOCONF@
245 @objroot@config.status : @srcroot@configure
246 ./@objroot@config.status --recheck
248 @srcroot@config.stamp.in : @srcroot@configure.ac
249 echo stamp > @srcroot@config.stamp.in
251 @objroot@config.stamp : @cfgoutputs_in@ @cfghdrs_in@ @srcroot@configure
252 ./@objroot@config.status
255 # There must be some action in order for make to re-read Makefile when it is
257 @cfgoutputs_out@ @cfghdrs_out@ : @objroot@config.stamp