VPP-498: Prepare vpp RPM packaging for use by downstream distros.

Change spec to add new macros to get rid of relative dir reference and
use vpp version. Store version string in .version to store metadata in
dist archive. New script to create dist archive.
Add dist and wipedist targets to Makefile for builds of source RPMs.

Change-Id: I7cf0164f0cb094ec70f3dc323ed7fa2ee82bd902
Signed-off-by: Thomas F Herbert <therbert@redhat.com>
diff --git a/Makefile b/Makefile
index 3a6c783..9870086 100644
--- a/Makefile
+++ b/Makefile
@@ -167,10 +167,27 @@
 	@make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2)
 endef
 
+$(BR)/scripts/.version:
+ifneq ("$(wildcard /etc/redhat-release)","")
+	$(shell $(BR)/scripts/version rpm-string > $(BR)/scripts/.version)
+else
+	$(shell $(BR)/scripts/version > $(BR)/scripts/.version)
+endif
+
+dist:	$(BR)/scripts/.version
+	$(MAKE) verstring=$(PLATFORM)-$(shell cat $(BR)/scripts/.version) prefix=$(PLATFORM) distversion
+
+distversion:	$(BR)/scripts/.version
+	$(BR)/scripts/verdist ${BR} ${prefix}-$(shell $(BR)/scripts/version rpm-version) ${verstring}
+	mv $(verstring).tar.gz $(BR)/rpm
+
 build: $(BR)/.bootstrap.ok
 	$(call make,$(PLATFORM)_debug,vpp-install)
 
-wipe: $(BR)/.bootstrap.ok
+wipedist:
+	$(RM) $(BR)/scripts/.version $(BR)/rpm/*.tar.gz
+
+wipe: wipedist $(BR)/.bootstrap.ok
 	$(call make,$(PLATFORM)_debug,vpp-wipe)
 
 rebuild: wipe build
@@ -271,7 +288,7 @@
 pkg-deb:
 	$(call make,$(PLATFORM),install-deb)
 
-pkg-rpm:
+pkg-rpm: dist
 	$(call make,$(PLATFORM),install-rpm)
 
 ctags: ctags.files