diff --git a/Makefile.am b/Makefile.am
index afb2a0010e4a862c10139341c8c5418cec01189d..054df8d2852758593f733d092362c8aaf2ebdf11 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -62,6 +62,46 @@ dist-hook:
 	find $(distdir)/DEMO \( -name ellipt -o -name heat -o -name nonlin \) -exec /bin/rm -f {} \;
 	find $(distdir)/DEMO -name Makefile -exec /bin/rm -f {} \;
 
+#
+# Generate all ALBERTA Makefile.am's form a template. I was just fed
+# up with changing 24 different files which looked essentially the
+# same.
+#
+generate-alberta-automakefiles:
+	for DEBUG in 0 1; do \
+	  for EL_INDEX in 0 1; do \
+	    for DIM in 1 2 3; do \
+	      DIM_OF_WORLD=$${DIM}; while test $${DIM_OF_WORLD} -le 3; do \
+		if test $$EL_INDEX -eq 0; then \
+		  LIBCODE=$${DIM}$${DIM_OF_WORLD}_$${DEBUG} ; \
+		else \
+		  LIBCODE=$${DIM}$${DIM_OF_WORLD}_$${DEBUG}1 ; \
+		fi; \
+		if test $$DEBUG -eq 0; then \
+		  EFLAGS=OPTIMISE ; \
+		else \
+		  EFLAGS=DEBUG ; \
+		fi ; \
+		sed -e "s/%DIM%/$$DIM/g" Makefile.am.template -e "s/%DIM_OF_WORLD%/$$DIM_OF_WORLD/g" -e "s/%DEBUG%/$$DEBUG/g" -e "s/%EL_INDEX%/$$EL_INDEX/g" -e "s/%LIBCODE%/$$LIBCODE/g" -e "s/%EFLAGS%/$$EFLAGS/g" > ALBERTA/src/ALBERTA$$LIBCODE/Makefile.am; \
+		DIM_OF_WORLD=$$(( $$DIM_OF_WORLD + 1 )) ; \
+	      done; \
+	    done; \
+	  done; \
+	done
+
+#
+# NOTE: you better have GRAPE installed properly before doing this.
+#
+# This target does not depend on any specific compilers, but we have
+# to enable all optional ALBERTA flavours, and we need GRAPE,
+# otherwise the grape-interface will not be included into the
+# distribution.
+#
+generate-alberta-dist: generate-alberta-automakefiles
+	autoreconf
+	./configure --enable-alberta-12 --enable-alberta-13 --enable-alberta-23 --enable-el-index --enable-maintainer-mode
+	make dist
+
 endif
 
 SUFFIXES = .gz .tar .tar.gz