groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/02: Use gnulib script 'git-version-gen' to define groff's ver


From: Bertrand Garrigues
Subject: [groff] 01/02: Use gnulib script 'git-version-gen' to define groff's version
Date: Thu, 1 Feb 2018 18:58:48 -0500 (EST)

bgarrigues pushed a commit to branch master
in repository groff.

commit 126453131024933ec17b9f22701decdf36275bc4
Author: Bertrand Garrigues <address@hidden>
Date:   Sun Jan 14 00:04:13 2018 +0100

    Use gnulib script 'git-version-gen' to define groff's version
    
    * bootstrap.conf: add 'git-version-gen' script.
    
    * configure.ac: suppress 'GROFF_VERSION_STRING' and replace it by
    the script.  If the current commit corresponds to a tag, then the
    version is simply the tag name.  Otherwise the version has the
    format: <tag>-<nb_commits_from_latest_tag>-<commit sha1>.  The
    version is now stored in '.version'.
    
    * REVISION: removed.
    
    * VERSION: removed.
    
    * Makefile.am: define 'MAJOR_VERSION', 'MINOR_VERSION' and
    'REVISION'.
    
    * src/libs/libgroff/libgroff.am: use 'MAJOR_VERSION',
    'MINOR_VERSION' and 'REVISION', add dependency on '.version'.
    
    * src/roff/troff/troff.am: ditto.
    
    * contrib/mom/om.tmac-u (short_revision): new string that extracts
    the first digit of the revision, to be used when checking groff
    version.
---
 .gitignore                    |  3 +++
 ChangeLog                     | 29 +++++++++++++++++++++++++++++
 Makefile.am                   | 35 ++++++++++++++++++++++++++++++++---
 REVISION                      |  1 -
 VERSION                       |  1 -
 bootstrap.conf                |  1 +
 configure.ac                  | 22 ++--------------------
 contrib/mom/om.tmac-u         |  9 ++++++---
 src/libs/libgroff/libgroff.am | 11 ++++-------
 src/roff/troff/troff.am       | 11 ++++-------
 10 files changed, 81 insertions(+), 42 deletions(-)

diff --git a/.gitignore b/.gitignore
index 823129f..d58329c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,3 +98,6 @@ stamp-*
 /troff
 /xtotroff
 /gendef.sh
+/.version
+/cscope.out
+/build
diff --git a/ChangeLog b/ChangeLog
index ea494a1..ceed13d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2018-02-02  Bertrand Garrigues <address@hidden>
+
+       Use gnulib script 'git-version-gen' to define groff's version
+
+       * bootstrap.conf: add 'git-version-gen' script.
+
+       * configure.ac: suppress 'GROFF_VERSION_STRING' and replace it by
+       the script.  If the current commit corresponds to a tag, then the
+       version is simply the tag name.  Otherwise the version has the
+       format: <tag>-<nb_commits_from_latest_tag>-<commit sha1>.  The
+       version is now stored in '.version'.
+
+       * REVISION: removed.
+
+       * VERSION: removed.
+
+       * Makefile.am: define 'MAJOR_VERSION', 'MINOR_VERSION' and
+       'REVISION'.
+
+       * src/libs/libgroff/libgroff.am: use 'MAJOR_VERSION',
+       'MINOR_VERSION' and 'REVISION', add dependency on '.version'.
+
+       * src/roff/troff/troff.am: ditto.
+
+       * contrib/mom/om.tmac-u (short_revision): new string that extracts
+       the first digit of the revision, to be used when checking groff
+       version.
+
+
 2018-01-18  Deri James  <address@hidden>
 
        On reflection using an array for Filter is not optimal.
diff --git a/Makefile.am b/Makefile.am
index 4cd4cf0..7de03f5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,9 +57,7 @@ address@hidden@
 # otherwise no.
 
 
-# VERSION is set by automake, based on what is passed to AC_INIT.  We
-# pass GROFF_VERSION_STRING to it, which skips the revision if set to
-# 0.
+# VERSION is set by automake, based on what is passed to AC_INIT.
 
 # PAGE
 # Define `page' to be letter if your PostScript printer uses 8.5x11
@@ -617,6 +615,30 @@ if MAKE_DONT_HAVE_RM
 RM = rm -f
 endif
 
