diff --git a/Makefile b/Makefile
index 43c6e3758e96b706f1fc0258908590524f82a228..0a0378d11d24be0cdb9ab10e7ba20a7f720ab738 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,18 @@
-all:
-	$(MAKE) -C wheezy
-	$(MAKE) -C jessie
-	$(MAKE) -C stretch
-
-push:
-	$(MAKE) -C wheezy push
-	$(MAKE) -C jessie push
-	$(MAKE) -C stretch push
+TARGETS := stretch jessie wheezy
+TARGETS_PUSH := $(TARGETS:=-push)
+TARGETS_CLEAN := $(TARGETS:=-clean)
+
+all: $(TARGETS)
+push: $(TARGETS_PUSH)
+clean: $(TARGETS_CLEAN)
+
+$(TARGETS):
+	$(MAKE) -C $@
+
+$(TARGETS_PUSH):
+	$(MAKE) -C $(@:-push=) push
+
+$(TARGETS_CLEAN):
+	$(MAKE) -C $(@:-clean=) clean
+
+.PHONY: all push clean $(TARGETS) $(TARGETS_PUSH) $(TARGETS_CLEAN)
diff --git a/dist.mk b/dist.mk
new file mode 100644
index 0000000000000000000000000000000000000000..c529ee657bb0a7772654e65c87557c8a5c7b89cb
--- /dev/null
+++ b/dist.mk
@@ -0,0 +1,21 @@
+ifeq ($(VERSIONS),)
+VERSIONS := x86_64 x86
+endif
+
+VERSIONS_PUSH := $(VERSIONS:=-push)
+VERSIONS_CLEAN := $(VERSIONS:=-clean)
+
+all: $(VERSIONS)
+push: $(VERSIONS_PUSH)
+clean: $(VERSIONS_CLEAN)
+
+$(VERSIONS):
+	make -C $@
+
+$(VERSIONS_PUSH):
+	make -C $(@:-push=) push
+
+$(VERSIONS_CLEAN):
+	make -C $(@:-clean=) clean
+
+.PHONY: all push clean $(VERSIONS) $(VERSIONS_PUSH) $(VERSIONS_CLEAN)
diff --git a/jessie/Makefile b/jessie/Makefile
index c306097a532b5ad62559d4b65c760fe29f5b4fb3..5575b7277a605ae7414bb26db324fb38dbb2f465 100644
--- a/jessie/Makefile
+++ b/jessie/Makefile
@@ -1,7 +1 @@
-all:
-	$(MAKE) -C x86_64
-	$(MAKE) -C x86
-
-push:
-	$(MAKE) -C x86_64 push
-	$(MAKE) -C x86 push
+include ../dist.mk
diff --git a/stretch/Makefile b/stretch/Makefile
index c306097a532b5ad62559d4b65c760fe29f5b4fb3..5575b7277a605ae7414bb26db324fb38dbb2f465 100644
--- a/stretch/Makefile
+++ b/stretch/Makefile
@@ -1,7 +1 @@
-all:
-	$(MAKE) -C x86_64
-	$(MAKE) -C x86
-
-push:
-	$(MAKE) -C x86_64 push
-	$(MAKE) -C x86 push
+include ../dist.mk
diff --git a/wheezy/Makefile b/wheezy/Makefile
index c306097a532b5ad62559d4b65c760fe29f5b4fb3..5575b7277a605ae7414bb26db324fb38dbb2f465 100644
--- a/wheezy/Makefile
+++ b/wheezy/Makefile
@@ -1,7 +1 @@
-all:
-	$(MAKE) -C x86_64
-	$(MAKE) -C x86
-
-push:
-	$(MAKE) -C x86_64 push
-	$(MAKE) -C x86 push
+include ../dist.mk