Add 'dist' targets.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Thu, 12 Jan 2012 22:51:11 +0200
changeset 103 b5b1dc62bdc0
parent 102 69269f77a7a0
child 104 4ebab09991e6
Add 'dist' targets.
.hgignore
Makefile
--- a/.hgignore	Thu Jan 12 22:48:08 2012 +0200
+++ b/.hgignore	Thu Jan 12 22:51:11 2012 +0200
@@ -1,7 +1,10 @@
 syntax: glob
 
+VERSION
 *.dict
 *.dict.dz
 *.index
 *.html
+*.tar.gz
+*.tar.bz2
 *~
--- a/Makefile	Thu Jan 12 22:48:08 2012 +0200
+++ b/Makefile	Thu Jan 12 22:51:11 2012 +0200
@@ -25,6 +25,27 @@
 .DEFAULT_GOAL = all
 
 ################################################################
+# Version extracting/generation.
+
+# Prevent from deploying and distributing with wrong version.
+ifneq '' '$(filter deploy%,$(MAKECMDGOALS))'
+  ifeq '' '$(MAKE_RESTARTS)'
+    $(info $(shell rm VERSION))
+  endif
+endif
+
+# Here are vmajor and vminor. Look README section "Versioning rules."
+-include VERSION
+
+VERSION:
+	ver=$$(hg log -r . --template '{latesttag}'); \
+ver=$${ver#t}; \
+major=$${ver%.*}; \
+minor=$${ver#*.}; \
+printf "vmajor=%s\nvminor=%s\n" $$major $$minor >VERSION
+	# is_release=`hg log --template '{latesttagdistance}'`
+
+################################################################
 # Platform/environment definition.
 
 host_os = unix
@@ -67,6 +88,45 @@
 RST_FILES := $(wildcard *.rst)
 HTML_FILES := $(RST_FILES:.rst=.html)
 
+name = gadict
+fullpkgname = $(name)-$(vmajor).$(vminor)
+
+DIST_DIR = $(fullpkgname)
+DISTSRC_DIR = $(fullpkgname)_src
+
+DIST_FILES = $(DICTDZ_FILES) $(INDEX_FILES) $(HTML_FILES) $(RST_FILES) VERSION
+
+DISTSRC_HELPER_FILES = VERSION Makefile rst.css .dir-locals.el
+DISTSRC_FILES = $(HTML_FILES) $(RST_FILES) $(DISTSRC_HELPER_FILES)
+
+################################################################
+# Dist targets.
+
+.PHONY: dist
+dist: dist-dictd dist-src
+
+.PHONY: dist-dictd
+dist-dictd: $(DIST_DIR).tar.gz $(DIST_DIR).tar.bz2
+
+.PHONY: dist-src
+dist-src: $(DISTSRC_DIR).tar.gz $(DISTSRC_DIR).tar.bz2
+
+%.tar.gz: %
+	tar zcf $*.tar.gz $*
+
+%.tar.bz2: %
+	tar jcf $*.tar.bz2 $*
+
+$(DIST_DIR): $(DIST_FILES)
+	rm -rf $@
+	mkdir $@
+	cp $(DIST_FILES) $@
+
+$(DISTSRC_DIR): $(DISTSRC_FILES)
+	rm -rf $@
+	mkdir $@
+	cp $(DISTSRC_FILES) $@
+
 ################################################################
 # Build targets.