From caed69490485466132348afe283a2e80ab371ed1 Mon Sep 17 00:00:00 2001 From: Natanael Copa <ncopa@alpinelinux.org> Date: Mon, 1 Jun 2020 17:29:37 +0200 Subject: [PATCH] Implement XDT_VERSION_INIT Add an XDT_VERSION_INIT help macro that will define a set of version macros using esyscmd so we no lnger need to use configure.ac.in to perpare the version string for AC_INIT. XDT_VERSION_INIT(SEMVER, [TAG] will set the following macros: - xdt_version - xdt_version_major - xdt_version_minor - xdt_version_micro - xdt_version_tag - xdt_version_build - xdt_debug_default Example usage: XDT_VERSION_INIT([4.15.3],[git]) AC_INIT([xfce4-someproject], [xdt_version()]) ... XDT_FEATURE_DEBUG([xdt_debug_default]) --- .gitignore | 1 - Makefile.am | 2 +- autogen.sh | 11 +--- configure.ac.in => configure.ac | 9 +-- m4macros/Makefile.am | 3 +- m4macros/xdt-version.m4 | 102 ++++++++++++++++++++++++++++++++ scripts/xdt-autogen.in.in | 1 - 7 files changed, 107 insertions(+), 22 deletions(-) rename configure.ac.in => configure.ac (83%) create mode 100644 m4macros/xdt-version.m4 diff --git a/.gitignore b/.gitignore index 793950d..24f3aad 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ scripts/xdt-autogen.in compile config.guess config.sub -configure.ac depcomp libtool ltmain.sh diff --git a/Makefile.am b/Makefile.am index b36ddd9..23212f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ # Written for Xfce by Benedikt Meurer <benny@xfce.org>. # -ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} +ACLOCAL_AMFLAGS = -I m4 -I m4macros ${ACLOCAL_FLAGS} SUBDIRS = \ docs \ diff --git a/autogen.sh b/autogen.sh index 404a962..62d362f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -20,17 +20,8 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -# substitute revision and date -if test -d .git; then - revision=$(git rev-parse --short HEAD) -fi -if test "x$revision" = "x"; then - revision=UNKNOWN -fi -sed -e "s/@REVISION@/${revision}/g" < "configure.ac.in" > "configure.ac" - (libtoolize && - aclocal && + aclocal -I m4macros && automake --add-missing --copy && autoconf) || exit 1 diff --git a/configure.ac.in b/configure.ac similarity index 83% rename from configure.ac.in rename to configure.ac index f42c15e..4398556 100644 --- a/configure.ac.in +++ b/configure.ac @@ -8,14 +8,8 @@ dnl dnl *************************** dnl *** Version information *** dnl *************************** -m4_define([xdt_version_major], [4]) -m4_define([xdt_version_minor], [14]) -m4_define([xdt_version_micro], [0]) -m4_define([xdt_version_nano], []) -m4_define([xdt_version_build], [@REVISION@]) -m4_define([xdt_version_tag], [git]) -m4_define([xdt_version], [xdt_version_major().xdt_version_minor().xdt_version_micro()ifelse(xdt_version_nano(), [], [], [.xdt_version_nano()])ifelse(xdt_version_tag(), [git], [xdt_version_tag()-xdt_version_build()], [])]) +XDT_VERSION_INIT([4.14.0]) dnl # DO NOT MODIFY ANYTHING BELOW THIS LINE, UNLESS YOU KNOW WHAT dnl # YOU ARE DOING. @@ -34,7 +28,6 @@ dnl substitute version info AC_SUBST([VERSION_MAJOR], [xdt_version_major]) AC_SUBST([VERSION_MINOR], [xdt_version_minor]) AC_SUBST([VERSION_MICRO], [xdt_version_micro]) -AC_SUBST([VERSION_NANO], [xdt_version_nano]) VERSION_REVISION=ifelse(xdt_version_tag(), [git], [xdt_version_tag()-xdt_version_build()], []) AC_SUBST([VERSION_REVISION]) diff --git a/m4macros/Makefile.am b/m4macros/Makefile.am index caa4316..51d473d 100644 --- a/m4macros/Makefile.am +++ b/m4macros/Makefile.am @@ -8,7 +8,8 @@ macrodir = $(datadir)/xfce4/dev-tools/m4macros macro_DATA = \ xdt-depends.m4 \ xdt-features.m4 \ - xdt-i18n.m4 + xdt-i18n.m4 \ + xdt-version.m4 EXTRA_DIST = \ $(macro_DATA) diff --git a/m4macros/xdt-version.m4 b/m4macros/xdt-version.m4 new file mode 100644 index 0000000..39d08ff --- /dev/null +++ b/m4macros/xdt-version.m4 @@ -0,0 +1,102 @@ +dnl Copyright (c) 2002-2020 +dnl The Xfce development team. All rights reserved. +dnl +dnl Written for Xfce by Natanael Copa <ncopa@alpinelinux.org> +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with this program; if not, write to the Free Software Foundation, Inc., +dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +dnl +dnl xdt-version +dnl -------- +dnl Version initialization M4 macros. +dnl + + +dnl XDT_VERSION_INIT(SEMVER, [TAG]) +dnl +dnl This macro takes care of setting up the version numbering. +dnl +dnl It will define the following macros based on SEMVER and TAG: +dnl +dnl - xdt_version +dnl - xdt_version_major +dnl - xdt_version_minor +dnl - xdt_version_micro +dnl - xdt_version_tag +dnl - xdt_version_build +dnl - xdt_debug_default +dnl +dnl If TAG isn't specified, the xdt_version_tag and xdt_version_git +dnl will be empty and xdt_debug_default will be set to "minimum", +dnl otherwise the xdt_version_build will contain a git hash and +dnl xdt_debug_default will be set to "yes" +dnl +dnl Example usage: +dnl +dnl XDT_VERSION_INIT([4.15.3],[git]) +dnl AC_INIT([xfce4-someproject], [xdt_version()]) +dnl ... +dnl XDT_FEATURE_DEBUG([xdt_debug_default]) +dnl + +AC_DEFUN([XDT_VERSION_INIT], +[ + m4_define([xdt_version_tag], [$2]) + + dnl set git revision in xdt_version_build if TAG is set + m4_define([xdt_version_build], [ifelse(xdt_version_tag(), [git], + [esyscmd([ + if test -d .git; then + revision=$(git rev-parse --short HEAD 2>/dev/null) + fi + printf "%s" "${revision:-UNKNOWN}" + ])])]) + + dnl define xdt_debug_default to "yes" if TAG is set + m4_define([xdt_debug_default], [ifelse(xdt_version_tag(), [git], [yes], [minimum])]) + + dnl define xdt_version string + m4_define([xdt_version], [$1][ifelse(xdt_version_tag(), [git], [xdt_version_tag()-xdt_version_build()], [xdt_version_tag()])]) + + dnl define major, minor and micro + m4_define([xdt_version_major], [esyscmd([ + version="$1" + printf "%s" "${version%%.*}" + ])]) + + m4_define([xdt_version_minor], [esyscmd([ + version="$1" + case "$version" in + *.*) + major="${version%%.*}" + minor_micro="${version#${major}.}" + printf "%s" "${minor_micro%%.*}" + ;; + esac + ])]) + + m4_define([xdt_version_micro], [esyscmd([ + version="$1" + case "$version" in + *.*.*) + major=${version%%.*} + minor_micro=${version#${major}.} + minor="${minor_micro%%.*}" + reminder=${version#${major}.${minor}.} + printf "%s" "${reminder%%.*}" + ;; + esac + ])]) +]) + diff --git a/scripts/xdt-autogen.in.in b/scripts/xdt-autogen.in.in index ef4c35e..7bcd60c 100644 --- a/scripts/xdt-autogen.in.in +++ b/scripts/xdt-autogen.in.in @@ -27,7 +27,6 @@ VERSION="@VERSION@" XDT_AUTOGEN_VERSION_MAJOR="@VERSION_MAJOR@" XDT_AUTOGEN_VERSION_MINOR="@VERSION_MINOR@" XDT_AUTOGEN_VERSION_MICRO="@VERSION_MICRO@" -XDT_AUTOGEN_VERSION_NANO="@VERSION_NANO@" XDT_AUTOGEN_VERSION_REVISION="@VERSION_REVISION@" -- GitLab