diff --git a/src/Makefile.am b/src/Makefile.am
index 0460e198b0c8fcfca88d706b659706290eeb73f3..79c9ab27e212be9a530136493788983cee234888 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,19 +47,15 @@ include $(top_srcdir)/am/global-rules
 
 include $(top_srcdir)/flymake.mk
 
+## Octave
+
 MKOCTFILE ?= mkoctfile
 OCTAVE    ?= octave
 
-bin_PROGRAMS =
-
-## Octave
-
-OCTAVE_MODULES= duneminimise.oct duneevaluate.oct
-octave_modules: $(OCTAVE_MODULES)
+OCTAVE_MODULES= duneminimise duneevaluate
 
 .PHONY:
-run-octave: octave_modules
+run-octave: $(addsuffix .oct,$(OCTAVE_MODULES))
 	$(OCTAVE) --path $(abs_builddir) --path $(abs_srcdir)
 
-include $(srcdir)/duneminimise.mk
-include $(srcdir)/duneevaluate.mk
+include $(srcdir)/octave.mk
diff --git a/src/duneevaluate.mk b/src/duneevaluate.mk
deleted file mode 100644
index 46ec6bed022c0770ca7a1472d4c6764a27d734f3..0000000000000000000000000000000000000000
--- a/src/duneevaluate.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-bin_PROGRAMS += duneminimise.oct
-
-# this would work if shared libraries were only passed via -L and -l, not directly
-#duneminimise_LINK = libtool --tag=CXX --mode link $(MKOCTFILE) $(AM_LDFLAGS) -o $@
-
-duneevaluate.oct: duneevaluate.o
-	$(MKOCTFILE) -o $@ $< -ldunecommon
-
-duneevaluate.o: duneevaluate.cc duneoctave.hh
-	$(MKOCTFILE) $(DEFS) $(AM_CPPFLAGS) -c -o $@ $<
diff --git a/src/duneminimise.mk b/src/duneminimise.mk
deleted file mode 100644
index 41a7440c2ed1127bff982f7a873e8b26669e0f5e..0000000000000000000000000000000000000000
--- a/src/duneminimise.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-bin_PROGRAMS += duneminimise.oct
-
-# this would work if shared libraries were only passed via -L and -l, not directly
-#duneminimise_LINK = libtool --tag=CXX --mode link $(MKOCTFILE) $(AM_LDFLAGS) -o $@
-
-duneminimise.oct: duneminimise.o
-	$(MKOCTFILE) -o $@ $< -ldunecommon
-
-duneminimise.o: duneminimise.cc duneoctave.hh
-	$(MKOCTFILE) $(DEFS) $(AM_CPPFLAGS) -c -o $@ $<
diff --git a/src/octave.mk b/src/octave.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f9271953d4ac85aff528d9953dec6d45b3781e92
--- /dev/null
+++ b/src/octave.mk
@@ -0,0 +1,12 @@
+define OCTFILE_template =
+$(1).oct: $(1).o
+	$$(MKOCTFILE) -o $$@ $$< -ldunecommon
+
+$(1).o: $(1).cc duneoctave.hh
+	$$(MKOCTFILE) $$(DEFS) $$(AM_CPPFLAGS) -c -o $$@ $$<
+endef
+
+$(foreach octave_module,$(OCTAVE_MODULES),$(eval $(call OCTFILE_template,$(octave_module))))
+
+CLEANFILES = $(addsuffix .oct,$(OCTAVE_MODULES)) $(addsuffix .o,$(OCTAVE_MODULES))
+