9 override DFLAGS ?= -release -inline -O -gc
10 LDFLAGS := -defaultlib=tango-$(GC) -debuglib=tango-$(GC)
11 LIBTANGO := ../lib/libtango-$(GC).a
15 P_DC = @printf ' DC %- 40s <- %s\n' '$@' '$(if \
16 $(subst 1,,$(words $^)),$< ... $(lastword $^),$<)';
17 P_PLOT = @printf ' PLOT %- 40s <- %s\n' '$@' '$(notdir $(filter %.csv,$^))';
18 P_AWK = @printf ' AWK %- 40s <- %s\n' '$@' '$<';
19 P_RUN = @printf ' RUN $< $(args)\n';
20 P_MAKE = @printf ' MAKE $@\n';
21 P_RM = @printf ' RM $^\n';
22 P_LN = @printf ' LN %- 40s <- %s\n' '$@' '$<';
25 # create build directories if they don't already exist
26 dummy_mkdir := $(shell mkdir -p $O $O/bin $O/time $O/stats)
29 ########################################################
30 # general rules that doesn't depend on the GC variable #
31 ########################################################
44 micro-time: $B/time.eps $B/time.svg
45 $B/time.%: $(patsubst micro/%.d,$B/time-%.csv,$(wildcard micro/*.d)) \
46 time-plot.tpl-gpi time-plot.sh templite.py
47 $(P_PLOT) ./time-plot.sh $* $@ $(filter %.csv,$^)
49 .PRECIOUS: $B/time-%.csv
50 $B/time-%.csv: $B/basic/time/%.csv | basic cdgc
52 $P for t in basic cdgc; do \
53 (echo -n $$t,; ./stats.py < $B/$$t/time/$*.csv) >> $@; \
54 echo " STATS `tail -n1 $@` >> $@"; \
59 $(P_MAKE) $(MAKE) --no-print-directory micro-gc-build dil-gc-build GC=$@
62 .PHONY: clean-all clean-cdgc clean-basic
63 clean-all: clean-cdgc clean-basic
65 $(P_MAKE) $(MAKE) --no-print-directory clean GC=cdgc
67 $(P_MAKE) $(MAKE) --no-print-directory clean GC=basic
70 #########################################
71 # rules that depends on the GC variable #
72 #########################################
77 micro-src := $(wildcard micro/*.d)
79 .PHONY: micro-gc-build
80 micro-gc-build: $(patsubst micro/%.d,$O/bin/%,$(wildcard micro/*.d))
83 $O/bin/%: $O/micro/%.o $(LIBTANGO)
84 $(P_DC) $(DC) $(LDFLAGS) -of$@ $^
87 micro-gc-time: $(patsubst micro/%.d,$O/time/%.csv,$(wildcard micro/*.d))
89 .PHONY: micro-gc-stats
90 micro-gc-stats: $(patsubst micro/%.d,$O/stats/%.eps,$(wildcard micro/*.d))
92 # special command line arguments for 'shootout_binarytrees' micro benchmark
93 $O/time/shootout_binarytrees.csv $O/stats/shootout_binarytrees.c.csv \
94 $O/stats/shootout_binarytrees.a.csv: \
97 # special command line arguments for 'split' micro benchmark
98 $O/time/split.csv $O/stats/split.c.csv $O/stats/split.a.csv: \
99 override args := micro/bible.txt 2
101 # special command line arguments for 'voronoi' micro benchmark
102 $O/time/voronoi.csv $O/stats/voronoi.c.csv $O/voronoi/split.a.csv: \
103 override args := -n 30000
109 DIL_SRC = $(wildcard dil/src/*.d dil/src/cmd/*.d dil/src/util/*.d \
110 dil/src/dil/*.d dil/src/dil/*/*.d)
113 dil-gc-build: $O/bin/dil
114 $O/bin/dil: override DFLAGS += -Idil/src
115 $O/bin/dil: $(patsubst %.d,$O/%.o,$(DIL_SRC)) $(LIBTANGO)
116 $(P_DC) $(DC) $(LDFLAGS) -L-lmpfr -L-lgmp -of$@ $^
119 dil-gc-time: $O/time/dil.csv
127 $(P_DC) $(DC) -c $(DFLAGS) -of$@ $^
130 .PRECIOUS: $O/time/%.csv
132 .PHONY: $(patsubst micro/%.d,$O/bin/%,$(wildcard micro/*.d))
134 $O/time/%.csv: $O/bin/%
135 $P echo -n ' RUN $* $(args) > $@ ($I)'
137 $P for i in `seq $I`; do \
139 $(TIME) -f%e -a -o $@ ./$< $(args); \
142 .PRECIOUS: $O/stats/%.c.csv $O/stats/%.a.csv
143 $O/stats/%.c.csv $O/stats/%.a.csv: $O/bin/%
144 $(P_RUN) D_GC_STATS=1 ./$< $(args)
145 $P mv gc-collections.csv $O/stats/$*.c.csv
146 $P mv gc-mallocs.csv $O/stats/$*.a.csv
148 .PRECIOUS: $O/stats/%.h.csv
149 $O/stats/%.h.csv: $O/stats/%.a.csv hist.awk
150 $(P_AWK) awk -F, -f $(lastword $^) $< > $@
152 .PRECIOUS: $O/stats/%.tics
153 $O/stats/%.tics: $O/stats/%.h.csv tics.awk
154 $(P_AWK) awk -F, -f $(lastword $^) $< > $@
156 $O/stats/%.eps: $O/stats/%.c.csv $O/stats/%.a.csv $O/stats/%.h.csv \
157 $O/stats/%.tics plot.gpi
158 $(P_PLOT) sed "s|@@PRG@@|$(*F)|g; s|@@COL@@|$(GC)|g; \
159 s|@@INC@@|$(word 1,$^)|g; s|@@INA@@|$(word 2,$^)|g; \
160 s|@@INH@@|$(word 3,$^)|g; s|@@OUT@@|$@|g; \
161 s|@@TICS@@|$(shell cat $(word 4,$^))|g" $(word 5,$^) \