programs := $(addprefix $(BIN_DIR)/,$(sources:.d=))
stat_c := $(addprefix $(STAT_DIR)/,$(addsuffix .c.csv,$(sources:.d=)))
stat_a := $(addprefix $(STAT_DIR)/,$(addsuffix .a.csv,$(sources:.d=)))
-stat := $(stat_c) $(stat_a)
+stat_h := $(addprefix $(STAT_DIR)/,$(addsuffix .h.csv,$(sources:.d=)))
+stat := $(stat_c) $(stat_a) $(stat_h)
graphs_c := $(addprefix $(PLOT_DIR)/,$(addsuffix .c.eps,$(sources:.d=)))
graphs := $(graphs_c)
+
ifndef V
P = @
P_DC = @echo ' DC $@';
P_LD = @echo ' LD $@';
-P_CP = @echo ' CP $@';
P_PLOT = @echo ' PLOT $@';
P_MAKE = @echo ' MAKE $@';
-P_RUN = @echo ' RUN $<';
+P_RUN = @echo ' RUN $< $(arg1) $(arg2) $(arg3)';
+P_AWK = @echo ' AWK $@';
endif
# create build directories if they don't already exist
$(BIN_DIR)/%: $(BIN_DIR)/%.o
$(P_LD) $(DC) $(DFLAGS) -of$@ $^
-.INTERMEDIATE: $(BIN_DIR)/%.o
$(BIN_DIR)/%.o: %.d
$(P_DC) $(DC) $(DFLAGS) -c -of$@ $<
.PRECIOUS: $(STAT_DIR)/%.c.csv $(STAT_DIR)/%.a.csv
$(STAT_DIR)/%.c.csv $(STAT_DIR)/%.a.csv: $(BIN_DIR)/%
- $(P_RUN) ./$<
+ $(P_RUN) ./$< $(args)
$P mv gc-collections.csv $(STAT_DIR)/$*.c.csv
$P mv gc-mallocs.csv $(STAT_DIR)/$*.a.csv
-$(STAT_DIR)/split.c.csv $(STAT_DIR)/split.a.csv: $(BIN_DIR)/bible.txt
-
-$(BIN_DIR)/bible.txt: bible.txt
- $(P_CP) cp -l $< $@
+# special command line arguments for benchmarks
+$(STAT_DIR)/split.c.csv $(STAT_DIR)/split.a.csv: override args := bible.txt
+.PRECIOUS: $(STAT_DIR)/%.h.csv
+$(STAT_DIR)/%.h.csv: $(STAT_DIR)/%.a.csv
+ $(P_AWK) awk -F, 'BEGIN { print "Size,Count" } NR > 1 { a[$$3]++ } \
+ END { for (i in a) print i "," a[i] }' $< | sort > $@
.PHONY: plot
plot: $(graphs)