diff -r 9131b58f51c4 -r abbbaffa9c9f devel-versioning.rst --- a/devel-versioning.rst Mon Nov 28 01:38:54 2011 +0200 +++ b/devel-versioning.rst Mon Nov 28 01:48:19 2011 +0200 @@ -401,6 +401,39 @@ * Reserving some possible names/prefixes for future use. * Generalising file format or protocol to envelop more cases. +Extracting version from VCS. +============================ + +Including version in sources. +============================= + +Don't use any ``$REVISION`` like keywords (usual practice in CVS, SVN)! + +Use sed, awk, M4 or any other preprocessor for non-compiled or non-preprocessed +files (like .lisp, .py, .java files):: + + $ cat my-version.el.in + (defvar my-major-version @VMAJOR@ + "Major version.") + (defvar my-major-version @VMAJOR@ + "Major version.") + (provide 'my-version) + + $ cat Makefile + %: %.in + sed -e 's|@VMAJOR@|$(VMAJOR)|' -e 's|@VMINOR@|$(VMINOR)|' <$< >$@ + +Pass version component to preprocessed file (like .c, .cxx files) through +preprocessor:: + + $ cat my-version.c + int get_major_version() { return VMAJOR; } + int get_minor_version() { return VMINOR; } + + $ cat Makefile + %.o: %.c + $(CC) -DVMAJOR=$(VMAJOR) -DVMINOR=$(VMINOR) -o $@ $< + Reference. ==========