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_PLOT = @echo ' PLOT $@';
P_MAKE = @echo ' MAKE $@';
P_RUN = @echo ' RUN $<';
+P_AWK = @echo ' AWK $@';
endif
# create build directories if they don't already exist
$(BIN_DIR)/bible.txt: bible.txt
$(P_CP) cp -l $< $@
+.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)