--- a/classic-bugs/vol1/Makefile
+++ b/classic-bugs/vol1/Makefile
@@ -1,59 +1,47 @@
-JAGS ?= /usr/local/bin/jags
-TIME = /usr/bin/time
+## By default we run examples in all sub-directories.  This can be
+## overridden by the user-specified variable "EXAMPLES"
+ 
 EXAMPLES ?= blocker bones dyes equiv leuk line litters mice pump \
-	rats salm seeds oxford lsat
+	    rats salm seeds oxford lsat
+
+export JAGS ?= /usr/local/bin/jags
+
+## Expand example names to make targets
+
+bench_EX=$(addprefix bench_,$(EXAMPLES))
+check_EX=$(addprefix check_,$(EXAMPLES))
+Rcheck_EX=$(addprefix Rcheck_,$(EXAMPLES))
+clean_EX=$(addprefix clean_,$(EXAMPLES))
+distclean_EX=$(addprefix distclean_,$(EXAMPLES))
+
+## All make targets are phony: i.e. they do not correspond to file
+## names
+
+.PHONY: all bench check Rcheck clean distclean \
+	$(bench_EX) $(check_EX) $(Rcheck_EX) $(clean_EX) $(distclean_EX)
+
+## Make targets
 
 all:
+bench: $(bench_EX)
+check: $(check_EX)
+Rcheck: $(Rcheck_EX)
+clean: $(clean_EX)
+distclean: $(distclean_EX)
 
-bench:
-	@echo "Creating new benchmark results"
-	@for d in $(EXAMPLES); do \
-	    (echo $${d}; \
-	    cd $${d}; \
-	    for cmdfile in `ls test*.cmd`; do \
-	       echo "Running " $${cmdfile}; \
-	       ($(JAGS) $${cmdfile} && \
-	       Rscript -e "benchfile='bench-$${cmdfile%%.cmd}.R'; source('../../R/bench.R')";) || exit 1; \
-	    done;) || exit 1;\
-	done;
+## Dispatch targets to subdirectories. They can be run in parallel
 
-check: clean
-	@echo "Checking output against benchmark results"
-	@for d in $(EXAMPLES); do \
-	   (cd $${d} && \
-	    for cmdfile in `ls test*.cmd`; do \
-	      ($(JAGS) $${cmdfile} && \
-	       Rscript -e "source('bench-$${cmdfile%%.cmd}.R'); source('../../R/check.R')";) \
-		|| exit 1; \
-	    done;) || exit 1;\
-	done;
+$(bench_EX): 
+	$(MAKE) -f $(CURDIR)/Makefile.sub -C $(patsubst bench_%,%,$@) bench 
 
-Rcheck: 
-	@echo "Checking output against benchmark results"
-	@for d in $(EXAMPLES); do \
-	   (cd $${d} && \
-	   for cmdfile in `ls test*.R`; do \
-	      R --vanilla  < $${cmdfile} || exit 1; \
-	   done;) || exit 1;\
-	done;
+$(check_EX): 
+	$(MAKE) -f $(CURDIR)/Makefile.sub -C $(patsubst check_%,%,$@) check
 
-checktime:
-	rm -f times
-	@for d in $(EXAMPLES); do \
-	   (cd $${d} && \
-	    for cmdfile in `ls test*.cmd`; do \
-	      ($(TIME)  -f "$${d} $${cmdfile} %e %U %S" -o ../times -a \
-	      $(JAGS) $${cmdfile};) || exit 1; \
-	    done;) || exit 1;\
-	done;
+$(Rcheck_EX): 
+	$(MAKE) -f $(CURDIR)/Makefile.sub -C $(patsubst Rcheck_%,%,$@) Rcheck
 
-clean:
-	@for d in $(EXAMPLES); do \
-	   (cd $${d} && rm -f core jags.out jags.ind jags.dump \
-            CODAchain*.txt CODAindex.txt gmon.out) || exit 1; \
-	done;
+$(clean_EX): 
+	$(MAKE) -f $(CURDIR)/Makefile.sub -C $(patsubst clean_%,%,$@) clean
 
-distclean: clean
-	@for d in $(EXAMPLES); do \
-	   (cd $${d} && rm -f bench-*.R) || exit 1; \
-	done;
+$(distclean_EX): 
+	$(MAKE) -f $(CURDIR)/Makefile.sub -C $(patsubst distclean_%,%,$@) distclean