From c04bf61ec61165a5784554d71a9aa9441718065f Mon Sep 17 00:00:00 2001
From: Markus Frosch <markus.frosch@icinga.com>
Date: Fri, 23 Mar 2018 12:48:17 +0100
Subject: [PATCH] Update dist stage Makefiles

---
 Makefile         | 27 ++++++++++++++++++---------
 dist.mk          | 21 +++++++++++++++++++++
 jessie/Makefile  |  8 +-------
 stretch/Makefile |  8 +-------
 wheezy/Makefile  |  8 +-------
 5 files changed, 42 insertions(+), 30 deletions(-)
 create mode 100644 dist.mk

diff --git a/Makefile b/Makefile
index 43c6e37..0a0378d 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 0000000..c529ee6
--- /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 c306097..5575b72 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 c306097..5575b72 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 c306097..5575b72 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
-- 
GitLab