+# 'VERSION' is generated by gnulib script git-version-gen, using the
+# command 'git describe':
+#
+# - From a git repository: if the current commit corresponds to a
+#   tag, then 'VERSION' is simply the tag (e.g. 1.22.3).  Otherwise
+#   'VERSION' has the following format:
+#     <tag>-<nb_commits>-<commit>
+#
+#   With:
+#     . tag: the most recent tag reachable from the current commit
+#     . nb_commits: number of commits between the most recent tag and
+#       the current commit.
+#     . current commit, abbreviated.
+#   For example: 1.22.3.real.434-5aafd
+#   The version is stored in .version.
+#
+# - From a tarball, the version is taken from .tarball-version
+#
+# REVISION is the full revision given by git-version-gen, which can
+# have non-alphanumeric symbols.
+MAJOR_VERSION =`echo $(VERSION) | sed 's/\([0-9]\+\)\.[0-9]\+.*/\1/'`
+MINOR_VERSION =`echo $(VERSION) | sed 's/[0-9]\+\.\([0-9]\+\).*/\1/'`
+REVISION = `echo $(VERSION) | sed 's/[0-9]\+\.[0-9]\+\.\(.*\)/\1/'`
+
 # Non-recursive makefile system. See Automake manual '7.3 An
 # Alternative Approach to Subdirectories'. We use a single Makefile.am
 # that includes other .am files, rather than using SUBDIRS.  Note that
@@ -900,6 +922,13 @@ SUFFIXES += .man
             -e "s|address@hidden@]|$(VERSION)|g" \
         $< >$@
 
+# Version files - see script 'build-aux/git-gen-version'
+EXTRA_DIST += $(top_srcdir)/.version
+BUILT_SOURCES += $(top_srcdir)/.version
+$(top_srcdir)/.version:
+       echo $(VERSION) > address@hidden && mv address@hidden $@
+dist-hook:
+       echo $(VERSION) > $(distdir)/.tarball-version
 
 ########################################################################
 ### Emacs settings
diff --git a/REVISION b/REVISION
deleted file mode 100644
index 00750ed..0000000
--- a/REVISION
+++ /dev/null
@@ -1 +0,0 @@
-3
diff --git a/VERSION b/VERSION
deleted file mode 100644
index 71f7f51..0000000
--- a/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-1.22
diff --git a/bootstrap.conf b/bootstrap.conf
index dc39207..deda4f6 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -36,6 +36,7 @@ checkout_only_file=README.git
 # havelib provides config.rpath
 # can be get through gettext though
 gnulib_modules="
+    git-version-gen
     havelib
     non-recursive-gnulib-prefix-hack
     wcwidth
diff --git a/configure.ac b/configure.ac
index 40c829d..bf46a4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,29 +18,11 @@
 #
 # Process this file with autoconf to produce a configure script.
 
-dnl Use `VERSION' and `REVISION' files to get version.
-m4_define([GROFF_VERSION_DATA], m4_include([VERSION]))
-m4_define([GROFF_REVISION_DATA], m4_include([REVISION]))
-
-dnl Strip off newline characters.
-m4_define([GROFF_VERSION],
-          m4_substr(GROFF_VERSION_DATA,
-                    [0], m4_decr(m4_len(GROFF_VERSION_DATA))))
-m4_define([GROFF_REVISION],
-          m4_substr(GROFF_REVISION_DATA,
-                    [0], m4_decr(m4_len(GROFF_REVISION_DATA))))
-
-dnl Don't use revision if it is zero.
-m4_define([GROFF_VERSION_STRING],
-          m4_if(m4_eval(GROFF_REVISION[ > 0]),
-                [1],
-                GROFF_VERSION[.]GROFF_REVISION,
-                GROFF_VERSION))
-
 AC_INIT([GNU Troff],
-        GROFF_VERSION_STRING,
+        m4_esyscmd([build-aux/git-version-gen --prefix "" .tarball-version]),
         address@hidden,
         [groff])
+
 AC_PREREQ([2.62])
 
 # Directories where the helper scripts should be found. This must be consistent
diff --git a/contrib/mom/om.tmac-u b/contrib/mom/om.tmac-u
index 78576af..96c06f3 100644
--- a/contrib/mom/om.tmac-u
+++ b/contrib/mom/om.tmac-u
@@ -58,6 +58,9 @@ extensions, and float management).
 .if dVERSION \{\
 .   ab [mom]: Version \*[version]
 .\}
+\# Groff revision
+.ds short_revision \n[.Y]
+.substring short_revision 0 0
 \#
 \# Add supplementary styles
 .sty \n[.fp] UL      \"  Ultra Light
@@ -552,10 +555,10 @@ end
 .       fam \\*[$TYPEWRITER_FAM]
 .       return
 .    \}
