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