From c04877dd956aabaf708bc432f122b387864196b7 Mon Sep 17 00:00:00 2001
From: Kaspar Schleiser <kaspar@schleiser.de>
Date: Tue, 27 Jan 2015 17:25:16 +0100
Subject: [PATCH] make: add bindist targets / Makefiles

---
 Makefile.bindist | 30 ++++++++++++++++++++++++++++++
 Makefile.include |  3 +++
 2 files changed, 33 insertions(+)
 create mode 100644 Makefile.bindist

diff --git a/Makefile.bindist b/Makefile.bindist
new file mode 100644
index 0000000000..da989fa25d
--- /dev/null
+++ b/Makefile.bindist
@@ -0,0 +1,30 @@
+DIST_FILES += bin/$(BOARD)/$(APPLICATION).a
+
+ifneq (, $(filter check_bindist, $(MAKECMDGOALS)))
+	include Makefile.distcheck
+else
+	DIRS+=$(BINARY_DIRS)
+endif
+
+bindist: all
+	@mkdir -p bindist
+	@for i in $(DIST_FILES) ; do \
+		echo Copying $$i to bindist. ; \
+		cp -a --parents $$i bindist ; \
+		done
+	@cp -a bin/$(BOARD)/$(APPLICATION).elf bindist
+
+	@echo "BINDIST_RIOT_VERSION=$(RIOT_VERSION)" > bindist/Makefile.distcheck
+	@echo "BINDIST_GIT_HEAD=$$(git --work-tree=$(RIOTBASE) describe)" >> bindist/Makefile.distcheck
+
+prepare_check_bindist:
+	@[ "$(BINDIST_RIOT_VERSION)" = "$(RIOT_VERSION)" ] || \
+		echo "Warning! RIOT_VERSION doesn't match!"
+	@[ "$(BINDIST_GIT_HEAD)" = "$$(git --work-tree=$(RIOTBASE) describe)" ] || \
+		echo "Warning! git describe doesn't match!"
+
+check_bindist: prepare_check_bindist all
+	@test $(shell md5sum bin/$(BOARD)/$(APPLICATION).elf | cut -f1 -d\ ) \
+		= $(shell md5sum $(APPLICATION).elf | cut -f1 -d\ ) \
+		&& echo "bin/$(BOARD)/$(APPLICATION).elf matches $(APPLICATION).elf." \
+		|| echo "bin/$(BOARD)/$(APPLICATION).elf and $(APPLICATION).elf don't match!"
diff --git a/Makefile.include b/Makefile.include
index c1439114a5..656e5c6fa7 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -451,3 +451,6 @@ endif
 
 # Include desvirt Makefile
 include $(RIOTBASE)/dist/tools/desvirt/Makefile.desvirt
+
+# include bindist target
+include $(RIOTBASE)/Makefile.bindist
-- 
GitLab