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@
12
13# Configuration parameters.
14DESTDIR =
15BINDIR := $(DESTDIR)@BINDIR@
16INCLUDEDIR := $(DESTDIR)@INCLUDEDIR@
17LIBDIR := $(DESTDIR)@LIBDIR@
18DATADIR := $(DESTDIR)@DATADIR@
19MANDIR := $(DESTDIR)@MANDIR@
20srcroot := @srcroot@
21objroot := @objroot@
22abs_srcroot := @abs_srcroot@
23abs_objroot := @abs_objroot@
24
25# Build parameters.
26CPPFLAGS := @CPPFLAGS@ -I$(srcroot)include -I$(objroot)include
27CFLAGS := @CFLAGS@
28LDFLAGS := @LDFLAGS@
29EXTRA_LDFLAGS := @EXTRA_LDFLAGS@
30LIBS := @LIBS@
31RPATH_EXTRA := @RPATH_EXTRA@
32SO := @so@
33IMPORTLIB := @importlib@
34O := @o@
35A := @a@
36EXE := @exe@
37LIBPREFIX := @libprefix@
38REV := @rev@
39install_suffix := @install_suffix@
40ABI := @abi@
41XSLTPROC := @XSLTPROC@
42AUTOCONF := @AUTOCONF@
43_RPATH = @RPATH@
44RPATH = $(if $(1),$(call _RPATH,$(1)))
45cfghdrs_in := @cfghdrs_in@
46cfghdrs_out := @cfghdrs_out@
47cfgoutputs_in := @cfgoutputs_in@
48cfgoutputs_out := @cfgoutputs_out@
49enable_autogen := @enable_autogen@
50enable_code_coverage := @enable_code_coverage@
51enable_valgrind := @enable_valgrind@
52enable_zone_allocator := @enable_zone_allocator@
53DSO_LDFLAGS = @DSO_LDFLAGS@
54SOREV = @SOREV@
55PIC_CFLAGS = @PIC_CFLAGS@
56CTARGET = @CTARGET@
57LDTARGET = @LDTARGET@
58MKLIB = @MKLIB@
59AR = @AR@
60ARFLAGS = @ARFLAGS@
61CC_MM = @CC_MM@
62
63ifeq (macho, $(ABI))
64TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH="$(objroot)lib"
65else
66ifeq (pecoff, $(ABI))
67TEST_LIBRARY_PATH := PATH="$(PATH):$(objroot)lib"
68else
69TEST_LIBRARY_PATH :=
70endif
71endif
72
73LIBJEMALLOC := $(LIBPREFIX)jemalloc$(install_suffix)
74
75# Lists of files.
76BINS := $(srcroot)bin/pprof $(objroot)bin/jemalloc.sh
77C_HDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h
78C_SRCS := $(srcroot)src/jemalloc.c $(srcroot)src/arena.c \
79	$(srcroot)src/atomic.c $(srcroot)src/base.c $(srcroot)src/bitmap.c \
80	$(srcroot)src/chunk.c $(srcroot)src/chunk_dss.c \
81	$(srcroot)src/chunk_mmap.c $(srcroot)src/ckh.c $(srcroot)src/ctl.c \
82	$(srcroot)src/extent.c $(srcroot)src/hash.c $(srcroot)src/huge.c \
83	$(srcroot)src/mb.c $(srcroot)src/mutex.c $(srcroot)src/prof.c \
84	$(srcroot)src/quarantine.c $(srcroot)src/rtree.c $(srcroot)src/stats.c \
85	$(srcroot)src/tcache.c $(srcroot)src/util.c $(srcroot)src/tsd.c
86ifeq ($(enable_valgrind), 1)
87C_SRCS += $(srcroot)src/valgrind.c
88endif
89ifeq ($(enable_zone_allocator), 1)
90C_SRCS += $(srcroot)src/zone.c
91endif
92ifeq ($(IMPORTLIB),$(SO))
93STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A)
94endif
95ifdef PIC_CFLAGS
96STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_pic.$(A)
97else
98STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_s.$(A)
99endif
100DSOS := $(objroot)lib/$(LIBJEMALLOC).$(SOREV)
101ifneq ($(SOREV),$(SO))
102DSOS += $(objroot)lib/$(LIBJEMALLOC).$(SO)
103endif
104MAN3 := $(objroot)doc/jemalloc$(install_suffix).3
105DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml
106DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.html)
107DOCS_MAN3 := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.3)
108DOCS := $(DOCS_HTML) $(DOCS_MAN3)
109C_TESTLIB_SRCS := $(srcroot)test/src/math.c $(srcroot)test/src/mtx.c \
110	$(srcroot)test/src/SFMT.c $(srcroot)test/src/test.c \
111	$(srcroot)test/src/thd.c
112C_UTIL_INTEGRATION_SRCS := $(srcroot)src/util.c
113TESTS_UNIT := $(srcroot)test/unit/bitmap.c \
114	$(srcroot)test/unit/ckh.c \
115	$(srcroot)test/unit/hash.c \
116	$(srcroot)test/unit/junk.c \
117	$(srcroot)test/unit/mallctl.c \
118	$(srcroot)test/unit/math.c \
119	$(srcroot)test/unit/mq.c \
120	$(srcroot)test/unit/mtx.c \
121	$(srcroot)test/unit/prof_accum.c \
122	$(srcroot)test/unit/prof_gdump.c \
123	$(srcroot)test/unit/prof_idump.c \
124	$(srcroot)test/unit/ql.c \
125	$(srcroot)test/unit/qr.c \
126	$(srcroot)test/unit/quarantine.c \
127	$(srcroot)test/unit/rb.c \
128	$(srcroot)test/unit/rtree.c \
129	$(srcroot)test/unit/SFMT.c \
130	$(srcroot)test/unit/stats.c \
131	$(srcroot)test/unit/tsd.c \
132	$(srcroot)test/unit/util.c \
133	$(srcroot)test/unit/zero.c
134TESTS_UNIT_AUX := $(srcroot)test/unit/prof_accum_a.c \
135	$(srcroot)test/unit/prof_accum_b.c
136TESTS_INTEGRATION := $(srcroot)test/integration/aligned_alloc.c \
137	$(srcroot)test/integration/allocated.c \
138	$(srcroot)test/integration/mallocx.c \
139	$(srcroot)test/integration/MALLOCX_ARENA.c \
140	$(srcroot)test/integration/posix_memalign.c \
141	$(srcroot)test/integration/rallocx.c \
142	$(srcroot)test/integration/thread_arena.c \
143	$(srcroot)test/integration/thread_tcache_enabled.c \
144	$(srcroot)test/integration/xallocx.c \
145	$(srcroot)test/integration/chunk.c
146TESTS_STRESS :=
147TESTS := $(TESTS_UNIT) $(TESTS_INTEGRATION) $(TESTS_STRESS)
148
149C_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.$(O))
150C_PIC_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.pic.$(O))
151C_JET_OBJS := $(C_SRCS:$(srcroot)%.c=$(objroot)%.jet.$(O))
152C_TESTLIB_UNIT_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.unit.$(O))
153C_TESTLIB_INTEGRATION_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.integration.$(O))
154C_UTIL_INTEGRATION_OBJS := $(C_UTIL_INTEGRATION_SRCS:$(srcroot)%.c=$(objroot)%.integration.$(O))
155C_TESTLIB_STRESS_OBJS := $(C_TESTLIB_SRCS:$(srcroot)%.c=$(objroot)%.stress.$(O))
156C_TESTLIB_OBJS := $(C_TESTLIB_UNIT_OBJS) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(C_TESTLIB_STRESS_OBJS)
157
158TESTS_UNIT_OBJS := $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%.$(O))
159TESTS_UNIT_AUX_OBJS := $(TESTS_UNIT_AUX:$(srcroot)%.c=$(objroot)%.$(O))
160TESTS_INTEGRATION_OBJS := $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%.$(O))
161TESTS_STRESS_OBJS := $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%.$(O))
162TESTS_OBJS := $(TESTS_UNIT_OBJS) $(TESTS_UNIT_AUX_OBJS) $(TESTS_INTEGRATION_OBJS) $(TESTS_STRESS_OBJS)
163
164.PHONY: all dist build_doc_html build_doc_man build_doc
165.PHONY: install_bin install_include install_lib
166.PHONY: install_doc_html install_doc_man install_doc install
167.PHONY: tests check clean distclean relclean
168
169.SECONDARY : $(TESTS_OBJS)
170
171# Default target.
172all: build_lib
173
174dist: build_doc
175
176$(srcroot)doc/%.html : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/html.xsl
177	$(XSLTPROC) -o $@ $(objroot)doc/html.xsl $<
178
179$(srcroot)doc/%.3 : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/manpages.xsl
180	$(XSLTPROC) -o $@ $(objroot)doc/manpages.xsl $<
181
182build_doc_html: $(DOCS_HTML)
183build_doc_man: $(DOCS_MAN3)
184build_doc: $(DOCS)
185
186#
187# Include generated dependency files.
188#
189ifdef CC_MM
190-include $(C_OBJS:%.$(O)=%.d)
191-include $(C_PIC_OBJS:%.$(O)=%.d)
192-include $(C_JET_OBJS:%.$(O)=%.d)
193-include $(C_TESTLIB_OBJS:%.$(O)=%.d)
194-include $(TESTS_OBJS:%.$(O)=%.d)
195endif
196
197$(C_OBJS): $(objroot)src/%.$(O): $(srcroot)src/%.c
198$(C_PIC_OBJS): $(objroot)src/%.pic.$(O): $(srcroot)src/%.c
199$(C_PIC_OBJS): CFLAGS += $(PIC_CFLAGS)
200$(C_JET_OBJS): $(objroot)src/%.jet.$(O): $(srcroot)src/%.c
201$(C_JET_OBJS): CFLAGS += -DJEMALLOC_JET
202$(C_TESTLIB_UNIT_OBJS): $(objroot)test/src/%.unit.$(O): $(srcroot)test/src/%.c
203$(C_TESTLIB_UNIT_OBJS): CPPFLAGS += -DJEMALLOC_UNIT_TEST
204$(C_TESTLIB_INTEGRATION_OBJS): $(objroot)test/src/%.integration.$(O): $(srcroot)test/src/%.c
205$(C_TESTLIB_INTEGRATION_OBJS): CPPFLAGS += -DJEMALLOC_INTEGRATION_TEST
206$(C_UTIL_INTEGRATION_OBJS): $(objroot)src/%.integration.$(O): $(srcroot)src/%.c
207$(C_TESTLIB_STRESS_OBJS): $(objroot)test/src/%.stress.$(O): $(srcroot)test/src/%.c
208$(C_TESTLIB_STRESS_OBJS): CPPFLAGS += -DJEMALLOC_STRESS_TEST -DJEMALLOC_STRESS_TESTLIB
209$(C_TESTLIB_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include
210$(TESTS_UNIT_OBJS): CPPFLAGS += -DJEMALLOC_UNIT_TEST
211$(TESTS_UNIT_AUX_OBJS): CPPFLAGS += -DJEMALLOC_UNIT_TEST
212define make-unit-link-dep
213$(1): TESTS_UNIT_LINK_OBJS += $(2)
214$(1): $(2)
215endef
216$(foreach test, $(TESTS_UNIT:$(srcroot)test/unit/%.c=$(objroot)test/unit/%$(EXE)), $(eval $(call make-unit-link-dep,$(test),$(filter $(test:%$(EXE)=%_a.$(O)) $(test:%$(EXE)=%_b.$(O)),$(TESTS_UNIT_AUX_OBJS)))))
217$(TESTS_INTEGRATION_OBJS): CPPFLAGS += -DJEMALLOC_INTEGRATION_TEST
218$(TESTS_STRESS_OBJS): CPPFLAGS += -DJEMALLOC_STRESS_TEST
219$(TESTS_OBJS): $(objroot)test/%.$(O): $(srcroot)test/%.c
220$(TESTS_OBJS): CPPFLAGS += -I$(srcroot)test/include -I$(objroot)test/include
221ifneq ($(IMPORTLIB),$(SO))
222$(C_OBJS) $(C_JET_OBJS): CPPFLAGS += -DDLLEXPORT
223endif
224
225ifndef CC_MM
226# Dependencies.
227HEADER_DIRS = $(srcroot)include/jemalloc/internal \
228	$(objroot)include/jemalloc $(objroot)include/jemalloc/internal
229HEADERS = $(wildcard $(foreach dir,$(HEADER_DIRS),$(dir)/*.h))
230$(C_OBJS) $(C_PIC_OBJS) $(C_JET_OBJS) $(C_TESTLIB_OBJS) $(TESTS_OBJS): $(HEADERS)
231$(TESTS_OBJS): $(objroot)test/include/test/jemalloc_test.h
232endif
233
234$(C_OBJS) $(C_PIC_OBJS) $(C_JET_OBJS) $(C_TESTLIB_OBJS) $(TESTS_OBJS): %.$(O):
235	@mkdir -p $(@D)
236	$(CC) $(CFLAGS) -c $(CPPFLAGS) $(CTARGET) $<
237ifdef CC_MM
238	@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $<
239endif
240
241ifneq ($(SOREV),$(SO))
242%.$(SO) : %.$(SOREV)
243	@mkdir -p $(@D)
244	ln -sf $(<F) $@
245endif
246
247$(objroot)lib/$(LIBJEMALLOC).$(SOREV) : $(if $(PIC_CFLAGS),$(C_PIC_OBJS),$(C_OBJS))
248	@mkdir -p $(@D)
249	$(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) $(LDTARGET) $+ $(LDFLAGS) $(LIBS) $(EXTRA_LDFLAGS)
250
251$(objroot)lib/$(LIBJEMALLOC)_pic.$(A) : $(C_PIC_OBJS)
252$(objroot)lib/$(LIBJEMALLOC).$(A) : $(C_OBJS)
253$(objroot)lib/$(LIBJEMALLOC)_s.$(A) : $(C_OBJS)
254
255$(STATIC_LIBS):
256	@mkdir -p $(@D)
257	$(AR) $(ARFLAGS)@AROUT@ $+
258
259$(objroot)test/unit/%$(EXE): $(objroot)test/unit/%.$(O) $(TESTS_UNIT_LINK_OBJS) $(C_JET_OBJS) $(C_TESTLIB_UNIT_OBJS)
260	@mkdir -p $(@D)
261	$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LDFLAGS) $(filter-out -lm,$(LIBS)) -lm $(EXTRA_LDFLAGS)
262
263$(objroot)test/integration/%$(EXE): $(objroot)test/integration/%.$(O) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB)
264	@mkdir -p $(@D)
265	$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(filter -lpthread,$(LIBS))) -lm $(EXTRA_LDFLAGS)
266
267$(objroot)test/stress/%$(EXE): $(objroot)test/stress/%.$(O) $(C_JET_OBJS) $(C_TESTLIB_STRESS_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB)
268	@mkdir -p $(@D)
269	$(CC) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB) $(LDFLAGS) $(filter-out -lm,$(LIBS)) -lm $(EXTRA_LDFLAGS)
270
271build_lib_shared: $(DSOS)
272build_lib_static: $(STATIC_LIBS)
273build_lib: build_lib_shared build_lib_static
274
275install_bin:
276	install -d $(BINDIR)
277	@for b in $(BINS); do \
278	echo "install -m 755 $$b $(BINDIR)"; \
279	install -m 755 $$b $(BINDIR); \
280done
281
282install_include:
283	install -d $(INCLUDEDIR)/jemalloc
284	@for h in $(C_HDRS); do \
285	echo "install -m 644 $$h $(INCLUDEDIR)/jemalloc"; \
286	install -m 644 $$h $(INCLUDEDIR)/jemalloc; \
287done
288
289install_lib_shared: $(DSOS)
290	install -d $(LIBDIR)
291	install -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SOREV) $(LIBDIR)
292ifneq ($(SOREV),$(SO))
293	ln -sf $(LIBJEMALLOC).$(SOREV) $(LIBDIR)/$(LIBJEMALLOC).$(SO)
294endif
295
296install_lib_static: $(STATIC_LIBS)
297	install -d $(LIBDIR)
298	@for l in $(STATIC_LIBS); do \
299	echo "install -m 755 $$l $(LIBDIR)"; \
300	install -m 755 $$l $(LIBDIR); \
301done
302
303install_lib: install_lib_shared install_lib_static
304
305install_doc_html:
306	install -d $(DATADIR)/doc/jemalloc$(install_suffix)
307	@for d in $(DOCS_HTML); do \
308	echo "install -m 644 $$d $(DATADIR)/doc/jemalloc$(install_suffix)"; \
309	install -m 644 $$d $(DATADIR)/doc/jemalloc$(install_suffix); \
310done
311
312install_doc_man:
313	install -d $(MANDIR)/man3
314	@for d in $(DOCS_MAN3); do \
315	echo "install -m 644 $$d $(MANDIR)/man3"; \
316	install -m 644 $$d $(MANDIR)/man3; \
317done
318
319install_doc: install_doc_html install_doc_man
320
321install: install_bin install_include install_lib install_doc
322
323tests_unit: $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%$(EXE))
324tests_integration: $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%$(EXE))
325tests_stress: $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%$(EXE))
326tests: tests_unit tests_integration tests_stress
327
328check_unit_dir:
329	@mkdir -p $(objroot)test/unit
330check_integration_dir:
331	@mkdir -p $(objroot)test/integration
332check_stress_dir:
333	@mkdir -p $(objroot)test/stress
334check_dir: check_unit_dir check_integration_dir check_stress_dir
335
336check_unit: tests_unit check_unit_dir
337	$(SHELL) $(objroot)test/test.sh $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%)
338check_integration: tests_integration check_integration_dir
339	$(SHELL) $(objroot)test/test.sh $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%)
340check_stress: tests_stress check_stress_dir
341	$(SHELL) $(objroot)test/test.sh $(TESTS_STRESS:$(srcroot)%.c=$(objroot)%)
342check: tests check_dir
343	$(SHELL) $(objroot)test/test.sh $(TESTS:$(srcroot)%.c=$(objroot)%)
344
345ifeq ($(enable_code_coverage), 1)
346coverage_unit: check_unit
347	$(SHELL) $(srcroot)coverage.sh $(srcroot)src jet $(C_JET_OBJS)
348	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/src unit $(C_TESTLIB_UNIT_OBJS)
349	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/unit unit $(TESTS_UNIT_OBJS)
350
351coverage_integration: check_integration
352	$(SHELL) $(srcroot)coverage.sh $(srcroot)src pic $(C_PIC_OBJS)
353	$(SHELL) $(srcroot)coverage.sh $(srcroot)src integration $(C_UTIL_INTEGRATION_OBJS)
354	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/src integration $(C_TESTLIB_INTEGRATION_OBJS)
355	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/integration integration $(TESTS_INTEGRATION_OBJS)
356
357coverage_stress: check_stress
358	$(SHELL) $(srcroot)coverage.sh $(srcroot)src pic $(C_PIC_OBJS)
359	$(SHELL) $(srcroot)coverage.sh $(srcroot)src jet $(C_JET_OBJS)
360	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/src stress $(C_TESTLIB_STRESS_OBJS)
361	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/stress stress $(TESTS_STRESS_OBJS)
362
363coverage: check
364	$(SHELL) $(srcroot)coverage.sh $(srcroot)src pic $(C_PIC_OBJS)
365	$(SHELL) $(srcroot)coverage.sh $(srcroot)src jet $(C_JET_OBJS)
366	$(SHELL) $(srcroot)coverage.sh $(srcroot)src integration $(C_UTIL_INTEGRATION_OBJS)
367	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/src unit $(C_TESTLIB_UNIT_OBJS)
368	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/src integration $(C_TESTLIB_INTEGRATION_OBJS)
369	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/src stress $(C_TESTLIB_STRESS_OBJS)
370	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/unit unit $(TESTS_UNIT_OBJS) $(TESTS_UNIT_AUX_OBJS)
371	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/integration integration $(TESTS_INTEGRATION_OBJS)
372	$(SHELL) $(srcroot)coverage.sh $(srcroot)test/stress integration $(TESTS_STRESS_OBJS)
373endif
374
375clean:
376	rm -f $(C_OBJS)
377	rm -f $(C_PIC_OBJS)
378	rm -f $(C_JET_OBJS)
379	rm -f $(C_TESTLIB_OBJS)
380	rm -f $(C_OBJS:%.$(O)=%.d)
381	rm -f $(C_OBJS:%.$(O)=%.gcda)
382	rm -f $(C_OBJS:%.$(O)=%.gcno)
383	rm -f $(C_PIC_OBJS:%.$(O)=%.d)
384	rm -f $(C_PIC_OBJS:%.$(O)=%.gcda)
385	rm -f $(C_PIC_OBJS:%.$(O)=%.gcno)
386	rm -f $(C_JET_OBJS:%.$(O)=%.d)
387	rm -f $(C_JET_OBJS:%.$(O)=%.gcda)
388	rm -f $(C_JET_OBJS:%.$(O)=%.gcno)
389	rm -f $(C_TESTLIB_OBJS:%.$(O)=%.d)
390	rm -f $(C_TESTLIB_OBJS:%.$(O)=%.gcda)
391	rm -f $(C_TESTLIB_OBJS:%.$(O)=%.gcno)
392	rm -f $(TESTS_OBJS:%.$(O)=%$(EXE))
393	rm -f $(TESTS_OBJS)
394	rm -f $(TESTS_OBJS:%.$(O)=%.d)
395	rm -f $(TESTS_OBJS:%.$(O)=%.gcda)
396	rm -f $(TESTS_OBJS:%.$(O)=%.gcno)
397	rm -f $(TESTS_OBJS:%.$(O)=%.out)
398	rm -f $(DSOS) $(STATIC_LIBS)
399	rm -f $(objroot)*.gcov.*
400
401distclean: clean
402	rm -rf $(objroot)autom4te.cache
403	rm -f $(objroot)bin/jemalloc.sh
404	rm -f $(objroot)config.log
405	rm -f $(objroot)config.status
406	rm -f $(objroot)config.stamp
407	rm -f $(cfghdrs_out)
408	rm -f $(cfgoutputs_out)
409
410relclean: distclean
411	rm -f $(objroot)configure
412	rm -f $(srcroot)VERSION
413	rm -f $(DOCS_HTML)
414	rm -f $(DOCS_MAN3)
415
416#===============================================================================
417# Re-configuration rules.
418
419ifeq ($(enable_autogen), 1)
420$(srcroot)configure : $(srcroot)configure.ac
421	cd ./$(srcroot) && $(AUTOCONF)
422
423$(objroot)config.status : $(srcroot)configure
424	./$(objroot)config.status --recheck
425
426$(srcroot)config.stamp.in : $(srcroot)configure.ac
427	echo stamp > $(srcroot)config.stamp.in
428
429$(objroot)config.stamp : $(cfgoutputs_in) $(cfghdrs_in) $(srcroot)configure
430	./$(objroot)config.status
431	@touch $@
432
433# There must be some action in order for make to re-read Makefile when it is
434# out of date.
435$(cfgoutputs_out) $(cfghdrs_out) : $(objroot)config.stamp
436	@true
437endif
438