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