8 override DFLAGS ?= -release -inline -O -gc
9 LDFLAGS := -defaultlib=tango-$(GC) -debuglib=tango-$(GC)
10 LIBTANGO := ../lib/libtango-$(GC).a
14 P_DC = @printf ' DC %- 40s <- %s\n' '$@' '$(if \
15 $(subst 1,,$(words $^)),$< ... $(lastword $^),$<)';
16 P_PLOT = @printf ' PLOT %- 40s <- %s\n' '$@' '$(filter %.csv,$^)';
17 P_AWK = @printf ' AWK %- 40s <- %s\n' '$@' '$<';
18 P_RUN = @printf ' RUN $< $(args)\n';
19 P_MAKE = @printf ' MAKE $@\n';
20 P_RM = @printf ' RM $^\n';
21 P_LN = @printf ' LN %- 40s <- %s\n' '$@' '$<';
24 # create build directories if they don't already exist
25 dummy_mkdir := $(shell mkdir -p $O $O/bin $O/time $O/stats)
32 $(P_MAKE) $(MAKE) --no-print-directory micro-time dil-build GC=$@
38 micro-src := $(wildcard micro/*.d)
41 micro-build: $(patsubst micro/%.d,$O/bin/%,$(wildcard micro/*.d))
44 $O/bin/%: $O/micro/%.o
45 $(P_DC) $(DC) $(LDFLAGS) -of$@ $^
48 micro-time: $O/time/stats.csv
51 micro-stats: $(patsubst micro/%.d,$O/stats/%.eps,$(wildcard micro/*.d))
53 # special command line arguments for 'shootout_binarytrees' micro benchmark
54 $O/time/shootout_binarytrees.t.csv $O/time/shootout_binarytrees.s.csv \
55 $O/stats/shootout_binarytrees.c.csv \
56 $O/stats/shootout_binarytrees.a.csv: \
59 # special command line arguments for 'split' micro benchmark
60 $O/time/split.t.csv $O/time/split.s.csv \
61 $O/stats/split.c.csv $O/stats/split.a.csv: \
62 override args := micro/bible.txt
64 # special command line arguments for 'voronoi' micro benchmark
65 $O/time/voronoi.t.csv $O/time/voronoi.s.csv \
66 $O/stats/voronoi.c.csv $O/voronoi/split.a.csv: \
67 override args := -n 30000
73 DIL_SRC = $(wildcard dil/src/*.d dil/src/cmd/*.d dil/src/util/*.d \
74 dil/src/dil/*.d dil/src/dil/*/*.d)
77 dil-nop-stats: $O/stats/dil-nop.eps
81 $O/bin/dil: override DFLAGS += -Idil/src
82 $O/bin/dil: $(patsubst %.d,$O/%.o,$(DIL_SRC)) $(LIBTANGO)
83 $(P_DC) $(DC) $(LDFLAGS) -L-lmpfr -L-lgmp -of$@ $^
85 $O/bin/dil-nop: $O/bin/dil
86 @$(P_LN) $(LN) -sf $(<F) $@
94 $(P_DC) $(DC) -c $(DFLAGS) -of$@ $^
97 .PRECIOUS: $O/time/%.t.csv
99 .PHONY: $(patsubst micro/%.d,$O/bin/%,$(wildcard micro/*.d))
101 $O/time/%.t.csv: $O/bin/%
102 $P echo -n ' RUN $* $(args) > $@ ($I)'
104 $P for i in `seq $I`; do \
106 time -f%e -a -o $@ ./$< $(args); \
109 .PRECIOUS: $O/time/stats.csv
110 $O/time/stats.csv: $(patsubst micro/%.d,$O/time/%.t.csv,$(micro-src))
113 (echo -n `basename $$t`,; ./stats.py < $$t) >> $@; \
114 echo " STATS `tail -n1 $@` >> $@"; \
117 .PRECIOUS: $O/stats/%.c.csv $O/stats/%.a.csv
118 $O/stats/%.c.csv $O/stats/%.a.csv: $O/bin/%
119 $(P_RUN) D_GC_STATS=1 ./$< $(args)
120 $P mv gc-collections.csv $O/stats/$*.c.csv
121 $P mv gc-mallocs.csv $O/stats/$*.a.csv
123 .PRECIOUS: $O/stats/%.h.csv
124 $O/stats/%.h.csv: $O/stats/%.a.csv hist.awk
125 $(P_AWK) awk -F, -f $(lastword $^) $< > $@
127 .PRECIOUS: $O/stats/%.tics
128 $O/stats/%.tics: $O/stats/%.h.csv tics.awk
129 $(P_AWK) awk -F, -f $(lastword $^) $< > $@
131 $O/stats/%.eps: $O/stats/%.c.csv $O/stats/%.a.csv $O/stats/%.h.csv \
132 $O/stats/%.tics plot.gpi
133 $(P_PLOT) sed "s|@@PRG@@|$(*F)|g; s|@@COL@@|$(GC)|g; \
134 s|@@INC@@|$(word 1,$^)|g; s|@@INA@@|$(word 2,$^)|g; \
135 s|@@INH@@|$(word 3,$^)|g; s|@@OUT@@|$@|g; \
136 s|@@TICS@@|$(shell cat $(word 4,$^))|g" $(word 5,$^) \
144 clean-all: clean-cdgc clean-basic
146 $(P_MAKE) $(MAKE) --no-print-directory clean GC=cdgc
148 $(P_MAKE) $(MAKE) --no-print-directory clean GC=basic