-.    if (\\n[.x]\\n[.y]\\n[.Y] >= 1192) .ds $SAVED_STYLE \\n[.sty]
+.    if (\\n[.x]\\n[.y]\\*[short_revision] >= 1192) .ds $SAVED_STYLE \\n[.sty]
 .    ft 0
 .    fam \\*[$FAMILY]
-.    if (\\n[.x]\\n[.y]\\n[.Y] >= 1192) \{\
+.    if (\\n[.x]\\n[.y]\\*[short_revision] >= 1192) \{\
 .       ft \\*[$SAVED_STYLE]
 .       if !F\\n[.fn] .ft 0
 .    \}
@@ -592,7 +595,7 @@ end
 .    \}
 .    ft 0
 .    ft \\*[$FONT]
-.    if (\\n[.x]\\n[.y]\\n[.Y] >= 1192) \{\
+.    if (\\n[.x]\\n[.y]\\*[short_revision] >= 1192) \{\
 .       if '\\n[.sty]'' \{\
 .          if !F\\n[.fn] \{\
 .             if !S\\*[$FONT] \{\
diff --git a/src/libs/libgroff/libgroff.am b/src/libs/libgroff/libgroff.am
index b9cf9b1..b25d64c 100644
--- a/src/libs/libgroff/libgroff.am
+++ b/src/libs/libgroff/libgroff.am
@@ -96,9 +96,6 @@ EXTRA_DIST += \
   src/libs/libgroff/make-uniuni \
   src/libs/snprintf/snprintf.c
 
-src_version=`cat $(top_srcdir)/VERSION`
-src_revision=`cat $(top_srcdir)/REVISION`
-
 CLEANFILES += \
   src/libs/libgroff/version.cpp \
   charset.alias \
@@ -111,12 +108,12 @@ src/libs/libgroff/libgroff_a-fontfile.$(OBJEXT): defs.h
 src/libs/libgroff/libgroff_a-macropath.$(OBJEXT): defs.h
 src/libs/libgroff/libgroff_a-relocate.$(OBJEXT): defs.h
 
-src/libs/libgroff/version.cpp: $(top_srcdir)/VERSION $(top_srcdir)/REVISION
+src/libs/libgroff/version.cpp: $(top_srcdir)/.version
        @echo Making version.cpp
-       @echo const char \*version_string = \"$(src_version)\"\; >$@
-       @echo const char \*revision_string = \"$(src_revision)\"\; >>$@
+       @echo const char \*version_string = 
\"$(MAJOR_VERSION).$(MINOR_VERSION)\"\; >$@
+       @echo const char \*revision_string = \"$(REVISION)\"\; >>$@
        @echo extern \"C\" { >>$@
-       @echo const char \*Version_string = 
\"$(src_version).$(src_revision)\"\; >>$@
+       @echo const char \*Version_string = \"$(VERSION)\"\; >>$@
        @echo } >>$@ \
          | sed -e 's/\.0\"/\"/' >>$@
 
diff --git a/src/roff/troff/troff.am b/src/roff/troff/troff.am
index 191798a..d9c2539 100644
--- a/src/roff/troff/troff.am
+++ b/src/roff/troff/troff.am
@@ -52,15 +52,12 @@ nodist_troff_SOURCES = src/roff/troff/majorminor.cpp
 src/roff/troff/input.$(OBJEXT): defs.h
 CLEANFILES += src/roff/troff/majorminor.cpp
 
-src/roff/troff/majorminor.cpp: $(top_srcdir)/VERSION $(top_srcdir)/REVISION
+src/roff/troff/majorminor.cpp: $(top_srcdir)/.version
        @echo Making $@
        @$(RM) $@
-       @echo const char \*major_version = \
-         \"`sed -e 's/^\([^.]*\)\..*$$/\1/' $(top_srcdir)/VERSION`\"\; >$@
-       @echo const char \*minor_version = \
-          \"`sed -e 's/^[^.]*\.\([0-9]*\).*$$/\1/' $(top_srcdir)/VERSION`\"\; \
-          >>$@
-       @echo const char \*revision = \"`cat $(top_srcdir)/REVISION`\"\; >>$@
+       @echo const char \*major_version = \"$(MAJOR_VERSION)\"\; >$@
+       @echo const char \*minor_version = \"$(MINOR_VERSION)\"\; >>$@
+       @echo const char \*revision = \"$(REVISION)\"\; >>$@
 
 
 ########################################################################



reply via email to

[Prev in Thread] Current Thread [Next in Thread]